2014-02-27 21:55:45 +00:00
|
|
|
.. _state-layers:
|
|
|
|
|
2013-06-09 20:28:27 +00:00
|
|
|
===================
|
|
|
|
State System Layers
|
|
|
|
===================
|
|
|
|
|
2013-06-11 00:11:29 +00:00
|
|
|
The Salt state system is comprised of multiple layers. While using Salt does
|
|
|
|
not require an understanding of the state layers, a deeper understanding of
|
2013-06-09 20:28:27 +00:00
|
|
|
how Salt compiles and manages states can be very beneficial.
|
|
|
|
|
2014-02-27 21:55:45 +00:00
|
|
|
.. _state-layers-function-call:
|
|
|
|
|
2013-06-09 20:28:27 +00:00
|
|
|
Function Call
|
|
|
|
=============
|
|
|
|
|
|
|
|
The lowest layer of functionality in the state system is the direct state
|
2013-06-11 00:11:29 +00:00
|
|
|
function call. State executions are executions of single state functions at
|
|
|
|
the core. These individual functions are defined in state modules and can
|
2013-06-09 20:28:27 +00:00
|
|
|
be called directly via the ``state.single`` command.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt '*' state.single pkg.installed name='vim'
|
|
|
|
|
2014-02-27 21:55:45 +00:00
|
|
|
.. _state-layers-low-chunk:
|
|
|
|
|
2013-06-09 20:28:27 +00:00
|
|
|
Low Chunk
|
|
|
|
=========
|
|
|
|
|
|
|
|
The low chunk is the bottom of the Salt state compiler. This is a data
|
|
|
|
representation of a single function call. The low chunk is sent to the state
|
|
|
|
caller and used to execute a single state function.
|
|
|
|
|
|
|
|
A single low chunk can be executed manually via the ``state.low`` command.
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt '*' state.low '{name: vim, state: pkg, fun: installed}'
|
|
|
|
|
|
|
|
The passed data reflects what the state execution system gets after compiling
|
|
|
|
the data down from sls formulas.
|
|
|
|
|
2014-02-27 21:55:45 +00:00
|
|
|
.. _state-layers-low-state:
|
|
|
|
|
2013-06-09 20:28:27 +00:00
|
|
|
Low State
|
|
|
|
=========
|
|
|
|
|
|
|
|
The `Low State` layer is the list of low chunks "evaluated" in order. To see
|
2013-06-11 00:11:29 +00:00
|
|
|
what the low state looks like for a highstate, run:
|
2013-06-09 20:28:27 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt '*' state.show_lowstate
|
|
|
|
|
|
|
|
This will display the raw lowstate in the order which each low chunk will be
|
|
|
|
evaluated. The order of evaluation is not necessarily the order of execution,
|
|
|
|
since requisites are evaluated at runtime. Requisite execution and evaluation
|
2013-06-11 00:11:29 +00:00
|
|
|
is finite; this means that the order of execution can be ascertained with 100%
|
2013-06-09 20:28:27 +00:00
|
|
|
certainty based on the order of the low state.
|
|
|
|
|
2014-02-27 21:55:45 +00:00
|
|
|
.. _state-layers-high-data:
|
|
|
|
|
2013-06-09 20:28:27 +00:00
|
|
|
High Data
|
|
|
|
=========
|
|
|
|
|
|
|
|
High data is the data structure represented in YAML via SLS files. The High
|
|
|
|
data structure is created by merging the data components rendered inside sls
|
|
|
|
files (or other render systems). The High data can be easily viewed by
|
|
|
|
executing the ``state.show_highstate`` or ``state.show_sls`` functions. Since
|
2013-06-11 00:11:29 +00:00
|
|
|
this data is a somewhat complex data structure, it may be easier to read using
|
|
|
|
the json, yaml, or pprint outputters:
|
2013-06-09 20:28:27 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt '*' state.show_highstate --out yaml
|
|
|
|
salt '*' state.show_sls edit.vim --out pprint
|
|
|
|
|
2014-02-27 21:55:45 +00:00
|
|
|
.. _state-layers-sls:
|
|
|
|
|
2013-06-09 20:28:27 +00:00
|
|
|
SLS
|
2016-02-08 16:28:32 +00:00
|
|
|
===
|
2013-06-09 20:28:27 +00:00
|
|
|
|
2013-06-11 00:11:29 +00:00
|
|
|
Above "High Data", the logical layers are no longer technically required to be
|
2013-06-09 20:28:27 +00:00
|
|
|
executed, or to be executed in a hierarchy. This means that how the High data
|
|
|
|
is generated is optional and very flexible. The SLS layer allows for many
|
|
|
|
mechanisms to be used to render sls data from files or to use the fileserver
|
|
|
|
backend to generate sls and file data from external systems.
|
|
|
|
|
|
|
|
The SLS layer can be called directly to execute individual sls formulas.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
SLS Formulas have historically been called "SLS files". This is because a
|
2014-12-11 03:36:15 +00:00
|
|
|
single SLS was only constituted in a single file. Now the term
|
2013-06-11 00:11:29 +00:00
|
|
|
"SLS Formula" better expresses how a compartmentalized SLS can be expressed
|
|
|
|
in a much more dynamic way by combining pillar and other sources, and the
|
2013-06-09 20:28:27 +00:00
|
|
|
SLS can be dynamically generated.
|
|
|
|
|
2013-06-11 00:11:29 +00:00
|
|
|
To call a single SLS formula named ``edit.vim``, execute ``state.sls``:
|
2013-06-09 20:28:27 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt '*' state.sls edit.vim
|
|
|
|
|
2014-02-27 21:55:45 +00:00
|
|
|
.. _state-layers-highstate:
|
|
|
|
|
2013-06-09 20:28:27 +00:00
|
|
|
HighState
|
|
|
|
=========
|
|
|
|
|
|
|
|
Calling SLS directly logically assigns what states should be executed from the
|
|
|
|
context of the calling minion. The Highstate layer is used to allow for full
|
|
|
|
contextual assignment of what is executed where to be tied to groups of, or
|
2013-06-11 00:11:29 +00:00
|
|
|
individual, minions entirely from the master. This means that the environment of
|
|
|
|
a minion, and all associated execution data pertinent to said minion, can be
|
2013-06-09 20:28:27 +00:00
|
|
|
assigned from the master without needing to execute or configure anything on
|
|
|
|
the target minion. This also means that the minion can independently retrieve
|
|
|
|
information about its complete configuration from the master.
|
|
|
|
|
|
|
|
To execute the High State call ``state.highstate``:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
salt '*' state.highstate
|
|
|
|
|
2016-02-08 16:28:32 +00:00
|
|
|
.. _state-layers-orchestrate:
|
2014-02-27 21:55:45 +00:00
|
|
|
|
2016-02-08 16:28:32 +00:00
|
|
|
Orchestrate
|
|
|
|
===========
|
2013-06-09 20:28:27 +00:00
|
|
|
|
2016-02-08 16:28:32 +00:00
|
|
|
The orchestrate layer expresses the highest functional layer of Salt's automated
|
2013-06-09 20:28:27 +00:00
|
|
|
logic systems. The Overstate allows for stateful and functional orchestration
|
2016-02-08 16:28:32 +00:00
|
|
|
of routines from the master. The orchestrate defines in data execution stages
|
2013-06-09 20:28:27 +00:00
|
|
|
which minions should execute states, or functions, and in what order using
|
2014-12-11 03:36:15 +00:00
|
|
|
requisite logic.
|