Debian Codegraph @

test/integration/targets/meta_tasks/refresh_preserve_dynamic.yml

raw
1 - hosts: all
2 gather_facts: false
3 tasks:
4 - name: check initial state
5 assert:
6 that:
7 - "'one' in ansible_play_hosts"
8 - "'two' in ansible_play_hosts"
9 - "'three' in ansible_play_hosts"
10 - "'four' not in ansible_play_hosts"
11 run_once: true
12
13 - name: add a host
14 add_host:
15 name: yolo
16 parity: null
17
18 - name: group em
19 group_by:
20 key: '{{parity}}'
21
22 - hosts: all
23 gather_facts: false
24 tasks:
25 - name: test and ensure we restore symlink
26 run_once: true
27 block:
28 - name: check added host state
29 assert:
30 that:
31 - "'yolo' in ansible_play_hosts"
32 - "'even' in groups"
33 - "'odd' in groups"
34 - "'two' in groups['even']"
35 - "'three' in groups['odd']"
36
37 - name: change symlink
38 file: src=./inventory_new.yml dest=./inventory_refresh.yml state=link force=yes follow=false
39 delegate_to: localhost
40
41 - name: refresh the inventory to new source
42 meta: refresh_inventory
43
44 always:
45 - name: revert symlink, invenotry was already reread or failed
46 file: src=./inventory_old.yml dest=./inventory_refresh.yml state=link force=yes follow=false
47 delegate_to: localhost
48
49 - hosts: all
50 gather_facts: false
51 tasks:
52 - name: check refreshed state
53 assert:
54 that:
55 - "'one' not in ansible_play_hosts"
56 - "'two' in ansible_play_hosts"
57 - "'three' in ansible_play_hosts"
58 - "'four' in ansible_play_hosts"
59 run_once: true
60
61 - name: check added host state
62 assert:
63 that:
64 - "'yolo' in ansible_play_hosts"
65 - "'even' in groups"
66 - "'odd' in groups"
67 - "'two' in groups['even']"
68 - "'three' in groups['odd']"
69 run_once: true