1--- 2- hosts: facthost1 3 gather_facts: no 4 tasks: 5 - name: check that smart gathering is enabled 6 fail: 7 msg: 'smart gathering must be enabled' 8 when: 'lookup("env", "ANSIBLE_GATHERING") != "smart"' 9 - name: install test local facts 10 copy: 11 src: uuid.fact 12 dest: /usr/local/etc/ansible/facts.d/ 13 mode: 0755 14 15- hosts: facthost1,facthost2 16 gather_facts: yes 17 run_once: yes 18 tasks: 19 - block: 20 - name: 'Check the same host is used' 21 assert: 22 that: 'hostvars.facthost1.ansible_fqdn == hostvars.facthost2.ansible_fqdn' 23 msg: 'This test requires 2 inventory hosts referring to the same host.' 24 - name: "Check that run_once doesn't prevent fact gathering (#39453)" 25 assert: 26 that: 'hostvars.facthost1.ansible_local.uuid != hostvars.facthost2.ansible_local.uuid' 27 msg: "{{ 'Same value for ansible_local.uuid on both hosts: ' ~ hostvars.facthost1.ansible_local.uuid }}" 28 always: 29 - name: remove test local facts 30 file: 31 path: /usr/local/etc/ansible/facts.d/uuid.fact 32 state: absent 33