Debian Codegraph @

test/integration/targets/module_defaults/test_defaults.yml

raw
1 - hosts: localhost
2 gather_facts: no
3 collections:
4 - testns.testcoll
5 - testns.othercoll
6 module_defaults:
7 testns.testcoll.echoaction:
8 explicit_module_default: from playbook
9 testns.testcoll.echo1:
10 explicit_module_default: from playbook
11 group/testgroup:
12 group_module_default: from playbook
13 tasks:
14 - testns.testcoll.echoaction:
15 task_arg: from task
16 register: echoaction_fq
17 - echoaction:
18 task_arg: from task
19 register: echoaction_unq
20 - testns.testcoll.echo1:
21 task_arg: from task
22 register: echo1_fq
23 - echo1:
24 task_arg: from task
25 register: echo1_unq
26 - testns.testcoll.echo2:
27 task_arg: from task
28 register: echo2_fq
29 - echo2:
30 task_arg: from task
31 register: echo2_unq
32 - testns.othercoll.other_echoaction:
33 task_arg: from task
34 register: other_echoaction_fq
35 - other_echoaction:
36 task_arg: from task
37 register: other_echoaction_unq
38 - testns.othercoll.other_echo1:
39 task_arg: from task
40 register: other_echo1_fq
41 - other_echo1:
42 task_arg: from task
43 register: other_echo1_unq
44
45 - legacy_ping:
46 register: legacy_ping_1
47 module_defaults:
48 legacy_ping:
49 data: from task
50
51 - legacy_ping:
52 register: legacy_ping_2
53 module_defaults:
54 ansible.legacy.legacy_ping:
55 data: from task
56
57 - ansible.legacy.legacy_ping:
58 register: legacy_ping_3
59 module_defaults:
60 legacy_ping:
61 data: from task
62
63 - ansible.legacy.legacy_ping:
64 register: legacy_ping_4
65 module_defaults:
66 ansible.legacy.legacy_ping:
67 data: from task
68
69 - name: builtin uses legacy defaults
70 ansible.builtin.debug:
71 module_defaults:
72 debug:
73 msg: legacy default
74 register: builtin_legacy_defaults_1
75
76 - name: builtin uses legacy defaults
77 ansible.builtin.debug:
78 module_defaults:
79 ansible.legacy.debug:
80 msg: legacy default
81 register: builtin_legacy_defaults_2
82
83 - name: legacy does not use builtin defaults
84 ansible.legacy.debug:
85 register: legacy_builtin_defaults
86 module_defaults:
87 ansible.builtin.debug:
88 msg: legacy default
89
90 - assert:
91 that:
92 - "echoaction_fq.args_in == {'task_arg': 'from task', 'explicit_module_default': 'from playbook', 'group_module_default': 'from playbook' }"
93 - "echoaction_unq.args_in == {'task_arg': 'from task', 'explicit_module_default': 'from playbook', 'group_module_default': 'from playbook' }"
94 - "echo1_fq.args_in == {'task_arg': 'from task', 'explicit_module_default': 'from playbook', 'group_module_default': 'from playbook' }"
95 - "echo1_unq.args_in == {'task_arg': 'from task', 'explicit_module_default': 'from playbook', 'group_module_default': 'from playbook' }"
96 - "echo2_fq.args_in == {'task_arg': 'from task', 'group_module_default': 'from playbook' }"
97 - "echo2_unq.args_in == {'task_arg': 'from task', 'group_module_default': 'from playbook' }"
98 - "other_echoaction_fq.args_in == {'task_arg': 'from task', 'group_module_default': 'from playbook' }"
99 - "other_echoaction_unq.args_in == {'task_arg': 'from task', 'group_module_default': 'from playbook' }"
100 - "other_echo1_fq.args_in == {'task_arg': 'from task', 'group_module_default': 'from playbook' }"
101 - "other_echo1_unq.args_in == {'task_arg': 'from task', 'group_module_default': 'from playbook' }"
102 - "legacy_ping_1.ping == 'from task'"
103 - "legacy_ping_2.ping == 'from task'"
104 - "legacy_ping_3.ping == 'from task'"
105 - "legacy_ping_4.ping == 'from task'"
106 - "legacy_builtin_defaults.msg == 'Hello overridden world!'"
107 - "builtin_legacy_defaults_1.msg == 'legacy default'"
108 - "builtin_legacy_defaults_2.msg == 'legacy default'"
109
110 - include_tasks: tasks/main.yml
111
112 - name: test preferring module name defaults for platform-specific actions
113 hosts: localhost
114 gather_facts: no
115 tasks:
116 - name: ensure eosfacts does not use action plugin default
117 testns.testcoll.eosfacts:
118 module_defaults:
119 testns.testcoll.eos:
120 fail: true
121
122 - name: eosfacts does use module name defaults
123 testns.testcoll.eosfacts:
124 module_defaults:
125 testns.testcoll.eosfacts:
126 eosfacts: true
127 register: result
128
129 - assert:
130 that:
131 - result.eosfacts
132 - result.action_plugin == 'eos'
133
134 - name: ensure vyosfacts does not use action plugin default
135 testns.testcoll.vyosfacts:
136 module_defaults:
137 testns.testcoll.vyos:
138 fail: true
139
140 - name: vyosfacts does use vyosfacts defaults
141 testns.testcoll.vyosfacts:
142 module_defaults:
143 testns.testcoll.vyosfacts:
144 vyosfacts: true
145 register: result
146
147 - assert:
148 that:
149 - result.vyosfacts
150 - result.action_plugin == 'vyos'
151
152 - name: iosfacts/ios_facts does not use action plugin default (module action_plugin field has precedence over module-as-action-redirect)
153 collections:
154 - testns.testcoll
155 module_defaults:
156 testns.testcoll.ios:
157 fail: true
158 block:
159 - ios_facts:
160 register: result
161 - assert:
162 that:
163 - result.action_plugin == 'ios'
164
165 - iosfacts:
166 register: result
167 - assert:
168 that:
169 - result.action_plugin == 'ios'
170
171 - name: ensure iosfacts/ios_facts uses ios_facts defaults
172 collections:
173 - testns.testcoll
174 module_defaults:
175 testns.testcoll.ios_facts:
176 ios_facts: true
177 block:
178 - ios_facts:
179 register: result
180 - assert:
181 that:
182 - result.ios_facts
183 - result.action_plugin == 'ios'
184
185 - iosfacts:
186 register: result
187 - assert:
188 that:
189 - result.ios_facts
190 - result.action_plugin == 'ios'
191
192 - name: ensure iosfacts/ios_facts uses iosfacts defaults
193 collections:
194 - testns.testcoll
195 module_defaults:
196 testns.testcoll.iosfacts:
197 ios_facts: true
198 block:
199 - ios_facts:
200 register: result
201 - assert:
202 that:
203 - result.ios_facts
204 - result.action_plugin == 'ios'
205
206 - iosfacts:
207 register: result
208 - assert:
209 that:
210 - result.ios_facts
211 - result.action_plugin == 'ios'
212
213 - name: ensure redirected action gets redirected action defaults
214 testns.testcoll.module_uses_action_defaults:
215 module_defaults:
216 testns.testcoll.module_uses_action_defaults:
217 action_option: true
218 register: result
219
220 - assert:
221 that:
222 - result.action_option
223 - result.action_plugin == 'eos'
224
225 - name: ensure redirected action gets resolved action defaults
226 testns.testcoll.module_uses_action_defaults:
227 module_defaults:
228 testns.testcoll.eos:
229 action_option: true
230 register: result
231
232 - assert:
233 that:
234 - result.action_option
235 - result.action_plugin == 'eos'
236
237 - name: ensure redirected action does not use module-specific defaults
238 testns.testcoll.module_uses_action_defaults:
239 module_defaults:
240 testns.testcoll.module:
241 fail: true
242 register: result
243
244 - assert:
245 that:
246 - not result.action_option
247 - result.action_plugin == 'eos'