Interview Prep/Ansible/Project Structure and Design

How do you structure inventories for dev, stage and prod?

BeginnerProductionProject Structure and Design
Answer

One inventory directory per environment, each with its own group_vars/ and host_vars/, sharing the same playbooks and roles. Environment-neutral values go in group_vars/all, environment values in the environment's directory.

ansible-playbook playbooks/site.yml -i inventories/stage/
ansible-playbook playbooks/site.yml -i inventories/prod/ --limit web

This makes it obvious which environment a command targets and keeps prod secrets (separate vault) out of dev's reach.

All Ansible questions Roadmap: Ansible

More on Project Structure and Design