diff --git a/ansible/roles/neutron/tasks/do_reconfigure.yml b/ansible/roles/neutron/tasks/do_reconfigure.yml new file mode 100644 index 0000000000..6441c96f3f --- /dev/null +++ b/ansible/roles/neutron/tasks/do_reconfigure.yml @@ -0,0 +1,272 @@ +--- +- name: Ensuring the containers running neutron-server and neutron agents are up + kolla_docker: + name: "{{ item.name }}" + action: "get_container_state" + register: container_state + failed_when: container_state.Running == false + when: inventory_hostname in groups[item.group] + with_items: + - { name: neutron_server, group: neutron-server } + - { name: neutron_dhcp_agent, group: neutron-dhcp-agent } + - { name: neutron_l3_agent, group: neutron-l3-agent } + - { name: neutron_metadata_agent, group: neutron-metadata-agent } + +- name: Ensuring the neutron_openvswitch_agent container is up + kolla_docker: + name: neutron_openvswitch_agent + action: "get_container_state" + register: container_state + failed_when: container_state.Running == false + when: + - ( + ( inventory_hostname in groups['compute'] + or inventory_hostname in groups['manila-share'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent'] + and not enable_nova_fake | bool + ) or + ( inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent'] + and enable_nova_fake | bool + ) + ) + - neutron_plugin_agent == "openvswitch" + +- name: Ensuring the neutron_linuxbridge_agent container is up + kolla_docker: + name: neutron_openvswitch_agent + action: "get_container_state" + register: container_state + failed_when: container_state.Running == false + when: + - (inventory_hostname in groups['compute'] + or inventory_hostname in groups['manila-share'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent']) + - neutron_plugin_agent == "linuxbridge" + +- include: config.yml + +- name: Check the configs in containers running neutron-server and neutron agents + command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check + changed_when: false + failed_when: false + register: check_results + when: inventory_hostname in groups[item.group] + with_items: + - { name: neutron_server, group: neutron-server } + - { name: neutron_dhcp_agent, group: neutron-dhcp-agent } + - { name: neutron_l3_agent, group: neutron-l3-agent } + - { name: neutron_metadata_agent, group: neutron-metadata-agent } + +- name: Check the configs in the neutron_openvswitch_agent container + command: docker exec neutron_openvswitch_agent /usr/local/bin/kolla_set_configs --check + changed_when: false + failed_when: false + when: + - ( + ( inventory_hostname in groups['compute'] + or inventory_hostname in groups['manila-share'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent'] + and not enable_nova_fake | bool + ) or + ( inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent'] + and enable_nova_fake | bool + ) + ) + - neutron_plugin_agent == "openvswitch" + +- name: Check the configs in the neutron_linuxbridge_agent container + command: docker exec neutron_linuxbridge_agent /usr/local/bin/kolla_set_configs --check + changed_when: false + failed_when: false + when: + - (inventory_hostname in groups['compute'] + or inventory_hostname in groups['manila-share'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent']) + - neutron_plugin_agent == "linuxbridge" + +# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS' +# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE', +# just remove the container and start again +- name: Containers config strategy for containers running neutron-server and neutron agents + kolla_docker: + name: "{{ item.name }}" + action: "get_container_env" + register: container_envs + when: inventory_hostname in groups[item.group] + with_items: + - { name: neutron_server, group: neutron-server } + - { name: neutron_dhcp_agent, group: neutron-dhcp-agent } + - { name: neutron_l3_agent, group: neutron-l3-agent } + - { name: neutron_metadata_agent, group: neutron-metadata-agent } + +- name: Container config strategy for the neutron_openvswitch_agent container + kolla_docker: + name: "neutron_openvswitch_agent" + action: "get_container_env" + when: + - ( + ( inventory_hostname in groups['compute'] + or inventory_hostname in groups['manila-share'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent'] + and not enable_nova_fake | bool + ) or + ( inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent'] + and enable_nova_fake | bool + ) + ) + - neutron_plugin_agent == "openvswitch" + +- name: Container config strategy for the neutron_linuxbridge_agent container + kolla_docker: + name: "neutron_linuxbridge_agent" + action: "get_container_env" + when: + - (inventory_hostname in groups['compute'] + or inventory_hostname in groups['manila-share'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent']) + - neutron_plugin_agent == "linuxbridge" + +- name: Remove the containers running neutron-server and neutron agents + kolla_docker: + name: "{{ item[0]['name'] }}" + action: "remove_container" + register: remove_containers + when: + - config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE' + - item[2]['rc'] == 1 + - inventory_hostname in groups[item[0]['group']] + with_together: + - [{ name: neutron_server, group: neutron-server }, + { name: neutron_dhcp_agent, group: neutron-dhcp-agent }, + { name: neutron_l3_agent, group: neutron-l3-agent }, + { name: neutron_metadata_agent, group: neutron-metadata-agent }] + - container_envs.results + - check_results.results + +- name: Remove the neutron_openvswitch_agent container + kolla_docker: + name: "neutron_openvswitch_agent" + action: "remove_container" + register: remove_containers + when: + - config_strategy == "COPY_ONCE" or item[0]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE' + - item[1]['rc'] == 1 + - ( + ( inventory_hostname in groups['compute'] + or inventory_hostname in groups['manila-share'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent'] + and not enable_nova_fake | bool + ) or + ( inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent'] + and enable_nova_fake | bool + ) + ) + - neutron_plugin_agent == "openvswitch" + with_together: + - container_envs.results + - check_results.results + +- name: Remove the neutron_linuxbridge_agent container + kolla_docker: + name: "neutron_linuxbridge_agent" + action: "remove_container" + register: remove_containers + when: + - config_strategy == "COPY_ONCE" or item[0]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE' + - item[1]['rc'] == 1 + - (inventory_hostname in groups['compute'] + or inventory_hostname in groups['manila-share'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent']) + - neutron_plugin_agent == "linuxbridge" + with_together: + - container_envs.results + - check_results.results + +- include: start.yml + when: remove_containers.changed + +- name: Restart containers running neutron-server and neutron agents + kolla_docker: + name: "{{ item[0]['name'] }}" + action: "restart_container" + when: + - config_strategy == 'COPY_ALWAYS' + - item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE' + - item[2]['rc'] == 1 + - inventory_hostname in groups[item[0]['group']] + with_together: + - [{ name: neutron_server, group: neutron-server }, + { name: neutron_dhcp_agent, group: neutron-dhcp-agent }, + { name: neutron_l3_agent, group: neutron-l3-agent }, + { name: neutron_metadata_agent, group: neutron-metadata-agent }] + - container_envs.results + - check_results.results + +- name: Restart the neutron_openvswitch_agent container + kolla_docker: + name: "neutron_openvswitch_agent" + action: "restart_container" + when: + - config_strategy == 'COPY_ALWAYS' + - item[0]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE' + - item[1]['rc'] == 1 + - ( + ( inventory_hostname in groups['compute'] + or inventory_hostname in groups['manila-share'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent'] + and not enable_nova_fake | bool + ) or + ( inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent'] + and enable_nova_fake | bool + ) + ) + - neutron_plugin_agent == "openvswitch" + with_together: + - container_envs.results + - check_results.results + +- name: Restart the neutron_linuxbridge_agent container + kolla_docker: + name: "neutron_linuxbridge_agent" + action: "restart_container" + when: + - config_strategy == 'COPY_ALWAYS' + - item[0]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE' + - item[1]['rc'] == 1 + - (inventory_hostname in groups['compute'] + or inventory_hostname in groups['manila-share'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent']) + - neutron_plugin_agent == "linuxbridge" + with_together: + - container_envs.results + - check_results.results diff --git a/ansible/roles/neutron/tasks/reconfigure.yml b/ansible/roles/neutron/tasks/reconfigure.yml index ed97d539c0..94ca71b961 100644 --- a/ansible/roles/neutron/tasks/reconfigure.yml +++ b/ansible/roles/neutron/tasks/reconfigure.yml @@ -1 +1,9 @@ --- +- include: do_reconfigure.yml + serial: "30%" + when: inventory_hostname in groups['neutron-server'] + or inventory_hostname in groups['neutron-openvswitch-agent'] + or inventory_hostname in groups['neutron-linuxbridge-agent'] + or inventory_hostname in groups['neutron-dhcp-agent'] + or inventory_hostname in groups['neutron-l3-agent'] + or inventory_hostname in groups['neutron-metadata-agent']