Debian Codegraph @

test/integration/targets/var_templating/task_vars_templating.yml

raw
1 ---
2 - hosts: localhost
3 connection: local
4 gather_facts: no
5 tasks:
6 - add_host:
7 name: host1
8 ansible_connection: local
9 ansible_host: 127.0.0.1
10
11 - hosts: all
12 gather_facts: no
13 tasks:
14 - debug:
15 msg: "{{ hostvars['host1']['x'] }}"
16 register: x_1
17 - debug:
18 msg: "{{ hostvars['host1']['y'] }}"
19 register: y_1
20 - debug:
21 msg: "{{ hostvars_['x'] }}"
22 vars:
23 hostvars_: "{{ hostvars['host1'] }}"
24 register: x_2
25 - debug:
26 msg: "{{ hostvars_['y'] }}"
27 vars:
28 hostvars_: "{{ hostvars['host1'] }}"
29 register: y_2
30
31 - assert:
32 that:
33 - x_1 == x_2
34 - y_1 == y_2
35 - x_1 == y_1
36
37 - debug:
38 msg: "{{ hostvars['host1']['nested_x']['value'] }}"
39 register: x_1
40 - debug:
41 msg: "{{ hostvars['host1']['nested_y']['value'] }}"
42 register: y_1
43 - debug:
44 msg: "{{ hostvars_['nested_x']['value'] }}"
45 vars:
46 hostvars_: "{{ hostvars['host1'] }}"
47 register: x_2
48 - debug:
49 msg: "{{ hostvars_['nested_y']['value'] }}"
50 vars:
51 hostvars_: "{{ hostvars['host1'] }}"
52 register: y_2
53
54 - assert:
55 that:
56 - x_1 == x_2
57 - y_1 == y_2
58 - x_1 == y_1