index.rst 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. .. _master-tops-system:
  2. ==================
  3. Master Tops System
  4. ==================
  5. In 0.10.4 the `external_nodes` system was upgraded to allow for modular
  6. subsystems to be used to generate the top file data for a :ref:`highstate
  7. <running-highstate>` run on the master.
  8. The old `external_nodes` option has been removed. The master tops system
  9. provides a pluggable and extendable replacement for it, allowing for multiple
  10. different subsystems to provide top file data.
  11. Using the new `master_tops` option is simple:
  12. .. code-block:: yaml
  13. master_tops:
  14. ext_nodes: cobbler-external-nodes
  15. for :mod:`Cobbler <salt.tops.cobbler>` or:
  16. .. code-block:: yaml
  17. master_tops:
  18. reclass:
  19. inventory_base_uri: /etc/reclass
  20. classes_uri: roles
  21. for :mod:`Reclass <salt.tops.reclass_adapter>`.
  22. .. code-block:: yaml
  23. master_tops:
  24. varstack: /path/to/the/config/file/varstack.yaml
  25. for :mod:`Varstack <salt.tops.varstack>`.
  26. It's also possible to create custom master_tops modules. Simply place them into
  27. ``salt://_tops`` in the Salt fileserver and use the
  28. :py:func:`saltutil.sync_tops <salt.runners.saltutil.sync_tops>` runner to sync
  29. them. If this runner function is not available, they can manually be placed
  30. into ``extmods/tops``, relative to the master cachedir (in most cases the full
  31. path will be ``/var/cache/salt/master/extmods/tops``).
  32. Custom tops modules are written like any other execution module, see the source
  33. for the two modules above for examples of fully functional ones. Below is a
  34. bare-bones example:
  35. **/etc/salt/master:**
  36. .. code-block:: yaml
  37. master_tops:
  38. customtop: True
  39. **customtop.py:** (custom master_tops module)
  40. .. code-block:: python
  41. import logging
  42. import sys
  43. # Define the module's virtual name
  44. __virtualname__ = 'customtop'
  45. log = logging.getLogger(__name__)
  46. def __virtual__():
  47. return __virtualname__
  48. def top(**kwargs):
  49. log.debug('Calling top in customtop')
  50. return {'base': ['test']}
  51. `salt minion state.show_top` should then display something like:
  52. .. code-block:: bash
  53. $ salt minion state.show_top
  54. minion
  55. ----------
  56. base:
  57. - test
  58. .. note::
  59. If a master_tops module returns :ref:`top file <states-top>` data for a
  60. given minion, it will be added to the states configured in the top file. It
  61. will *not* replace it altogether. The 2018.3.0 release adds additional
  62. functionality allowing a minion to treat master_tops as the single source
  63. of truth, irrespective of the top file.