Skip to content

Commit 18e270d

Browse files
committed
Merge pull request #6032 from terminalmage/docs
Document defining custom grains in /etc/salt/grains
2 parents 00f5968 + 11b79f9 commit 18e270d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

doc/topics/targeting/grains.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Grains data can be listed by using the 'grains.items' module::
5050

5151
salt '*' grains.items
5252

53+
5354
Grains in the Minion Config
5455
===========================
5556

@@ -70,6 +71,31 @@ Then status data specific to your servers can be retrieved via Salt, or used
7071
inside of the State system for matching. It also makes targeting, in the case
7172
of the example above, simply based on specific data about your deployment.
7273

74+
75+
Grains in /etc/salt/grains
76+
==========================
77+
78+
If you do not want to place your custom static grains in the minion config
79+
file, you can also put them in ``/etc/salt/grains``. They are configured in the
80+
same way as in the above example, only without a top-level ``grains:`` key:
81+
82+
.. code-block:: yaml
83+
84+
roles:
85+
- webserver
86+
- memcache
87+
deployment: datacenter4
88+
cabinet: 13
89+
cab_u: 14-15
90+
91+
.. admonition:: Precedece of Custom Static Grains
92+
93+
Be careful when defining grains both in ``/etc/salt/grains`` and within the
94+
minion config file. If a grain is defined in both places, the value in the
95+
minion config file takes precedence, and will always be used over its
96+
counterpart in ``/etc/salt/grains``.
97+
98+
7399
Writing Grains
74100
==============
75101

@@ -92,6 +118,7 @@ change, consider using :doc:`Pillar <../pillar/index>` instead.
92118

93119
.. _`dict`: http://docs.python.org/library/stdtypes.html#typesmapping
94120

121+
95122
Examples of Grains
96123
------------------
97124

@@ -100,6 +127,7 @@ the Salt minion and provides the principal example of how to write grains:
100127

101128
:blob:`salt/grains/core.py`
102129

130+
103131
Syncing Grains
104132
--------------
105133

0 commit comments

Comments
 (0)