set_fact: handle 'cacheable=value' form (#34871)
* Ensure fact isn't cached when cacheable=val form is used * Don't cache fact when cacheable=val form is used
This commit is contained in:
parent
b107e397cb
commit
64e1593243
3 changed files with 22 additions and 1 deletions
|
@ -36,7 +36,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
facts = dict()
|
||||
|
||||
cacheable = bool(self._task.args.pop('cacheable', False))
|
||||
cacheable = boolean(self._task.args.pop('cacheable', False))
|
||||
|
||||
if self._task.args:
|
||||
for (k, v) in iteritems(self._task.args):
|
||||
|
|
|
@ -33,6 +33,18 @@
|
|||
that:
|
||||
- ansible_foobar_not_cached == 'this_should_not_be_cached'
|
||||
|
||||
- name: set another non persistent fact that will not be cached
|
||||
set_fact: "cacheable=no fact_not_cached='this_should_not_be_cached!'"
|
||||
|
||||
- name: show fact_not_cached fact after being set
|
||||
debug:
|
||||
var: fact_not_cached
|
||||
|
||||
- name: assert fact_not_cached is correct value
|
||||
assert:
|
||||
that:
|
||||
- fact_not_cached == 'this_should_not_be_cached!'
|
||||
|
||||
- name: the second play
|
||||
hosts: localhost
|
||||
tasks:
|
||||
|
|
|
@ -19,3 +19,12 @@
|
|||
assert:
|
||||
that:
|
||||
- ansible_foobar_not_cached is undefined
|
||||
|
||||
- name: show fact_not_cached fact
|
||||
debug:
|
||||
var: fact_not_cached
|
||||
|
||||
- name: assert fact_not_cached is not cached
|
||||
assert:
|
||||
that:
|
||||
- fact_not_cached is undefined
|
||||
|
|
Loading…
Reference in a new issue