Debian Codegraph @

test/integration/targets/include_import/run_once/playbook.yml

raw
1 # This playbook exists to document the behavior of how run_once when
2 # applied to a dynamic include works
3 #
4 # As with other uses of keywords on dynamic includes, it only affects the include.
5 # In this case it causes the include to only be processed for ansible_play_hosts[0]
6 # which has the side effect of only running the tasks on ansible_play_hosts[0]
7 # and would only delegate facts of the include itself, not the tasks contained within
8
9 - hosts: localhost
10 gather_facts: false
11 tasks:
12 - add_host:
13 name: "{{ item }}"
14 ansible_connection: local
15 groups:
16 - all
17 loop:
18 - localhost0
19 - localhost1
20
21 - add_host:
22 name: "{{ item }}"
23 groups:
24 - testing
25 ansible_connection: local
26 loop:
27 - localhost2
28 - localhost3
29
30 - hosts: all:!testing
31 gather_facts: false
32 vars:
33 lola: untouched
34 tasks:
35 - include_tasks:
36 file: include_me.yml
37 apply:
38 run_once: true
39 run_once: true
40
41 - assert:
42 that:
43 - lola == 'wiseman'
44
45 - hosts: testing
46 gather_facts: false
47 vars:
48 lola: untouched
49 tasks:
50 - include_tasks: include_me.yml
51 run_once: true
52
53 - assert:
54 that:
55 - lola == 'wiseman'
56 when: inventory_hostname == ansible_play_hosts[0]
57
58 - assert:
59 that:
60 - lola == 'untouched'
61 when: inventory_hostname != ansible_play_hosts[0]