Document and test 'is undefined' rather than 'is not defined'
According to https://github.com/ansible/ansible/issues/10273, this syntax should work better for nested dicts.
This commit is contained in:
parent
8509f22839
commit
106e942faa
2 changed files with 11 additions and 1 deletions
|
@ -90,7 +90,7 @@ If a required variable has not been set, you can skip or fail using Jinja2's
|
|||
when: foo is defined
|
||||
|
||||
- fail: msg="Bailing out. this play requires 'bar'"
|
||||
when: bar is not defined
|
||||
when: bar is undefined
|
||||
|
||||
This is especially useful in combination with the conditional import of vars
|
||||
files (see below).
|
||||
|
|
|
@ -148,6 +148,16 @@
|
|||
that:
|
||||
- "result.skipped == true"
|
||||
|
||||
- name: test bad conditional 'is undefined'
|
||||
shell: echo 'testing'
|
||||
when: test_bare is undefined
|
||||
register: result
|
||||
|
||||
- name: assert bad conditional 'is undefined' did NOT run
|
||||
assert:
|
||||
that:
|
||||
- "result.skipped == true"
|
||||
|
||||
- name: test bare conditional
|
||||
shell: echo 'testing'
|
||||
when: test_bare
|
||||
|
|
Loading…
Reference in a new issue