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.
|
|
|
|
|
|
|
|
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'
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
SLS
|
|
|
|
====
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
OverState
|
|
|
|
=========
|
|
|
|
|
|
|
|
The overstate layer expresses the highest functional layer of Salt's automated
|
|
|
|
logic systems. The Overstate allows for stateful and functional orchestration
|
|
|
|
of routines from the master. The overstate defines in data execution stages
|
|
|
|
which minions should execute states, or functions, and in what order using
|
|
|
|
requisite logic.
|