summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/delegate_to/delegate_facts_loop.yml
diff options
context:
space:
mode:
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'] }}"