Nodegroups¶
Nodegroups allow the automatic grouping and application of states to minions based on minion attributes. These are applied for all matches. Commonly used to apply a based configuration to specific types of OS, environment, or setup.
Create Nodegroups¶
Add node configuration to the salt master and restart for the nodegroups to be picked up.
1 2 3 4 5 | nodegroups:
- linux-base: 'G@os_family:Debian'
- debian-stretch: 'G@os:Debian and G@oscodename:stretch'
- ubuntu-bionic: 'G@os:Ubuntu and G@oscodename:bionic'
- ubuntu-xenial: 'G@os:Ubuntu and G@oscodename:xenial'
|
This will create four nodegroups, one matching
os_family
grain to a debian based system (e.g. will apply to debian, ubuntu, etc), and one matching other specific releases for those platforms.See Compound Matchers for matching syntax.
systemctl restart salt-master
Apply State to Nodegroups¶
States can now be applied to nodegroups and layered based on setup.
1 2 3 4 5 6 7 8 9 | prod:
linux-base:
- match: nodegroup
- {STANDARD STATES}
debian:
- match: nodegroup
- {DEBIAN SPECIFIC STATES}
'host1':
- {HOST SPECIFIC STATES}
|
If host1 is a Debian machine, it will have linux-base then debian and finally host1 applied.
If another host is a Debian install, it will have linux-base then debian applied.
An Ubuntu machine will only have linux-base applied.
See Rendering SLS ‘{PILLAR DATA}’ failed: Jinja variable … for common access errors with nodegroups.