1
0

layers.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. .. _state-layers:
  2. ===================
  3. State System Layers
  4. ===================
  5. The Salt state system is comprised of multiple layers. While using Salt does
  6. not require an understanding of the state layers, a deeper understanding of
  7. how Salt compiles and manages states can be very beneficial.
  8. .. _state-layers-function-call:
  9. Function Call
  10. =============
  11. The lowest layer of functionality in the state system is the direct state
  12. function call. State executions are executions of single state functions at
  13. the core. These individual functions are defined in state modules and can
  14. be called directly via the ``state.single`` command.
  15. .. code-block:: bash
  16. salt '*' state.single pkg.installed name='vim'
  17. .. _state-layers-low-chunk:
  18. Low Chunk
  19. =========
  20. The low chunk is the bottom of the Salt state compiler. This is a data
  21. representation of a single function call. The low chunk is sent to the state
  22. caller and used to execute a single state function.
  23. A single low chunk can be executed manually via the ``state.low`` command.
  24. .. code-block:: bash
  25. salt '*' state.low '{name: vim, state: pkg, fun: installed}'
  26. The passed data reflects what the state execution system gets after compiling
  27. the data down from sls formulas.
  28. .. _state-layers-low-state:
  29. Low State
  30. =========
  31. The `Low State` layer is the list of low chunks "evaluated" in order. To see
  32. what the low state looks like for a :ref:`highstate <running-highstate>`, run:
  33. .. code-block:: bash
  34. salt '*' state.show_lowstate
  35. This will display the raw lowstate in the order which each low chunk will be
  36. evaluated. The order of evaluation is not necessarily the order of execution,
  37. since requisites are evaluated at runtime. Requisite execution and evaluation
  38. is finite; this means that the order of execution can be ascertained with 100%
  39. certainty based on the order of the low state.
  40. .. _state-layers-high-data:
  41. High Data
  42. =========
  43. High data is the data structure represented in YAML via SLS files. The High
  44. data structure is created by merging the data components rendered inside sls
  45. files (or other render systems). The High data can be easily viewed by
  46. executing the ``state.show_highstate`` or ``state.show_sls`` functions. Since
  47. this data is a somewhat complex data structure, it may be easier to read using
  48. the json, yaml, or pprint outputters:
  49. .. code-block:: bash
  50. salt '*' state.show_highstate --out yaml
  51. salt '*' state.show_sls edit.vim --out pprint
  52. .. _state-layers-sls:
  53. SLS
  54. ===
  55. Above "High Data", the logical layers are no longer technically required to be
  56. executed, or to be executed in a hierarchy. This means that how the High data
  57. is generated is optional and very flexible. The SLS layer allows for many
  58. mechanisms to be used to render sls data from files or to use the fileserver
  59. backend to generate sls and file data from external systems.
  60. The SLS layer can be called directly to execute individual sls formulas.
  61. .. note::
  62. SLS Formulas have historically been called "SLS files". This is because a
  63. single SLS was only constituted in a single file. Now the term
  64. "SLS Formula" better expresses how a compartmentalized SLS can be expressed
  65. in a much more dynamic way by combining pillar and other sources, and the
  66. SLS can be dynamically generated.
  67. To call a single SLS formula named ``edit.vim``, execute :py:func:`state.apply
  68. <salt.modules.state.apply_>` and pass ``edit.vim`` as an argument:
  69. .. code-block:: bash
  70. salt '*' state.apply edit.vim
  71. .. _state-layers-highstate:
  72. HighState
  73. =========
  74. Calling SLS directly logically assigns what states should be executed from the
  75. context of the calling minion. The Highstate layer is used to allow for full
  76. contextual assignment of what is executed where to be tied to groups of, or
  77. individual, minions entirely from the master. This means that the environment of
  78. a minion, and all associated execution data pertinent to said minion, can be
  79. assigned from the master without needing to execute or configure anything on
  80. the target minion. This also means that the minion can independently retrieve
  81. information about its complete configuration from the master.
  82. To execute the :ref:`highstate <running-highstate>` use :py:func:`state.apply
  83. <salt.modules.state.apply_>`:
  84. .. code-block:: bash
  85. salt '*' state.apply
  86. .. _state-layers-orchestrate:
  87. Orchestrate
  88. ===========
  89. The orchestrate layer expresses the highest functional layer of Salt's automated
  90. logic systems. The Overstate allows for stateful and functional orchestration
  91. of routines from the master. The orchestrate defines in data execution stages
  92. which minions should execute states, or functions, and in what order using
  93. requisite logic.