DevOps / Ansible Interview questions
How do you troubleshoot slow fact gathering in Ansible?
- Time the gather_facts step specifically using
-vvvor the profile_tasks callback to confirm it's actually the bottleneck versus other tasks. - Disable gathering for plays that don't need facts (
gather_facts: false), which is often the single biggest win if facts aren't actually used. - Narrow gathered subsets with
gather_subsetto skip expensive categories (like all network interfaces) when only a few specific facts are needed. - Enable fact caching so repeated runs within the cache's expiration window skip live gathering entirely and reuse the last known values.
- Check for slow or high-latency hosts specifically - a handful of consistently slow hosts (not the whole inventory) often points to a host-level issue, like DNS resolution delays during setup, rather than an Ansible-wide problem.
- hosts: all gather_facts: true vars: ansible_facts_modules: setup tasks: - name: Only gather what's needed ansible.builtin.setup: gather_subset: - network
Fact gathering is one of the more overlooked sources of playbook slowness precisely because it's implicit - it's worth explicitly timing it before assuming a slow run is due to the playbook's own task logic.
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...
