]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
add-osd: gather facts in second part of playbook
authorGuillaume Abrioux <gabrioux@redhat.com>
Mon, 4 Mar 2019 08:23:00 +0000 (09:23 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Mon, 4 Mar 2019 13:44:27 +0000 (14:44 +0100)
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 <gabrioux@redhat.com>
infrastructure-playbooks/add-osd.yml

index 393e6e6f786ef4ad45c1c64cd04f2927f002f4d1..467c0358a64de4a43aadabcb9df49a837cd433a9 100644 (file)
   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: