mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-21 15:50:22 -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
|
@ -33,11 +33,19 @@ options:
|
|||
using the C(args:) statement.
|
||||
required: true
|
||||
default: null
|
||||
cacheable:
|
||||
description:
|
||||
- This boolean indicates if the facts set will also be added to the
|
||||
fact cache, if fact caching is enabled.
|
||||
required: false
|
||||
default: false
|
||||
version_added: "2.4"
|
||||
version_added: "1.2"
|
||||
notes:
|
||||
- "The `var=value` notation can only create strings or booleans.
|
||||
If you want to create lists/arrays or dictionary/hashes use `var: [val1, val2]`"
|
||||
- This module is also supported for Windows targets.
|
||||
- Since 'cacheable' is now a module param, 'cacheable' is no longer a valid fact name as of 2.4.
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
@ -50,6 +58,12 @@ EXAMPLES = '''
|
|||
other_fact: "{{ local_var * 2 }}"
|
||||
another_fact: "{{ some_registered_var.results | map(attribute='ansible_facts.some_fact') | list }}"
|
||||
|
||||
# Example setting facts so that they will be persisted in the fact cache
|
||||
- set_fact:
|
||||
one_fact: something
|
||||
other_fact: "{{ local_var * 2 }}"
|
||||
cacheable: true
|
||||
|
||||
# As of 1.8, Ansible will convert boolean strings ('true', 'false', 'yes', 'no')
|
||||
# to proper boolean values when using the key=value syntax, however it is still
|
||||
# recommended that booleans be set using the complex argument style:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue