2012-10-16 22:11:11 +00:00
|
|
|
==================
|
|
|
|
Master Tops System
|
|
|
|
==================
|
|
|
|
|
|
|
|
In 0.10.4 the `external_nodes` system was upgraded to allow for modular
|
|
|
|
subsystems to be used to generate the top file data for a highstate run on
|
|
|
|
the master.
|
|
|
|
|
2014-07-01 20:15:55 +00:00
|
|
|
The old `external_nodes` option has been removed.
|
|
|
|
The master tops system contains a number of subsystems that
|
2012-10-16 22:11:11 +00:00
|
|
|
are loaded via the Salt loader interfaces like modules, states, returners,
|
|
|
|
runners, etc.
|
|
|
|
|
2012-10-18 04:39:25 +00:00
|
|
|
Using the new `master_tops` option is simple:
|
2012-10-16 22:11:11 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
master_tops:
|
|
|
|
ext_nodes: cobbler-external-nodes
|
2013-06-26 11:38:37 +00:00
|
|
|
|
2013-09-04 12:42:14 +00:00
|
|
|
for :doc:`Cobbler <../../ref/tops/all/salt.tops.cobbler>` or:
|
2013-06-26 11:38:37 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
master_tops:
|
|
|
|
reclass:
|
|
|
|
inventory_base_uri: /etc/reclass
|
|
|
|
classes_uri: roles
|
2013-09-04 12:42:14 +00:00
|
|
|
|
|
|
|
for :doc:`Reclass <../../ref/tops/all/salt.tops.reclass_adapter>`.
|
2014-07-01 20:15:55 +00:00
|
|
|
|
2014-12-06 03:47:41 +00:00
|
|
|
It's also possible to create custom master_tops modules. These modules must go
|
2014-07-01 20:15:55 +00:00
|
|
|
in a subdirectory called `tops` in the `extension_modules` directory.
|
|
|
|
The `extension_modules` directory is not defined by default (the
|
|
|
|
default `/srv/salt/_modules` will NOT work as of this release)
|
|
|
|
|
|
|
|
Custom tops modules are written like any other execution module, see the source
|
2014-12-06 03:47:41 +00:00
|
|
|
for the two modules above for examples of fully functional ones. Below is
|
2014-07-01 20:15:55 +00:00
|
|
|
a degenerate example:
|
|
|
|
|
|
|
|
/etc/salt/master:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
extension_modules: /srv/salt/modules
|
|
|
|
master_tops:
|
|
|
|
customtop: True
|
|
|
|
|
|
|
|
/srv/salt/modules/tops/customtop.py:
|
|
|
|
|
2014-12-06 03:47:41 +00:00
|
|
|
.. code-block:: python
|
2014-07-01 20:15:55 +00:00
|
|
|
|
|
|
|
import logging
|
|
|
|
import sys
|
|
|
|
# Define the module's virtual name
|
|
|
|
__virtualname__ = 'customtop'
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
def __virtual__():
|
|
|
|
return __virtualname__
|
|
|
|
|
|
|
|
|
|
|
|
def top(**kwargs):
|
|
|
|
log.debug('Calling top in customtop')
|
|
|
|
return {'base': ['test']}
|
|
|
|
|
|
|
|
`salt minion state.show_top` should then display something like:
|
|
|
|
|
2014-12-06 03:47:41 +00:00
|
|
|
.. code-block:: bash
|
2014-07-01 20:15:55 +00:00
|
|
|
|
|
|
|
$ salt minion state.show_top
|
|
|
|
|
|
|
|
minion
|
|
|
|
----------
|
|
|
|
base:
|
|
|
|
- test
|