group_vars

A directory whose files hold variables for inventory groups, one file or folder per group, named exactly after the group.

In more detail

group_vars/webservers.yml applies to every host in webservers, and group_vars/all.yml to every host. There is no registration step: the file name is the whole mechanism. Ansible looks for the directory beside the inventory and beside the playbook. A group can also have a folder, such as group_vars/all/, holding several files, for example one encrypted with Vault.

Example

group_vars/webservers.yml

Related terms

Taught in

References

Certification courses