4 changed files with 45 additions and 0 deletions
@ -0,0 +1,4 @@ |
|||||
|
[defaults] |
||||
|
fact_caching = jsonfile |
||||
|
fact_caching_connection = facts |
||||
|
fact_caching_timeout = 10 |
||||
@ -0,0 +1,17 @@ |
|||||
|
--- |
||||
|
|
||||
|
- name: A cacheable fact can be defined and used between invocations / playbooks |
||||
|
gather_facts: no |
||||
|
hosts: localhost |
||||
|
tasks: |
||||
|
- debug: |
||||
|
var: myfact456 |
||||
|
- set_fact: |
||||
|
myfact456: test |
||||
|
cacheable: true |
||||
|
when: myfact456 is not defined |
||||
|
- assert: |
||||
|
that: |
||||
|
- "myfact456 == 'test'" |
||||
|
- "'myfact456' in ansible_facts" |
||||
|
- "ansible_facts.myfact456 == 'test'" |
||||
@ -0,0 +1 @@ |
|||||
|
* |
||||
@ -0,0 +1,23 @@ |
|||||
|
--- |
||||
|
|
||||
|
- name: A standard fact can be defined in a playbook... |
||||
|
gather_facts: no |
||||
|
hosts: localhost |
||||
|
tasks: |
||||
|
- set_fact: |
||||
|
myfact123: test |
||||
|
- assert: |
||||
|
that: |
||||
|
# A fact is available as a standard variable |
||||
|
- "myfact123 == 'test'" |
||||
|
# But not part of the "ansible_facts" dictionary |
||||
|
- "'myfact123' not in ansible_facts" |
||||
|
|
||||
|
- name: and used in another role/playbook ! |
||||
|
gather_facts: no |
||||
|
hosts: localhost |
||||
|
tasks: |
||||
|
- assert: |
||||
|
that: |
||||
|
- "myfact123 == 'test'" |
||||
|
- "'myfact123' not in ansible_facts" |
||||
Loading…
Reference in new issue