diff --git a/doc/index.rst b/doc/index.rst index 8c76d1ff9d..2c7f9f8293 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -57,7 +57,7 @@ Writing your own customizations on top of Salt ref/index ref/python-api ref/modules/index - ref/returners + ref/returners/index ref/grains ref/renderers ref/states diff --git a/doc/ref/grains.rst b/doc/ref/grains.rst new file mode 100644 index 0000000000..306fedc06e --- /dev/null +++ b/doc/ref/grains.rst @@ -0,0 +1,5 @@ +====== +Grains +====== + +Static information that Salt derives about the system it's running on. diff --git a/doc/ref/index.rst b/doc/ref/index.rst new file mode 100644 index 0000000000..b802d348f2 --- /dev/null +++ b/doc/ref/index.rst @@ -0,0 +1,3 @@ +============================== +Introduction to extending Salt +============================== diff --git a/doc/ref/modules/index.rst b/doc/ref/modules/index.rst new file mode 100644 index 0000000000..440b5674b7 --- /dev/null +++ b/doc/ref/modules/index.rst @@ -0,0 +1,128 @@ +======= +Modules +======= + +Salt modules are the functions called by the :command:`salt` command. + +Full list of builtin modules +============================ + +.. toctree:: + :maxdepth: 1 + :glob: + + * + +Easy Modules to write +===================== + +Salt modules are amazingly simple to write, just write a regular Python module +or a regular Cython module and place it in the ``salt/modules`` directory. + +Since Salt modules are just Python/Cython modules there are no restraints as to +what you can put inside of a salt module, and if a Salt module has errors and +cannot import the Salt minion will continue to load without issue, the module +with errors will simply be omitted. + +If adding a Cython module the file must be named ``.pyx`` so that +the loader knows that the module needs to be imported as a Cython module. The +compilation of the Cython module is automatic and happens when the minion +starts, so only the ``*.pyx`` file is required. + +Preloaded Modules Data +====================== + +When interacting with modules often it is nice to be able to read information +dynamically about the minion, or load in configuration parameters for a module. +Salt allows for different types of data to be loaded into the modules by the +minion, as of this writing Salt loads information gathered from the Salt Grains +system and from the minion configuration file. + +Grains Data +----------- + +The Salt minion detects information about the system when started. This allows +for modules to be written dynamically with respect to the underlying hardware +and OS. This information is referred to as Salt Grains, or "grains of salt". +The Grains system was introduced to replace Facter, since relying on a Ruby +application from a Python application was both slow and inefficient. Grains +support replaces Facter in all releases after 0.8 + +The values detected by the Salt Grains on the minion are available in a dict by +the name of ``__grains__`` and can be accessed from within callable objects in +the Python modules. + +To see the contents of the grains dict for a given system in your deployment +run the :func:`grains.items` function: + +.. code-block:: bash + + salt 'hostname' grains.items + +To use the ``__grains__`` dict simply call it as a Python dict from within your +code, an excellent example is available in the Grains module: +:mod:`salt.modules.grains`. + +Module Configuration +-------------------- + +Since parameters for configuring a module may be desired, Salt allows for +configuration information stored in the main minion config file to be passed to +the modules. + +Since the minion configuration file is a yaml document, arbitrary configuration +data can be passed in the minion config that is read by the modules. It is +**strongly** recommended that the values passed in the configuration file match +the module. This means that a value intended for the ``test`` module should be +named ``test.``. + +Configuration also requires that default configuration parameters need to be +loaded as well. This can be done simply by adding the ``__opts__`` dict to the +top level of the module. + +The test module contains usage of the module configuration, and the default +configuration file for the minion contains the information and format used to +pass data to the modules. :mod:`salt.modules.test`, :file:`conf/minion`. + +Documentation +============= + +Salt modules are self documenting, the :func:`sys.doc` function will return the +documentation for all available Facter modules: + +.. code-block:: bash + + salt '*' sys.doc + +This function simple prints out the docstrings found in the modules, when +writing salt modules, please follow the formating conventions for docstrings as +they appear in the other modules. + +How Functions are Read +====================== + +In Salt Python callable objects contained within a module are made available to +the Salt minion for use. The only exception to this rule is a callable object +with a name starting with an underscore ``_``. + +Objects Loaded Into the Salt Minion +----------------------------------- + +.. code-block:: python + + def foo(bar): + return bar + + class baz: + def __init__(self, quo): + return quo + +Objects NOT Loaded into the Salt Minion +--------------------------------------- + +.. code-block:: python + + def _foobar(baz): # Preceded with an _ + return baz + + cheese = {} # Not a callable python object diff --git a/doc/ref/modules/modules.rst b/doc/ref/modules/modules.rst new file mode 100644 index 0000000000..7f2f078e95 --- /dev/null +++ b/doc/ref/modules/modules.rst @@ -0,0 +1,125 @@ +============================= +:mod:`salt.modules.butterkvm` +============================= + +.. automodule:: salt.modules.butterkvm + :members: + +=========================== +:mod:`salt.modules.cluster` +=========================== + +.. automodule:: salt.modules.cluster + :members: + +======================= +:mod:`salt.modules.cmd` +======================= + +.. automodule:: salt.modules.cmd + :members: + +======================== +:mod:`salt.modules.cmdc` +======================== + +.. automodule:: salt.modules.cmdc + :members: + +====================== +:mod:`salt.modules.cp` +====================== + +.. automodule:: salt.modules.cp + :members: + +=========================== +:mod:`salt.modules.cytestx` +=========================== + +.. automodule:: salt.modules.cytestx + :members: + +======================== +:mod:`salt.modules.disk` +======================== + +.. automodule:: salt.modules.disk + :members: + +========================== +:mod:`salt.modules.grains` +========================== + +.. automodule:: salt.modules.grains + :members: + +=========================== +:mod:`salt.modules.network` +=========================== + +.. automodule:: salt.modules.network + :members: + +========================== +:mod:`salt.modules.pacman` +========================== + +.. automodule:: salt.modules.pacman + :members: + +=========================== +:mod:`salt.modules.service` +=========================== + +.. automodule:: salt.modules.service + :members: + +========================= +:mod:`salt.modules.state` +========================= + +.. automodule:: salt.modules.state + :members: + +========================== +:mod:`salt.modules.status` +========================== + +.. automodule:: salt.modules.status + :members: + +=========================== +:mod:`salt.modules.statusc` +=========================== + +.. automodule:: salt.modules.statusc + :members: + +========================== +:mod:`salt.modules.sysctl` +========================== + +.. automodule:: salt.modules.sysctl + :members: + +======================== +:mod:`salt.modules.test` +======================== + +.. automodule:: salt.modules.test + :members: + +======================== +:mod:`salt.modules.virt` +======================== + +.. automodule:: salt.modules.virt + :members: + +======================= +:mod:`salt.modules.yum` +======================= + +.. automodule:: salt.modules.yum + :members: diff --git a/doc/ref/renderers.rst b/doc/ref/renderers.rst new file mode 100644 index 0000000000..d4f4bc03d4 --- /dev/null +++ b/doc/ref/renderers.rst @@ -0,0 +1,5 @@ +========= +Renderers +========= + +A python module that impments a render() method. diff --git a/doc/ref/returners/index.rst b/doc/ref/returners/index.rst new file mode 100644 index 0000000000..ccb92b06e8 --- /dev/null +++ b/doc/ref/returners/index.rst @@ -0,0 +1,15 @@ +========= +Returners +========= + +Salt returners allow the return data to be sent to arbitrary locations instead +of the salt master. + +Full list of builtin returners +============================== + +.. toctree:: + :maxdepth: 1 + :glob: + + * diff --git a/doc/ref/returners/returners.rst b/doc/ref/returners/returners.rst new file mode 100644 index 0000000000..3465a721e9 --- /dev/null +++ b/doc/ref/returners/returners.rst @@ -0,0 +1,13 @@ +=========================== +:mod:`salt.returners.local` +=========================== + +.. automodule:: salt.returners.local + :members: + +=========================== +:mod:`salt.returners.redis` +=========================== + +.. automodule:: salt.returners.redis + :members: diff --git a/doc/ref/states.rst b/doc/ref/states.rst new file mode 100644 index 0000000000..dabec2242a --- /dev/null +++ b/doc/ref/states.rst @@ -0,0 +1,6 @@ +================= +State enforcement +================= + +Enforce that specified packages are installed or that specified services are +running.