DevOps / Ansible Interview questions
Explain the internal working of Ansible's variable precedence resolution?
Internally, Ansible builds up a variable's final value by layering every source that defines it, in a fixed precedence order, so the value that "wins" is whichever source sits highest in that order, regardless of the order files happen to be read from disk.
As Ansible processes a playbook, it maintains an internal merged variable namespace per host; each layer above simply overwrites the same key if it's also defined at a lower layer, rather than merging values together (with the notable exception of hash/dictionary merging, which can be configured via hash_behaviour, though the default is still overwrite, not merge). Because -e extra vars sit at the very top, they always win regardless of what's set anywhere else in roles, inventory, or playbooks - this is deliberate, since it gives an operator a reliable way to force a value at runtime without needing to trace through every file that might otherwise define it.
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...
