From c03c932c9b172c2fc4d9033684d124e2a3141081 Mon Sep 17 00:00:00 2001 From: Jimmy McCrory Date: Mon, 13 Nov 2017 08:40:17 -0800 Subject: [PATCH] Use known group names Avoid assuming that provider or deployment specific groups are defined in inventory by making use of the group names defined in the 'neutron_services' var and checking group membership through a host's group_names instead of Ansible's groups dictionary. Change-Id: I66b7c639494d98fdb3baa52fe56c670e32dea3ce --- meta/main.yml | 2 +- tasks/providers/dragonflow_config.yml | 4 ++-- tasks/providers/opendaylight_config.yml | 2 +- tests/calico_inventory | 2 -- tests/dragonflow_inventory | 2 -- tests/lxb_inventory | 2 -- tests/opendaylight_inventory | 2 -- tests/ovs_inventory | 2 -- vars/main.yml | 4 ++-- 9 files changed, 6 insertions(+), 16 deletions(-) diff --git a/meta/main.yml b/meta/main.yml index 3e562415..4e35a31c 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -58,4 +58,4 @@ dependencies: extra_features: "{{ opendaylight_extra_features }}" when: - neutron_plugin_type == "ml2.opendaylight" - - inventory_hostname in groups["opendaylight"] + - "'opendaylight' in group_names" diff --git a/tasks/providers/dragonflow_config.yml b/tasks/providers/dragonflow_config.yml index 68e4fa99..d14eeff5 100644 --- a/tasks/providers/dragonflow_config.yml +++ b/tasks/providers/dragonflow_config.yml @@ -73,5 +73,5 @@ tags: - dragonflow-config when: - - (inventory_hostname in groups[neutron_services['dragonflow-l3-agent']['group']]) or - (inventory_hostname in groups[neutron_services['dragonflow-controller-agent']['group']]) + - (neutron_services['dragonflow-l3-agent']['group'] in group_names) or + (neutron_services['dragonflow-controller-agent']['group'] in group_names) diff --git a/tasks/providers/opendaylight_config.yml b/tasks/providers/opendaylight_config.yml index f88e38d2..eab3d4dc 100644 --- a/tasks/providers/opendaylight_config.yml +++ b/tasks/providers/opendaylight_config.yml @@ -32,4 +32,4 @@ - opendaylight-pip-packages - include: setup_ovs_opendaylight.yml - when: (inventory_hostname in groups['neutron_agents_container'] or inventory_hostname in groups['compute_hosts']) + when: neutron_services['neutron-server']['group'] not in group_names diff --git a/tests/calico_inventory b/tests/calico_inventory index 5dcfd0cb..344e41e9 100644 --- a/tests/calico_inventory +++ b/tests/calico_inventory @@ -56,8 +56,6 @@ server2 [neutron_l3_agent] [neutron_lbaas_agent] [neutron_metadata_agent] -[neutron_agents_container] -[compute_hosts] [neutron_all:children] neutron_agent diff --git a/tests/dragonflow_inventory b/tests/dragonflow_inventory index c9e53b7b..0fe75e3c 100644 --- a/tests/dragonflow_inventory +++ b/tests/dragonflow_inventory @@ -63,8 +63,6 @@ agents2 [neutron_l3_agent] [neutron_lbaas_agent] [neutron_metadata_agent] -[neutron_agents_container] -[compute_hosts] [neutron_all:children] neutron_agent diff --git a/tests/lxb_inventory b/tests/lxb_inventory index 25cb32c5..b10413e1 100644 --- a/tests/lxb_inventory +++ b/tests/lxb_inventory @@ -68,8 +68,6 @@ server1 server2 [neutron_calico_dhcp_agent] -[neutron_agents_container] -[compute_hosts] [neutron_all:children] neutron_agent diff --git a/tests/opendaylight_inventory b/tests/opendaylight_inventory index 0c06b512..f12d9d93 100644 --- a/tests/opendaylight_inventory +++ b/tests/opendaylight_inventory @@ -46,8 +46,6 @@ server1 [neutron_l3_agent] [neutron_lbaas_agent] [neutron_metadata_agent] -[neutron_agents_container] -[compute_hosts] [neutron_all:children] neutron_agent diff --git a/tests/ovs_inventory b/tests/ovs_inventory index 1c553f90..d15f929f 100644 --- a/tests/ovs_inventory +++ b/tests/ovs_inventory @@ -68,8 +68,6 @@ server1 server2 [neutron_calico_dhcp_agent] -[neutron_agents_container] -[compute_hosts] [neutron_all:children] neutron_agent diff --git a/vars/main.yml b/vars/main.yml index d80fb03a..2c037d54 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -27,7 +27,7 @@ neutron_package_list: |- {% if (neutron_services['neutron-openvswitch-agent']['group'] in group_names and neutron_services['neutron-openvswitch-agent'].service_en | bool) or (neutron_services['dragonflow-controller-agent']['group'] in group_names and neutron_services['dragonflow-controller-agent'].service_en | bool) or (neutron_services['dragonflow-l3-agent']['group'] in group_names and neutron_services['dragonflow-l3-agent'].service_en | bool) - or ((inventory_hostname in groups['neutron_agents_container'] or inventory_hostname in groups['compute_hosts']) and neutron_plugin_type == 'ml2.opendaylight') %} + or ((neutron_services['neutron-server']['group'] not in group_names) and neutron_plugin_type == 'ml2.opendaylight') %} {% set _ = packages.extend(neutron_ovs_distro_packages) %} {% endif %} {% if neutron_services['neutron-linuxbridge-agent']['group'] in group_names and neutron_services['neutron-linuxbridge-agent'].service_en | bool %} @@ -241,7 +241,7 @@ opendaylight_install_method: "{{ (ansible_os_family=='Debian') | ternary('deb_re ovs_manager_list: |- {% set ovs_managers_odls = [] %} - {% for host in groups["neutron_server_container"] %} + {% for host in neutron_services['neutron-server']['group'] %} {% set odl_ip_address = hostvars[host]['container_address']|string %} {% set _ = ovs_managers_odls.append('tcp:' + odl_ip_address + ':6640') %} {% endfor %}