DevOps / Ansible Interview questions
What are the types of variables in Ansible?
Ansible pulls variables from many possible sources, each with a different scope and precedence.
| Source | Typical use |
Role defaults (defaults/main.yml) | Lowest-precedence, overridable fallback values. |
| Inventory / group_vars / host_vars | Environment- or host-specific settings. |
| Play vars / vars_files | Values scoped to a specific playbook run. |
Registered variables (register) | Output captured from a previous task. |
| Facts | Auto-discovered host information. |
Extra vars (-e on the command line) | Highest-precedence, runtime overrides. |
Understanding which source wins matters because the same variable name can be set in several places at once; Ansible resolves this through a well-defined precedence order rather than "last one wins" by file position alone.
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...
