1
0

index.rst 2.3 KB

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