1
0

grains.rst 985 B

1234567891011121314151617181920212223242526272829303132333435
  1. .. _targeting-grains:
  2. ======================
  3. Targeting using Grains
  4. ======================
  5. Grain data can be used when targeting minions.
  6. For example, the following matches all CentOS minions:
  7. .. code-block:: bash
  8. salt -G 'os:CentOS' test.version
  9. Match all minions with 64-bit CPUs, and return number of CPU cores for each
  10. matching minion:
  11. .. code-block:: bash
  12. salt -G 'cpuarch:x86_64' grains.item num_cpus
  13. Additionally, globs can be used in grain matches, and grains that are nested in
  14. a dictionary can be matched by adding a colon for each level that is traversed.
  15. For example, the following will match hosts that have a grain called
  16. ``ec2_tags``, which itself is a dictionary with a key named ``environment``,
  17. which has a value that contains the word ``production``:
  18. .. code-block:: bash
  19. salt -G 'ec2_tags:environment:*production*'
  20. .. important::
  21. See :ref:`Is Targeting using Grain Data Secure? <faq-grain-security>` for
  22. important security information.