Ansible interview question

How do you structure reusable Ansible roles for several environments?

How you'd do it Asked in DevOps Engineer interviews

Members can save this page, take notes and track progress. See membership · Sign in

Summary

Put everything that varies by environment into variables, give each role safe defaults in defaults/main.yml, and keep environment values in separate inventories (inventories/dev, inventories/prod) with their own group_vars. The role code is identical everywhere; only the inventory changes.

Keep reading with a membership

The full answer with examples, key points and comparisons is part of the membership, along with every other interview answer, progress tracking and Daily Review. Most-asked answers stay free to read.

See plans and free trial Already a member? Sign in

More Ansible questions

← All Ansible questions

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake