Interview Prep/Ansible/Project Structure and Design

How do you keep variables from turning into an unmanageable mess?

AdvancedProductionProject Structure and Design
Answer
  • Few places: role defaults for tunables, group_vars per environment, host_vars as rare exceptions.
  • Avoid vars/main.yml for things users might change, and avoid set_fact for values that should stay overridable.
  • Never rely on extra vars in normal operation.
  • Prefix names and validate with argument_specs.
  • Use ansible-inventory --host <name> and -vvv to see the final merged values.

Treat precedence bugs as a design smell: if you need a table to explain where a value comes from, simplify the layout.

All Ansible questions Roadmap: Ansible

More on Project Structure and Design