Interview Prep/Ansible/Project Structure and Design

How do you design inventory groups?

AdvancedProductionProject Structure and Design
Answer

Think of groups on three independent axes and combine them with intersections, instead of one deep tree:

  • function: web, db, cache
  • environment: env_prod, env_stage
  • location: region_ap_south_1, az_a

A play targets hosts: web:&env_prod. In a cloud, derive groups from tags with keyed_groups, so groups can never go stale. Variables go in the group they describe (function settings on web, endpoints on env_prod). Avoid defining the same variable on two sibling groups, because the alphabetical merge order will bite you.

All Ansible questions Roadmap: Ansible

More on Project Structure and Design