DevOps / Ansible Interview questions
How can you optimize playbook execution speed?
- Increase forks (
forks = 20or higher in ansible.cfg) so more hosts are processed in parallel instead of the default 5. - Disable unnecessary fact gathering (
gather_facts: false) for plays that don't need host facts. - Enable fact caching (e.g. to Redis or a JSON file) so repeated runs don't re-gather facts from scratch every time.
- Use pipelining (
pipelining = True) to reduce the number of SSH round trips per task. - Prefer the free strategy for independent hosts, so faster hosts aren't held up waiting for slower ones on every task.
- Batch related changes into fewer, well-designed modules rather than many small shell/command tasks, since built-in modules are generally more efficient than shelling out.
Most large gains come from parallelism (forks) and cutting unnecessary work (facts, redundant SSH connections) rather than from micro-optimizing individual task logic, so it's worth checking these settings before assuming a slow playbook needs a rewrite.
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...
