mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-05 16:04:09 -07:00
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:
parent
3476b005b9
commit
6fbd0a8bb5
8 changed files with 125 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue