From f1b82f43c4fdc85fe465ffbd4aa1a061eabab48d 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 --- defaults/main.yml | 7 +++++++ tasks/main.yml | 4 ++-- tasks/neutron_db_setup.yml | 4 ++-- tasks/neutron_install.yml | 2 +- tasks/neutron_post_install.yml | 9 ++++----- tasks/neutron_upstart_init.yml | 14 +++++++------- tasks/plumgrid_config.yml | 8 ++++---- templates/neutron.conf.j2 | 4 ++-- 8 files changed, 29 insertions(+), 23 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 8c681855..03b21611 100644 --- a/defaults/main.yml +++ b/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/tasks/main.yml b/tasks/main.yml index 779f9f1f..40646921 100644 --- a/tasks/main.yml +++ b/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/tasks/neutron_db_setup.yml b/tasks/neutron_db_setup.yml index ca01379e..ed903f92 100644 --- a/tasks/neutron_db_setup.yml +++ b/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/tasks/neutron_install.yml b/tasks/neutron_install.yml index 8f79ca91..5820719b 100644 --- a/tasks/neutron_install.yml +++ b/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/tasks/neutron_post_install.yml b/tasks/neutron_post_install.yml index c8513e19..9be58488 100644 --- a/tasks/neutron_post_install.yml +++ b/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/tasks/neutron_upstart_init.yml b/tasks/neutron_upstart_init.yml index d5720ca6..ef47d726 100644 --- a/tasks/neutron_upstart_init.yml +++ b/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/tasks/plumgrid_config.yml b/tasks/plumgrid_config.yml index d02520b6..7100a98c 100644 --- a/tasks/plumgrid_config.yml +++ b/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/templates/neutron.conf.j2 b/templates/neutron.conf.j2 index 3baa115e..44912f63 100644 --- a/templates/neutron.conf.j2 +++ b/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 %}