From 05331a26348e162e4083131d2a259f6c983f3ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 11 Apr 2017 12:10:55 +0200 Subject: [PATCH] mon: fix with_items being evaluated before when MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ansible evaluates the 'with_items' before the 'when' so if the inventory does not have the group declared it'll fail. To fix this, we set an empty array to make the with_items happy and then evaluate with the 'when'. Signed-off-by: Sébastien Han --- roles/ceph-mon/tasks/docker/fetch_configs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/ceph-mon/tasks/docker/fetch_configs.yml b/roles/ceph-mon/tasks/docker/fetch_configs.yml index 5b8df68ff..a96f34c88 100644 --- a/roles/ceph-mon/tasks/docker/fetch_configs.yml +++ b/roles/ceph-mon/tasks/docker/fetch_configs.yml @@ -13,7 +13,7 @@ - name: add mgr keys to config and keys paths set_fact: tmp_ceph_mgr_keys: /etc/ceph/{{ cluster }}.mgr.{{ hostvars[item]['ansible_hostname'] }}.keyring - with_items: "{{ groups[mgr_group_name] }}" + with_items: "{{ groups.get(mgr_group_name, []) }}" register: tmp_ceph_mgr_keys_result when: "{{ groups.get(mgr_group_name, []) | length > 0 }}"