nodegroups.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. .. _targeting-nodegroups:
  2. ===========
  3. Node groups
  4. ===========
  5. Nodegroups are declared using a compound target specification. The compound
  6. target documentation can be found :ref:`here <targeting-compound>`.
  7. The :conf_master:`nodegroups` master config file parameter is used to define
  8. nodegroups. Here's an example nodegroup configuration within
  9. ``/etc/salt/master``:
  10. .. code-block:: yaml
  11. nodegroups:
  12. group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com or bl*.domain.com'
  13. group2: 'G@os:Debian and foo.domain.com'
  14. group3: 'G@os:Debian and N@group1'
  15. group4:
  16. - 'G@foo:bar'
  17. - 'or'
  18. - 'G@foo:baz'
  19. .. note::
  20. The ``L`` within group1 is matching a list of minions, while the ``G`` in
  21. group2 is matching specific grains. See the :ref:`compound matchers
  22. <targeting-compound>` documentation for more details.
  23. As of the 2017.7.0 release of Salt, group names can also be prepended with
  24. a dash. This brings the usage in line with many other areas of Salt. For
  25. example:
  26. .. code-block:: yaml
  27. nodegroups:
  28. - group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com or bl*.domain.com'
  29. .. versionadded:: 2015.8.0
  30. .. note::
  31. Nodegroups can reference other nodegroups as seen in ``group3``. Ensure
  32. that you do not have circular references. Circular references will be
  33. detected and cause partial expansion with a logged error message.
  34. .. versionadded:: 2015.8.0
  35. Compound nodegroups can be either string values or lists of string values.
  36. When the nodegroup is A string value will be tokenized by splitting on
  37. whitespace. This may be a problem if whitespace is necessary as part of a
  38. pattern. When a nodegroup is a list of strings then tokenization will
  39. happen for each list element as a whole.
  40. To match a nodegroup on the CLI, use the ``-N`` command-line option:
  41. .. code-block:: bash
  42. salt -N group1 test.version
  43. .. versionadded:: 2019.2.0
  44. .. note::
  45. The ``N@`` classifier historically could not be used in compound matches
  46. within the CLI or :term:`top file <Top File>`, it was only recognized in the
  47. :conf_master:`nodegroups` master config file parameter. As of the 2019.2.0
  48. release, this limitation no longer exists.
  49. To match a nodegroup in your :term:`top file <Top File>`, make sure to put ``- match:
  50. nodegroup`` on the line directly following the nodegroup name.
  51. .. code-block:: yaml
  52. base:
  53. group1:
  54. - match: nodegroup
  55. - webserver
  56. .. note::
  57. When adding or modifying nodegroups to a master configuration file, the
  58. master must be restarted for those changes to be fully recognized.
  59. A limited amount of functionality, such as targeting with -N from the
  60. command-line may be available without a restart.
  61. Defining Nodegroups as Lists of Minion IDs
  62. ==========================================
  63. A simple list of minion IDs would traditionally be defined like this:
  64. .. code-block:: yaml
  65. nodegroups:
  66. group1: L@host1,host2,host3
  67. They can now also be defined as a YAML list, like this:
  68. .. code-block:: yaml
  69. nodegroups:
  70. group1:
  71. - host1
  72. - host2
  73. - host3
  74. .. versionadded:: 2016.11.0