salt/doc/topics/slots/index.rst

54 lines
1.8 KiB
ReStructuredText
Raw Normal View History

2017-12-07 09:59:53 +00:00
.. _slots-subsystem:
=====
Slots
=====
.. versionadded:: 2018.3.0
2017-12-07 09:59:53 +00:00
.. note:: This functionality is under development and could be changed in the
future releases
Many times it is useful to store the results of a command during the course of
an execution. Salt Slots are designed to allow you to store this information and
use it later during the :ref:`highstate <running-highstate>` or other job
execution.
2017-12-07 09:59:53 +00:00
Slots extend the state syntax and allows you to do things right before the
state function is executed. So you can make a decision in the last moment right
before a state is executed.
2017-12-07 09:59:53 +00:00
Execution functions
-------------------
.. note:: Using execution modules return data as a state values is a first step
of Slots development. Other functionality is under development.
Slots allow you to use the return from a remote-execution function as an
argument value in states.
2017-12-07 09:59:53 +00:00
Slot syntax looks close to the simple python function call.
2018-06-06 05:49:37 +00:00
.. code-block:: text
2017-12-07 09:59:53 +00:00
__slot__:salt:<module>.<function>(<args>, ..., <kwargs...>, ...)
Also there are some specifics in the syntax coming from the execution functions
nature and a desire to simplify the user experience. First one is that you
don't need to quote the strings passed to the slots functions. The second one
is that all arguments handled as strings.
2017-12-07 09:59:53 +00:00
Here is a simple example:
2017-12-07 09:59:53 +00:00
.. code-block:: yaml
copy-some-file:
file.copy:
- name: __slot__:salt:test.echo(text=/tmp/some_file)
- source: __slot__:salt:test.echo(/etc/hosts)
This will execute the :py:func:`test.echo <salt.modules.test.echo>` execution
functions right before calling the state. The functions in the example will
return `/tmp/some_file` and `/etc/hosts` strings that will be used as a target
and source arguments in the state function `file.copy`.