summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/delegate_to/delegate_facts_loop.yml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 16:04:21 +0000
commit8a754e0858d922e955e71b253c139e071ecec432 (patch)
tree527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/delegate_to/delegate_facts_loop.yml
parentInitial commit. (diff)
downloadansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz
ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/delegate_to/delegate_facts_loop.yml')
-rw-r--r--test/integration/targets/delegate_to/delegate_facts_loop.yml40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/integration/targets/delegate_to/delegate_facts_loop.yml b/test/integration/targets/delegate_to/delegate_facts_loop.yml
new file mode 100644
index 0000000..b05c406
--- /dev/null
+++ b/test/integration/targets/delegate_to/delegate_facts_loop.yml
@@ -0,0 +1,40 @@
+- hosts: localhost
+ gather_facts: no
+ tasks:
+ - set_fact:
+ test: 123
+ delegate_to: "{{ item }}"
+ delegate_facts: true
+ loop: "{{ groups['all'] | difference(['localhost']) }}"
+
+ - name: ensure we didnt create it on current host
+ assert:
+ that:
+ - test is undefined
+
+ - name: ensure facts get created
+ assert:
+ that:
+ - "'test' in hostvars[item]"
+ - hostvars[item]['test'] == 123
+ loop: "{{ groups['all'] | difference(['localhost'])}}"
+
+
+- name: test that we don't polute whole group with one value
+ hosts: localhost
+ gather_facts: no
+ vars:
+ cluster_name: bleh
+ tasks:
+ - name: construct different fact per host in loop
+ set_fact:
+ vm_name: "{{ cluster_name }}-{{item}}"
+ delegate_to: "{{ item }}"
+ delegate_facts: True
+ with_items: "{{ groups['all'] }}"
+
+ - name: ensure the fact is personalized for each host
+ assert:
+ that:
+ - hostvars[item]['vm_name'].endswith(item)
+ loop: "{{ groups['all'] }}"