Ansible fact_caching_timeout and granular cache invalidation
0 reputation · 23 May 2020, 05:17 UTC
Ansible's fact caching mechanism allows system information to be stored in backends such as Redis or JSON files to optimize playbook execution. When gather_facts is set to smart, the engine relies on the fact_caching_timeout setting to determine if the stored data is still valid.
While the global timeout manages the expiration of the entire host cache, there is a requirement to handle scenarios where specific system attributes change more frequently than others. Currently, the system does not provide a native method to mark a single fact as stale without invalidating the entire cached dataset for that host.
Given the behavior of the smart gathering directive in Ansible 2.15+, how can specific facts be forced to refresh while retaining the rest of the cached system information? Is there a configuration to implement per-fact expiration logic?