peer.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. .. _peer:
  2. ==================
  3. Peer Communication
  4. ==================
  5. Salt 0.9.0 introduced the capability for Salt minions to publish commands. The
  6. intent of this feature is not for Salt minions to act as independent brokers
  7. one with another, but to allow Salt minions to pass commands to each other.
  8. In Salt 0.10.0 the ability to execute runners from the master was added. This
  9. allows for the master to return collective data from runners back to the
  10. minions via the peer interface.
  11. The peer interface is configured through two options in the master
  12. configuration file. For minions to send commands from the master the ``peer``
  13. configuration is used. To allow for minions to execute runners from the master
  14. the ``peer_run`` configuration is used.
  15. Since this presents a viable security risk by allowing minions access to the
  16. master publisher the capability is turned off by default. The minions can be
  17. allowed access to the master publisher on a per minion basis based on regular
  18. expressions. Minions with specific ids can be allowed access to certain Salt
  19. modules and functions.
  20. Peer Configuration
  21. ==================
  22. The configuration is done under the ``peer`` setting in the Salt master
  23. configuration file, here are a number of configuration possibilities.
  24. The simplest approach is to enable all communication for all minions, this is
  25. only recommended for very secure environments.
  26. .. code-block:: yaml
  27. peer:
  28. .*:
  29. - .*
  30. This configuration will allow minions with IDs ending in example.com access
  31. to the test, ps, and pkg module functions.
  32. .. code-block:: yaml
  33. peer:
  34. .*example.com:
  35. - test.*
  36. - ps.*
  37. - pkg.*
  38. The configuration logic is simple, a regular expression is passed for matching
  39. minion ids, and then a list of expressions matching minion functions is
  40. associated with the named minion. For instance, this configuration will also
  41. allow minions ending with foo.org access to the publisher.
  42. .. code-block:: yaml
  43. peer:
  44. .*example.com:
  45. - test.*
  46. - ps.*
  47. - pkg.*
  48. .*foo.org:
  49. - test.*
  50. - ps.*
  51. - pkg.*
  52. .. note::
  53. Functions are matched using regular expressions.
  54. Peer Runner Communication
  55. =========================
  56. Configuration to allow minions to execute runners from the master is done via
  57. the ``peer_run`` option on the master. The ``peer_run`` configuration follows
  58. the same logic as the ``peer`` option. The only difference is that access is
  59. granted to runner modules.
  60. To open up access to all minions to all runners:
  61. .. code-block:: yaml
  62. peer_run:
  63. .*:
  64. - .*
  65. This configuration will allow minions with IDs ending in example.com access
  66. to the manage and jobs runner functions.
  67. .. code-block:: yaml
  68. peer_run:
  69. .*example.com:
  70. - manage.*
  71. - jobs.*
  72. .. note::
  73. Functions are matched using regular expressions.
  74. Using Peer Communication
  75. ========================
  76. The publish module was created to manage peer communication. The publish module
  77. comes with a number of functions to execute peer communication in different
  78. ways. Currently there are three functions in the publish module. These examples
  79. will show how to test the peer system via the salt-call command.
  80. To execute test.version on all minions:
  81. .. code-block:: bash
  82. # salt-call publish.publish \* test.version
  83. To execute the manage.up runner:
  84. .. code-block:: bash
  85. # salt-call publish.runner manage.up
  86. To match minions using other matchers, use ``tgt_type``:
  87. .. code-block:: bash
  88. # salt-call publish.publish 'webserv* and not G@os:Ubuntu' test.version tgt_type='compound'
  89. .. note::
  90. In pre-2017.7.0 releases, use ``expr_form`` instead of ``tgt_type``.