Debian Codegraph @

test/integration/targets/hash/test_inventory_hash.yml

raw
1 ---
2 - hosts: localhost
3 gather_facts: no
4 vars:
5 host_hash_merged: {'host_var1': 'inventory 2', 'host_var2': 'inventory 1'}
6 host_hash_replaced: {'host_var1': 'inventory 2'}
7 group_hash_merged: {'group_var1': 'inventory 2', 'group_var2': 'inventory 1'}
8 group_hash_replaced: {'group_var1': 'inventory 2'}
9 tasks:
10
11 - name: debug hash behaviour result
12 debug:
13 var: lookup('env', 'ANSIBLE_HASH_BEHAVIOUR')
14 verbosity: 2
15
16 - name: assert hash behaviour is merge or replace
17 assert:
18 that:
19 - lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') in ('merge', 'replace')
20
21 - name: debug test_inventory_host_hash
22 debug:
23 var: hostvars['host1']['test_inventory_host_hash']
24 verbosity: 2
25
26 - name: debug test_inventory_group_hash
27 debug:
28 var: test_inventory_group_hash
29 verbosity: 2
30
31 - assert:
32 that:
33 - hostvars['host1']['test_inventory_host_hash'] == host_hash_replaced
34 - test_inventory_group_hash == group_hash_replaced
35 when: "lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') == 'replace'"
36
37 - assert:
38 that:
39 - hostvars['host1']['test_inventory_host_hash'] == host_hash_merged
40 - test_inventory_group_hash == group_hash_merged
41 when: "lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') == 'merge'"