mon: fix with_items being evaluated before when

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 <seb@redhat.com>
pull/1428/head
Sébastien Han 2017-04-11 12:10:55 +02:00
parent 186a392656
commit 05331a2634
1 changed files with 1 additions and 1 deletions

View File

@ -13,7 +13,7 @@
- name: add mgr keys to config and keys paths - name: add mgr keys to config and keys paths
set_fact: set_fact:
tmp_ceph_mgr_keys: /etc/ceph/{{ cluster }}.mgr.{{ hostvars[item]['ansible_hostname'] }}.keyring 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 register: tmp_ceph_mgr_keys_result
when: "{{ groups.get(mgr_group_name, []) | length > 0 }}" when: "{{ groups.get(mgr_group_name, []) | length > 0 }}"