Add set_fact_persistent action and module. (#26153)

* Add 'cacheable' param to  set_fact action and module.

Used just like set_fact, except facts set with cacheable: true
will be stored in the fact cache if fact caching is enabled.

set_fact normally only sets facts in the non_persistent_fact_cache, so they
are lost between invocations.

* update set_facts docs

* use 'ansible_facts_cacheable' in module/actions result

* pop fact cacheable related items out of args/results

We dont want to use 'ansible_facts_cacheable' result item
or 'cacheable' arg as actual facts, so pop them out of the
dicts.
This commit is contained in:
Adrian Likins 2017-08-02 15:57:58 -04:00 committed by GitHub
commit 6fbd0a8bb5
8 changed files with 125 additions and 3 deletions

View file

@ -35,6 +35,9 @@ class ActionModule(ActionBase):
result = super(ActionModule, self).run(tmp, task_vars)
facts = dict()
cacheable = bool(self._task.args.pop('cacheable', False))
if self._task.args:
for (k, v) in iteritems(self._task.args):
k = self._templar.template(k)
@ -51,4 +54,5 @@ class ActionModule(ActionBase):
result['changed'] = False
result['ansible_facts'] = facts
result['ansible_facts_cacheable'] = cacheable
return result