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
pull/26105/head
Pilou 7 years ago committed by Matt Martz
parent b107e397cb
commit 64e1593243

@ -36,7 +36,7 @@ class ActionModule(ActionBase):
facts = dict() facts = dict()
cacheable = bool(self._task.args.pop('cacheable', False)) cacheable = boolean(self._task.args.pop('cacheable', False))
if self._task.args: if self._task.args:
for (k, v) in iteritems(self._task.args): for (k, v) in iteritems(self._task.args):

@ -33,6 +33,18 @@
that: that:
- ansible_foobar_not_cached == 'this_should_not_be_cached' - 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 - name: the second play
hosts: localhost hosts: localhost
tasks: tasks:

@ -19,3 +19,12 @@
assert: assert:
that: that:
- ansible_foobar_not_cached is undefined - 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…
Cancel
Save