From 4dd46ec396dc3dd9bb7fb752331f44038ff9022c Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Mon, 4 Mar 2019 09:23:00 +0100 Subject: [PATCH] add-osd: gather facts in second part of playbook otherwise, it will end up with error like following: ``` FAILED! => {"msg": "'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_hostname'"} ``` because facts won't have been gathered. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1670663 Signed-off-by: Guillaume Abrioux (cherry picked from commit a4408785332512f6fab6134ee488a4cec18639c1) --- infrastructure-playbooks/add-osd.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/infrastructure-playbooks/add-osd.yml b/infrastructure-playbooks/add-osd.yml index cb02a74c0..3a9056710 100644 --- a/infrastructure-playbooks/add-osd.yml +++ b/infrastructure-playbooks/add-osd.yml @@ -50,7 +50,27 @@ gather_facts: False become: True + vars: + delegate_facts_host: True + pre_tasks: + + - name: gather facts + setup: + when: + - not delegate_facts_host | bool + + - name: gather and delegate facts + setup: + delegate_to: "{{ item }}" + delegate_facts: True + with_items: + - "{{ groups['mons'] }}" + - "{{ groups['osds'] }}" + run_once: True + when: + - delegate_facts_host | bool + # this task is needed so we can skip the openstack_config.yml include in roles/ceph-osd - name: set_fact add_osd set_fact: