mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #28306 from sdm24/update-nodegroup-docs-with-state-targeting
Updated the Nodegroup docs to include how to target nodegroups in SLS Jinja
This commit is contained in:
commit
0ab7c0053d
1 changed files with 39 additions and 0 deletions
|
@ -67,3 +67,42 @@ nodegroup`` on the line directly following the nodegroup name.
|
|||
|
||||
A limited amount of functionality, such as targeting with -N from the command-line may be
|
||||
available without a restart.
|
||||
|
||||
Using Nodegroups in SLS files
|
||||
=============================
|
||||
|
||||
To use Nodegroups in Jinja logic for SLS files, the :conf_master:'pillar_opts' option in
|
||||
``/etc/salt/master`` must be set to "True". This will pass the master's configuration as
|
||||
Pillar data to each minion.
|
||||
|
||||
.. note::
|
||||
|
||||
If the master's configuration contains any sensitive data, this will be passed to each minion.
|
||||
Do not enable this option if you have any configuration data that you do not want to get
|
||||
on your minions.
|
||||
|
||||
Also, if you make changes to your nodegroups, you might need to run
|
||||
``salt '*' saltutil.refresh_pillar`` after restarting the master.
|
||||
|
||||
Once pillar_opts is enabled, you can find the nodegroups under the "master" pillar.
|
||||
To make sure that only the correct minions are targeted,
|
||||
you should use each matcher for the nodegroup definition.
|
||||
For example, to check if a minion is in the 'webserver' nodegroup:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
nodegroups:
|
||||
webserver: 'G@os:Debian and L@minion1,minion2'
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
{% if grains.id in salt['pillar.get']('master:nodegroups:webserver', [])
|
||||
and grains.os in salt['pillar.get']('master:nodegroups:webserver', []) %}
|
||||
...
|
||||
{% endif %}
|
||||
|
||||
.. note::
|
||||
|
||||
If you do not include all of the matchers used to define a nodegroup,
|
||||
Salt might incorrectly target minions that meet some of the nodegroup
|
||||
requirements, but not all of them.
|
||||
|
|
Loading…
Add table
Reference in a new issue