1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/gathering_facts/test_run_once.yml
Mickaël Guérin 8ac69b0a5f Fix gathering facts in run_once play (#39453)
* Fix gathering facts in run_once play

Fixes https://github.com/ansible/ansible/issues/39312

* Check that run_once doesn't prevent fact gathering
2018-05-04 15:33:32 -04:00

28 lines
943 B
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- hosts: facthost1
gather_facts: no
tasks:
- 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:
- 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 }}"
always:
- name: remove test local facts
file:
path: /etc/ansible/facts.d/uuid.fact
state: absent