salt/doc/topics/targeting/grains.rst
rallytime f6d9cdc633 Merge branch '2015.8' into '2016.3'
Conflicts:
  - doc/ref/states/compiler_ordering.rst
  - doc/topics/installation/suse.rst
  - doc/topics/jobs/schedule.rst
  - doc/topics/targeting/grains.rst
  - doc/topics/tutorials/preseed_key.rst
  - doc/topics/tutorials/states_pt5.rst
  - pkg/suse/use-forking-daemon.patch
  - salt/minion.py
  - salt/modules/pacman.py
  - salt/modules/state.py
  - salt/modules/yumpkg.py
2016-03-25 11:47:16 -06:00

37 lines
1.0 KiB
ReStructuredText

.. _targeting-grains:
======================
Targeting using Grains
======================
Grain data can be used when targeting minions.
For example, the following matches all CentOS minions:
.. code-block:: bash
salt -G 'os:CentOS' test.ping
Match all minions with 64-bit CPUs, and return number of CPU cores for each
matching minion:
.. code-block:: bash
salt -G 'cpuarch:x86_64' grains.item num_cpus
Additionally, globs can be used in grain matches, and grains that are nested in
a :ref:`dictionary <python2:typesmapping>` can be matched by adding a colon for
each level that is traversed. For example, the following will match hosts that
have a grain called ``ec2_tags``, which itself is a
:ref:`dict <python2:typesmapping>` with a key named ``environment``, which
has a value that contains the word ``production``:
.. code-block:: bash
salt -G 'ec2_tags:environment:*production*'
.. important::
See :ref:`Is Targeting using Grain Data Secure? <faq-grain-security>` for
important security information.