blob: 6ea08f72d899c77d30d6c26d9fbc60dcf4a7c66b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
- hosts: testhost,testhost2
gather_facts: false
vars:
delegate_to_host: "localhost"
tasks:
- set_fact:
gandalf:
shout: 'You shall not pass!'
when: inventory_hostname == 'testhost'
- set_fact:
gandalf:
speak: 'Run you fools!'
when: inventory_hostname == 'testhost2'
- name: works correctly
debug: var=item
delegate_to: localhost
with_dict: "{{ gandalf }}"
register: result1
- name: shows same item for all hosts
debug: var=item
delegate_to: "{{ delegate_to_host }}"
with_dict: "{{ gandalf }}"
register: result2
- debug:
var: result2.results[0].item.value
- assert:
that:
- result1.results[0].item.value == 'You shall not pass!'
- result2.results[0].item.value == 'You shall not pass!'
when: inventory_hostname == 'testhost'
- assert:
that:
- result1.results[0].item.value == 'Run you fools!'
- result2.results[0].item.value == 'Run you fools!'
when: inventory_hostname == 'testhost2'
- assert:
that:
- _ansible_loop_cache is undefined
|