summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/var_templating/task_vars_templating.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/var_templating/task_vars_templating.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/var_templating/task_vars_templating.yml')
-rw-r--r--test/integration/targets/var_templating/task_vars_templating.yml58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/integration/targets/var_templating/task_vars_templating.yml b/test/integration/targets/var_templating/task_vars_templating.yml
new file mode 100644
index 0000000..88e1e60
--- /dev/null
+++ b/test/integration/targets/var_templating/task_vars_templating.yml
@@ -0,0 +1,58 @@
+---
+- hosts: localhost
+ connection: local
+ gather_facts: no
+ tasks:
+ - add_host:
+ name: host1
+ ansible_connection: local
+ ansible_host: 127.0.0.1
+
+- hosts: all
+ gather_facts: no
+ tasks:
+ - debug:
+ msg: "{{ hostvars['host1']['x'] }}"
+ register: x_1
+ - debug:
+ msg: "{{ hostvars['host1']['y'] }}"
+ register: y_1
+ - debug:
+ msg: "{{ hostvars_['x'] }}"
+ vars:
+ hostvars_: "{{ hostvars['host1'] }}"
+ register: x_2
+ - debug:
+ msg: "{{ hostvars_['y'] }}"
+ vars:
+ hostvars_: "{{ hostvars['host1'] }}"
+ register: y_2
+
+ - assert:
+ that:
+ - x_1 == x_2
+ - y_1 == y_2
+ - x_1 == y_1
+
+ - debug:
+ msg: "{{ hostvars['host1']['nested_x']['value'] }}"
+ register: x_1
+ - debug:
+ msg: "{{ hostvars['host1']['nested_y']['value'] }}"
+ register: y_1
+ - debug:
+ msg: "{{ hostvars_['nested_x']['value'] }}"
+ vars:
+ hostvars_: "{{ hostvars['host1'] }}"
+ register: x_2
+ - debug:
+ msg: "{{ hostvars_['nested_y']['value'] }}"
+ vars:
+ hostvars_: "{{ hostvars['host1'] }}"
+ register: y_2
+
+ - assert:
+ that:
+ - x_1 == x_2
+ - y_1 == y_2
+ - x_1 == y_1