From 0524fa6a46185b08f8d9cf8d5aa4cecee0b5b675 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Thu, 6 Jul 2017 12:49:51 +0100 Subject: [PATCH] Improve inventory scoping for limited play execution When executing the playbook with limits set, the scoping currently does not work quite as well as one would hope. This tightens it a bit more to ensure that it operates as expected. Change-Id: I8ebd42bcdf9676fd580955256498bbd8801f1cbd --- handlers/main.yml | 2 +- tasks/main.yml | 2 +- tasks/neutron_db_setup.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index 516a7845..94b30969 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -71,7 +71,7 @@ when: - "ansible_local['openstack_ansible']['neutron']['need_db_contract'] | bool" - "neutron_services['neutron-server']['group'] in group_names" - - "inventory_hostname == ansible_play_hosts[0]" + - "inventory_hostname == (groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts))[0]" listen: "Restart neutron services" - name: Start services diff --git a/tasks/main.yml b/tasks/main.yml index f58946e3..b9bb93fb 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -96,7 +96,7 @@ static: no when: - "neutron_services['neutron-server']['group'] in group_names" - - "inventory_hostname == ansible_play_hosts[0]" + - "inventory_hostname == (groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts))[0]" tags: - neutron-config diff --git a/tasks/neutron_db_setup.yml b/tasks/neutron_db_setup.yml index 6620a870..746b8bc0 100644 --- a/tasks/neutron_db_setup.yml +++ b/tasks/neutron_db_setup.yml @@ -19,7 +19,7 @@ become_user: "{{ neutron_system_user_name }}" when: - "ansible_local['openstack_ansible']['neutron']['need_db_expand'] | bool" - - "inventory_hostname == ansible_play_hosts[0]" + - "inventory_hostname == (groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts))[0]" - name: Disable the db expand fact ini_file: @@ -33,7 +33,7 @@ become: yes become_user: "{{ neutron_system_user_name }}" when: - - "inventory_hostname == ansible_play_hosts[0]" + - "inventory_hostname == (groups[neutron_services['neutron-server']['group']] | intersect(ansible_play_hosts))[0]" changed_when: false register: _offline_migrations_check failed_when: