DevOps / Ansible Interview questions
What is the difference between include and import in Ansible?
| import_* (static) | include_* (dynamic) |
| Processed at playbook parse time, before the run starts. | Processed at runtime, as the play executes. |
| Tags and conditionals apply to every task inside up front. | Can use variables/loops to decide what to include on the fly. |
| Can't use a variable that's only known at runtime for the file path. | Can use runtime variables in the included file's path. |
| Slightly more predictable and easier to reason about statically. | More flexible for conditional or looped inclusion. |
Use import_tasks/import_playbook when the structure is fixed and known ahead of time, since static processing lets tools like --list-tasks show the full task list without running anything. Use include_tasks/include_role when the set of tasks to run genuinely depends on a runtime condition or needs to loop over a dynamic list, since only dynamic inclusion can evaluate that condition as the play unfolds rather than upfront.
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...
