DevOps / Ansible Interview questions
How does Ansible implement fact caching internally?
Fact caching stores the ansible_facts dictionary gathered for each host in an external cache backend, keyed by hostname, with a configurable time-to-live, so a future run can read cached facts instead of re-running the setup module.
# ansible.cfg [defaults] fact_caching = redis fact_caching_connection = localhost:6379:0 fact_caching_timeout = 86400
Supported backends include a simple jsonfile (facts written to local disk as JSON), redis, and other plugin-based options, chosen based on whether facts need to be shared across multiple control nodes (favoring a networked backend like Redis) or just persisted locally between runs (where jsonfile is simpler). On each play, Ansible checks whether a valid, non-expired cache entry exists for a given host; if so, it loads facts from there instead of dispatching setup, and if not (or if the entry expired past fact_caching_timeout), it gathers fresh facts and writes the result back to the cache for next time.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
