I want to speed-up ansible playbook execution by avoiding to call some sections that do not have to be called more often than once a day or so.
I know that facts are supposed to allow us to implement this but it seems almost impossible to find some basic example of: setting a fact, reading it and doing something if this it has a specific value, setting a default value for a fact.
- name: "do system update"
shell: echo "did it!"
- set_fact:
os_is_updated: true
If my impression or facts are nothing else than variables that can be saved, loaded and caches between executions?
Let's assume hat ansible.cfg
is already configured to enable fact caching for two hours.
[defaults]
gathering = smart
fact_caching = jsonfile
fact_caching_timeout = 7200
fact_caching_connection = /tmp/facts_cache