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.ymlRelated terms
- host_vars — A directory whose files hold variables for single hosts, each file named exactly as the host is spelled in the inventory.
- group — A named set of hosts in an inventory, used both to target them together and to attach variables that are true of all of them.
- variable precedence — The fixed order Ansible uses to decide which value wins when the same variable is set in several places.
- environment overlay — Keeping one shared playbook and putting the values that differ between environments in separate variable files, one per environment.
Taught in
- Host Groups And Host Variables — Ansible Configuration Management at Scale
- Connections And Privilege Escalation — Ansible Configuration Management at Scale
- Securing Data With Ansible Vault — Ansible Configuration Management at Scale
- Environment Specific Configuration — Ansible Configuration Management at Scale
- Static Inventories: Hosts, Groups And Groups Of Groups — RHCE in Ansible (EX294): Automate Red Hat Systems
- Inventory Variables: Ranges, group_vars And host_vars — RHCE in Ansible (EX294): Automate Red Hat Systems
- Variables And Where They Win: group_vars, host_vars And Play Vars — RHCE in Ansible (EX294): Automate Red Hat Systems
- ansible-navigator: The Settings File The Exam Reads — RHCE in Ansible (EX294): Automate Red Hat Systems
- Roles: The Directory Ansible Expects, Defaults And Handlers — RHCE in Ansible (EX294): Automate Red Hat Systems
- RHEL System Roles: timesync And selinux From A Collection — RHCE in Ansible (EX294): Automate Red Hat Systems
- Mock Exam, Part 1: Seven Tasks Across Three Sections — RHCE in Ansible (EX294): Automate Red Hat Systems