Stale Host Facts with JSONFILE Cache: When Does Ansible Refresh?
0 reputation · 23 Aug 2020, 11:32 UTC
Stale Host Facts with JSONFILE Cache
When fact_caching=jsonfile and gathering=smart are enabled, Ansible writes gathered facts to a JSON file and skips the setup module on subsequent runs. If a remote system changes a fact value after the cache is written, the playbook continues to see the old value until the cache is cleared or the timeout expires.
This behavior raises an unresolved question: does the JSONFILE cache plugin provide any mechanism to detect and invalidate stale facts automatically when the underlying system changes? Operators currently must manually clear the cache directory or rely on a fixed timeout, which may not align with production change‑management workflows.
Key uncertainties include:
- Is there a configuration option that triggers cache refresh on remote fact changes?
- How do
gather_subsetorgather_filterinteract with cache staleness detection? - Does the plugin support event‑driven invalidation (e.g., via inventory hooks) in newer Ansible releases?