]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
site: delegate fact to all the hosts
authorSébastien Han <seb@redhat.com>
Thu, 24 Aug 2017 07:28:22 +0000 (09:28 +0200)
committerSébastien Han <seb@redhat.com>
Thu, 24 Aug 2017 09:33:07 +0000 (11:33 +0200)
Before this patch we couldn't use --limit properly to only interact with
a particular set of hosts. We basically always required to have ceph-mon
role being played to properly get facts and then build the ceph.conf.

Now, the current running host will get the facts from the machines that
are not part of the current play. This is achieved with the help of the
new option delegate_facts, for more info see:
http://docs.ansible.com/ansible/latest/playbooks_delegation.html#delegated-facts

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1482067
Signed-off-by: Sébastien Han <seb@redhat.com>
site.yml.sample

index de833be904ce2d2e5ed4d6c624410e5550de9190..f32621250774fec74152f70603d327872af43547 100644 (file)
   - rbdmirrors
   - clients
   - mgrs
+
   gather_facts: false
+
   tags:
     - always
+
   tasks:
     # If we can't get python2 installed before any module is used we will fail
     # so just try what we can to get it installed
         path: /usr/bin/python
       ignore_errors: yes
       register: systempython2
-    - name: install python2 for Debian based systems
+
+    - name: install python2 for debian based systems
       raw: sudo apt-get -y install python-simplejson
       ignore_errors: yes
-      when: systempython2.stat.exists is undefined or systempython2.stat.exists == false
-    # Try to install python2 on Fedora > 23
-    - name: install python2 for Fedora
+      when:
+        - systempython2.stat.exists is undefined or systempython2.stat.exists == false
+
+    - name: install python2 for fedora
       raw: sudo dnf -y install python creates=/usr/bin/python
       ignore_errors: yes
-      when: systempython2.stat.exists is undefined or systempython2.stat.exists == false
-    - name: gathering facts
+      when:
+        - systempython2.stat.exists is undefined or systempython2.stat.exists == false
+
+    - name: gather and delegate facts
       setup:
-    - name: install required packages for Fedora > 23
+      delegate_to: "{{ item }}"
+      delegate_facts: True
+      with_items: "{{ groups['all'] }}"
+
+    - name: install required packages for fedora > 23
       raw: sudo dnf -y install python2-dnf libselinux-python ntp
-      when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int >= 23
+      when:
+        - ansible_distribution == 'Fedora'
+        - ansible_distribution_major_version|int >= 23
 
 - hosts: mons
   gather_facts: false