1
0

index.rst 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .. _slots-subsystem:
  2. =====
  3. Slots
  4. =====
  5. .. versionadded:: 2018.3.0
  6. .. note:: This functionality is under development and could be changed in the
  7. future releases
  8. Many times it is useful to store the results of a command during the course of
  9. an execution. Salt Slots are designed to allow you to store this information and
  10. use it later during the :ref:`highstate <running-highstate>` or other job
  11. execution.
  12. Slots extend the state syntax and allows you to do things right before the
  13. state function is executed. So you can make a decision in the last moment right
  14. before a state is executed.
  15. Execution functions
  16. -------------------
  17. .. note:: Using execution modules return data as a state values is a first step
  18. of Slots development. Other functionality is under development.
  19. Slots allow you to use the return from a remote-execution function as an
  20. argument value in states.
  21. Slot syntax looks close to the simple python function call.
  22. .. code-block:: text
  23. __slot__:salt:<module>.<function>(<args>, ..., <kwargs...>, ...)
  24. Also there are some specifics in the syntax coming from the execution functions
  25. nature and a desire to simplify the user experience. First one is that you
  26. don't need to quote the strings passed to the slots functions. The second one
  27. is that all arguments handled as strings.
  28. Here is a simple example:
  29. .. code-block:: yaml
  30. copy-some-file:
  31. file.copy:
  32. - name: __slot__:salt:test.echo(text=/tmp/some_file)
  33. - source: __slot__:salt:test.echo(/etc/hosts)
  34. This will execute the :py:func:`test.echo <salt.modules.test.echo>` execution
  35. functions right before calling the state. The functions in the example will
  36. return `/tmp/some_file` and `/etc/hosts` strings that will be used as a target
  37. and source arguments in the state function `file.copy`.