2018-05-04 21:33:32 +02:00
|
|
|
|
---
|
|
|
|
|
- hosts: facthost1
|
|
|
|
|
gather_facts: no
|
|
|
|
|
tasks:
|
2018-08-23 17:36:06 +02:00
|
|
|
|
- name: check that smart gathering is enabled
|
|
|
|
|
fail:
|
|
|
|
|
msg: 'smart gathering must be enabled'
|
|
|
|
|
when: 'lookup("env", "ANSIBLE_GATHERING") != "smart"'
|
2018-05-04 21:33:32 +02:00
|
|
|
|
- name: install test local facts
|
|
|
|
|
copy:
|
|
|
|
|
src: uuid.fact
|
|
|
|
|
dest: /etc/ansible/facts.d/
|
|
|
|
|
mode: 0755
|
|
|
|
|
|
|
|
|
|
- hosts: facthost1,facthost2
|
|
|
|
|
gather_facts: yes
|
|
|
|
|
run_once: yes
|
|
|
|
|
tasks:
|
|
|
|
|
- block:
|
2018-08-23 17:36:06 +02:00
|
|
|
|
- name: 'Check the same host is used'
|
|
|
|
|
assert:
|
|
|
|
|
that: 'hostvars.facthost1.ansible_fqdn == hostvars.facthost2.ansible_fqdn'
|
|
|
|
|
msg: 'This test requires 2 inventory hosts referring to the same host.'
|
|
|
|
|
- name: "Check that run_once doesn't prevent fact gathering (#39453)"
|
|
|
|
|
assert:
|
|
|
|
|
that: 'hostvars.facthost1.ansible_local.uuid != hostvars.facthost2.ansible_local.uuid'
|
|
|
|
|
msg: "{{ 'Same value for ansible_local.uuid on both hosts: ' ~ hostvars.facthost1.ansible_local.uuid }}"
|
2018-05-04 21:33:32 +02:00
|
|
|
|
always:
|
|
|
|
|
- name: remove test local facts
|
|
|
|
|
file:
|
|
|
|
|
path: /etc/ansible/facts.d/uuid.fact
|
|
|
|
|
state: absent
|