From 4fb7413e5717904cc1fe6db678c6a852b2842bde Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Sun, 5 Jul 2020 12:07:38 +0300 Subject: [PATCH] Fix run task conditionals Current conditionals didn't work correctly with running tasks with --limit We should intersect with ansible_play_hosts to get tasks run for specific host only (ie running with --limit) Change-Id: I56e873114cf85b29233d50a866ee925615dba70b --- tasks/main.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 77f7df7..6d7a817 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -27,7 +27,7 @@ - import_tasks: db_setup.yml when: - - inventory_hostname == groups['gnocchi_all'][0] + - inventory_hostname == (groups['gnocchi_all'] | intersect(ansible_play_hosts))[0] vars: _oslodb_setup_host: "{{ gnocchi_db_setup_host }}" _oslodb_databases: @@ -115,19 +115,20 @@ type: "{{ gnocchi_service_type }}" description: "{{ gnocchi_service_description }}" when: - - inventory_hostname == groups['gnocchi_all'][0] + - inventory_hostname == (groups['gnocchi_all'] | intersect(ansible_play_hosts))[0] - not gnocchi_identity_only | bool tags: - gnocchi-config - import_tasks: gnocchi_identity_setup.yml - when: inventory_hostname == groups['gnocchi_all'][0] + when: inventory_hostname == (groups['gnocchi_all'] | intersect(ansible_play_hosts))[0] tags: - gnocchi-config - import_tasks: gnocchi_ceph_python_libs.yml when: - gnocchi_storage_driver == 'ceph' + - not gnocchi_identity_only | bool tags: - gnocchi-install @@ -135,7 +136,7 @@ # Similarly, when using Ceph, must occur after Ceph setup. - import_tasks: gnocchi_db_sync.yml when: - - inventory_hostname == groups['gnocchi_all'][0] + - inventory_hostname == (groups['gnocchi_all'] | intersect(ansible_play_hosts))[0] - not gnocchi_identity_only | bool tags: - gnocchi-config