From 929a172be98985c9e1d95d4fd3c823be83dbee86 Mon Sep 17 00:00:00 2001 From: Logan V Date: Fri, 20 Nov 2015 16:22:06 -0600 Subject: [PATCH] Allow neutron services to move around environment Enable neutron services to be moved around the environment by addressing the service groups directly in neutron tasks instead of assuming everything lives on the neutron_agents containers. Change-Id: I631226d695ae5e916d74be51a126896e45589610 Closes-Bug: #1510202 --- playbooks/roles/os_neutron/defaults/main.yml | 7 +++++++ playbooks/roles/os_neutron/tasks/main.yml | 4 ++-- .../roles/os_neutron/tasks/neutron_db_setup.yml | 4 ++-- .../roles/os_neutron/tasks/neutron_install.yml | 2 +- .../os_neutron/tasks/neutron_post_install.yml | 9 ++++----- .../os_neutron/tasks/neutron_upstart_init.yml | 14 +++++++------- .../roles/os_neutron/tasks/plumgrid_config.yml | 8 ++++---- .../roles/os_neutron/templates/neutron.conf.j2 | 4 ++-- 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/playbooks/roles/os_neutron/defaults/main.yml b/playbooks/roles/os_neutron/defaults/main.yml index 8c681855db..03b2161121 100644 --- a/playbooks/roles/os_neutron/defaults/main.yml +++ b/playbooks/roles/os_neutron/defaults/main.yml @@ -96,6 +96,7 @@ neutron_plugins: neutron_services: neutron-dhcp-agent: + group: neutron_dhcp_agent service_name: neutron-dhcp-agent service_en: True service_conf: dhcp_agent.ini @@ -105,6 +106,7 @@ neutron_services: config_overrides: "{{ neutron_dhcp_agent_ini_overrides }}" config_type: "ini" neutron-linuxbridge-agent: + group: neutron_linuxbridge_agent service_name: neutron-linuxbridge-agent service_en: True service_conf: plugins/ml2/linuxbridge_agent.ini @@ -114,6 +116,7 @@ neutron_services: config_overrides: "{{ neutron_linuxbridge_agent_ini_overrides }}" config_type: "ini" neutron-metadata-agent: + group: neutron_metadata_agent service_name: neutron-metadata-agent service_en: True service_conf: metadata_agent.ini @@ -122,6 +125,7 @@ neutron_services: config_overrides: "{{ neutron_metadata_agent_ini_overrides }}" config_type: "ini" neutron-metering-agent: + group: neutron_metering_agent service_name: neutron-metering-agent service_en: "{{ neutron_metering }}" service_conf: metering_agent.ini @@ -130,6 +134,7 @@ neutron_services: config_overrides: "{{ neutron_metering_agent_ini_overrides }}" config_type: "ini" neutron-l3-agent: + group: neutron_l3_agent service_name: neutron-l3-agent service_en: "{{ neutron_l3 }}" service_conf: l3_agent.ini @@ -139,6 +144,7 @@ neutron_services: config_overrides: "{{ neutron_l3_agent_ini_overrides }}" config_type: "ini" neutron-lbaas-agent: + group: neutron_lbaas_agent service_name: neutron-lbaas-agent service_en: "{{ neutron_lbaas }}" service_conf: lbaas_agent.ini @@ -148,6 +154,7 @@ neutron_services: config_overrides: "{{ neutron_lbaas_agent_ini_overrides }}" config_type: "ini" neutron-server: + group: neutron_server service_name: neutron-server service_en: True service_group: neutron_server diff --git a/playbooks/roles/os_neutron/tasks/main.yml b/playbooks/roles/os_neutron/tasks/main.yml index 779f9f1f0a..4064692137 100644 --- a/playbooks/roles/os_neutron/tasks/main.yml +++ b/playbooks/roles/os_neutron/tasks/main.yml @@ -20,7 +20,7 @@ - include: neutron_db_setup.yml when: > - inventory_hostname == groups['neutron_server'][0] + inventory_hostname == groups[neutron_services['neutron-server']['group']][0] - include: neutron_service_setup.yml when: > @@ -28,7 +28,7 @@ - include: neutron_l3_ha.yml when: > - inventory_hostname in groups['neutron_agent'] + inventory_hostname in groups[neutron_services['neutron-l3-agent']['group']] - name: Flush handlers meta: flush_handlers diff --git a/playbooks/roles/os_neutron/tasks/neutron_db_setup.yml b/playbooks/roles/os_neutron/tasks/neutron_db_setup.yml index ca01379eb3..ed903f92f5 100644 --- a/playbooks/roles/os_neutron/tasks/neutron_db_setup.yml +++ b/playbooks/roles/os_neutron/tasks/neutron_db_setup.yml @@ -77,7 +77,7 @@ state: stopped pattern: "neutron-server" delegate_to: "{{ item }}" - with_items: groups['neutron_server'] + with_items: groups[neutron_services['neutron-server']['group']] when: (neutron_migrations is defined and neutron_migrations['run_contract']|bool) or neutron_plugin_type != 'ml2' tags: - neutron-db-setup @@ -121,7 +121,7 @@ state: started pattern: "neutron-server" delegate_to: "{{ item }}" - with_items: groups['neutron_server'] + with_items: groups[neutron_services['neutron-server']['group']] when: (neutron_migrations is defined and neutron_migrations['run_contract']|bool) or neutron_plugin_type != 'ml2' tags: - neutron-db-setup diff --git a/playbooks/roles/os_neutron/tasks/neutron_install.yml b/playbooks/roles/os_neutron/tasks/neutron_install.yml index 8f79ca91fd..5820719bf2 100644 --- a/playbooks/roles/os_neutron/tasks/neutron_install.yml +++ b/playbooks/roles/os_neutron/tasks/neutron_install.yml @@ -47,7 +47,7 @@ delay: 2 with_items: neutron_lbaas_apt_packages when: - - inventory_hostname in groups['neutron_agents_container'] + - inventory_hostname in groups[neutron_services['neutron-lbaas-agent']['group']] - neutron_lbaas | bool tags: - neutron-install diff --git a/playbooks/roles/os_neutron/tasks/neutron_post_install.yml b/playbooks/roles/os_neutron/tasks/neutron_post_install.yml index c8513e195c..9be58488f7 100644 --- a/playbooks/roles/os_neutron/tasks/neutron_post_install.yml +++ b/playbooks/roles/os_neutron/tasks/neutron_post_install.yml @@ -60,7 +60,7 @@ notify: - Restart neutron services when: > - inventory_hostname in groups['neutron_agents_container'] + inventory_hostname in groups[neutron_services['neutron-dhcp-agent']['group']] tags: - neutron-config @@ -79,8 +79,7 @@ when: - item.value.service_en | bool - item.value.service_conf is defined - - (inventory_hostname in groups['neutron_agents_container'] or - inventory_hostname in groups['neutron_linuxbridge_agent']) + - inventory_hostname in groups[item.value.group] tags: - neutron-config @@ -127,7 +126,7 @@ group: "root" mode: "0755" when: > - inventory_hostname in groups['neutron_linuxbridge_agent'] + inventory_hostname in groups[neutron_services['neutron-linuxbridge-agent']['group']] tags: - neutron-config - neutron-checksum-fix @@ -135,7 +134,7 @@ - name: Run iptables checksum fix command: /etc/network/if-up.d/post-up-checksum-rules when: > - inventory_hostname in groups['neutron_linuxbridge_agent'] + inventory_hostname in groups[neutron_services['neutron-linuxbridge-agent']['group']] tags: - neutron-config - neutron-checksum-fix diff --git a/playbooks/roles/os_neutron/tasks/neutron_upstart_init.yml b/playbooks/roles/os_neutron/tasks/neutron_upstart_init.yml index d5720ca6eb..ef47d72678 100644 --- a/playbooks/roles/os_neutron/tasks/neutron_upstart_init.yml +++ b/playbooks/roles/os_neutron/tasks/neutron_upstart_init.yml @@ -22,7 +22,7 @@ system_group: "{{ neutron_system_group_name }}" service_home: "{{ neutron_system_home_folder }}" when: - - inventory_hostname in groups['neutron_server'] + - inventory_hostname in groups[neutron_services['neutron-server']['group']] - neutron_services['neutron-server'].service_en | bool tags: - upstart-init @@ -36,7 +36,7 @@ system_group: "{{ neutron_system_group_name }}" service_home: "{{ neutron_system_home_folder }}" when: - - inventory_hostname in groups['neutron_agent'] + - inventory_hostname in groups[neutron_services['neutron-dhcp-agent']['group']] - neutron_services['neutron-dhcp-agent'].service_en | bool tags: - upstart-init @@ -50,7 +50,7 @@ system_group: "{{ neutron_system_group_name }}" service_home: "{{ neutron_system_home_folder }}" when: - - inventory_hostname in groups['neutron_agent'] + - inventory_hostname in groups[neutron_services['neutron-l3-agent']['group']] - neutron_services['neutron-l3-agent'].service_en | bool tags: - upstart-init @@ -64,7 +64,7 @@ system_group: "{{ neutron_system_group_name }}" service_home: "{{ neutron_system_home_folder }}" when: - - inventory_hostname in groups['neutron_linuxbridge_agent'] + - inventory_hostname in groups[neutron_services['neutron-linuxbridge-agent']['group']] - neutron_services['neutron-linuxbridge-agent'].service_en | bool tags: - upstart-init @@ -78,7 +78,7 @@ system_group: "{{ neutron_system_group_name }}" service_home: "{{ neutron_system_home_folder }}" when: - - inventory_hostname in groups['neutron_agent'] + - inventory_hostname in groups[neutron_services['neutron-metadata-agent']['group']] - neutron_services['neutron-metadata-agent'].service_en | bool tags: - upstart-init @@ -92,7 +92,7 @@ system_group: "{{ neutron_system_group_name }}" service_home: "{{ neutron_system_home_folder }}" when: - - inventory_hostname in groups['neutron_agent'] + - inventory_hostname in groups[neutron_services['neutron-metering-agent']['group']] - neutron_services['neutron-metering-agent'].service_en | bool tags: - upstart-init @@ -106,7 +106,7 @@ system_group: "{{ neutron_system_group_name }}" service_home: "{{ neutron_system_home_folder }}" when: - - inventory_hostname in groups['neutron_agent'] + - inventory_hostname in groups[neutron_services['neutron-lbaas-agent']['group']] - neutron_services['neutron-lbaas-agent'].service_en | bool tags: - upstart-init diff --git a/playbooks/roles/os_neutron/tasks/plumgrid_config.yml b/playbooks/roles/os_neutron/tasks/plumgrid_config.yml index d02520b640..7100a98c8f 100644 --- a/playbooks/roles/os_neutron/tasks/plumgrid_config.yml +++ b/playbooks/roles/os_neutron/tasks/plumgrid_config.yml @@ -39,7 +39,7 @@ - "{{ neutron_optional_plumgrid_pip_packages }}" when: - neutron_venv_enabled | bool - - inventory_hostname in groups['neutron_server'] + - inventory_hostname in groups[neutron_services['neutron-server']['group']] tags: - neutron-install - neutron-pip-packages @@ -60,7 +60,7 @@ - "{{ neutron_optional_plumgrid_pip_packages }}" when: - neutron_venv_enabled | bool - - inventory_hostname in groups['neutron_server'] + - inventory_hostname in groups[neutron_services['neutron-server']['group']] tags: - neutron-install - neutron-pip-packages @@ -79,7 +79,7 @@ - "{{ neutron_optional_plumgrid_pip_packages }}" when: - not neutron_venv_enabled | bool - - inventory_hostname in groups['neutron_server'] + - inventory_hostname in groups[neutron_services['neutron-server']['group']] tags: - neutron-install - neutron-pip-packages @@ -98,7 +98,7 @@ - "{{ neutron_optional_plumgrid_pip_packages }}" when: - not neutron_venv_enabled | bool - - inventory_hostname in groups['neutron_server'] + - inventory_hostname in groups[neutron_services['neutron-server']['group']] tags: - neutron-install - neutron-pip-packages diff --git a/playbooks/roles/os_neutron/templates/neutron.conf.j2 b/playbooks/roles/os_neutron/templates/neutron.conf.j2 index 3baa115e8b..44912f6315 100644 --- a/playbooks/roles/os_neutron/templates/neutron.conf.j2 +++ b/playbooks/roles/os_neutron/templates/neutron.conf.j2 @@ -10,7 +10,7 @@ debug = {{ debug }} fatal_deprecations = {{ neutron_fatal_deprecations }} log_file = /var/log/neutron/neutron.log -{% if inventory_hostname in groups['neutron_server'] %} +{% if inventory_hostname in groups[neutron_services['neutron-server']['group']] %} # General, only applies to neutron server host group network_device_mtu = {{ neutron_network_device_mtu }} @@ -48,7 +48,7 @@ router_distributed = False # Agents agent_down_time = {{ neutron_agent_down_time }} -{% set num_agent = groups['neutron_agent'] | length %} +{% set num_agent = groups[neutron_services['neutron-dhcp-agent']['group']] | length %} {% if neutron_plugin_type == 'ml2' and num_agent >= 2 %} {% if neutron_services['neutron-linuxbridge-agent']['service_en'] | bool %}