Ansible inventory

Full docs

Directory structure

hosts
group_vars/[group_name]/vars
group_vars/[group_name]/vault
host_vars/[host_name]/vars
host_vars/[host_name]/vault

Hosts file

Lists all host and the groups they belong to. There is two default groups that always exists all and ungrouped. A host can be added to many groups and groups can be added to other groups as long as there are no loops.

It works with both FQDN (host1.example.com) and only the hostname (host1) if you have your search path set up correctly.

ungrouped:
  hosts:
    host4
webservers:
  hosts:
    host[1:3].example.com

Variables

Variables shared by all members of a group go into group_vars/[group_name]/vars.

Variables unique for a host goes into host_vars/[host_name]/vars.

Secrets

Managed by ansible vault. Secrets shared by all members of a group go into group_vars/[group_name]/vault

Secrets unique for a host goes into host_vars/[host_name]/vault.