What are `group_vars` and `host_vars` directories?

IntermediateConceptInventory
Answer

Directories placed next to the inventory file (or the playbook) that hold variables by group or host name, instead of cluttering the inventory.

inventory/
  hosts.ini
  group_vars/
    all.yml
    web.yml
    db/
      main.yml
      secrets.yml   # vault-encrypted
  host_vars/
    web1.yml

A group can use either web.yml or a web/ directory whose files are all loaded. Splitting a vaulted secrets.yml from plain main.yml keeps diffs readable.

All Ansible questions Roadmap: Ansible

More on Inventory