6fbd0a8bb5
* 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.
46 lines
1.1 KiB
YAML
46 lines
1.1 KiB
YAML
---
|
|
- name: the first play
|
|
hosts: localhost
|
|
tasks:
|
|
- name: show foobar fact before
|
|
debug:
|
|
var: ansible_foobar
|
|
|
|
- name: set a persistent fact foobar
|
|
set_fact:
|
|
ansible_foobar: 'blippy'
|
|
cacheable: true
|
|
|
|
- name: show foobar fact after
|
|
debug:
|
|
var: ansible_foobar
|
|
|
|
- name: assert ansible_foobar is correct value
|
|
assert:
|
|
that:
|
|
- ansible_foobar == 'blippy'
|
|
|
|
- name: set a non persistent fact that will not be cached
|
|
set_fact:
|
|
ansible_foobar_not_cached: 'this_should_not_be_cached'
|
|
|
|
- name: show ansible_foobar_not_cached fact after being set
|
|
debug:
|
|
var: ansible_foobar_not_cached
|
|
|
|
- name: assert ansible_foobar_not_cached is correct value
|
|
assert:
|
|
that:
|
|
- ansible_foobar_not_cached == 'this_should_not_be_cached'
|
|
|
|
- name: the second play
|
|
hosts: localhost
|
|
tasks:
|
|
- name: show foobar fact after second play
|
|
debug:
|
|
var: ansible_foobar
|
|
|
|
- name: assert ansible_foobar is correct value
|
|
assert:
|
|
that:
|
|
- ansible_foobar == 'blippy'
|