2012-09-22 21:55:32 +00:00
|
|
|
===================
|
|
|
|
Include and Exclude
|
|
|
|
===================
|
|
|
|
|
|
|
|
Salt sls files can include other sls files and exclude sls files that have been
|
|
|
|
otherwise included. This allows for an sls file to easily extend or manipulate
|
|
|
|
other sls files.
|
|
|
|
|
2013-04-29 02:19:43 +00:00
|
|
|
Include
|
|
|
|
=======
|
|
|
|
|
|
|
|
When other sls files are included, everything defined in the included sls file
|
|
|
|
will be added to the state run. When including define a list of sls formulas
|
|
|
|
to include:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
include:
|
|
|
|
- http
|
|
|
|
- libvirt
|
|
|
|
|
|
|
|
The include statement will include sls formulas from the same environment
|
|
|
|
that the including sls formula is in. But the environment can be explicitly
|
|
|
|
defined in the configuration to override the running environment, therefore
|
|
|
|
if an sls formula needs to be included from an external environment named "dev"
|
|
|
|
the following syntax is used:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
include:
|
|
|
|
- dev: http
|
|
|
|
|
2015-05-18 16:12:07 +00:00
|
|
|
.. include:: ../../_incl/_incl/sls_filename_cant_contain_period.rst
|
2015-01-20 05:02:26 +00:00
|
|
|
|
2013-05-16 23:51:50 +00:00
|
|
|
Relative Include
|
|
|
|
================
|
|
|
|
|
|
|
|
In Salt 0.16.0 the capability to include sls formulas which are relative to
|
|
|
|
the running sls formula was added, simply precede the formula name with a
|
|
|
|
`.`:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
include:
|
|
|
|
- .virt
|
|
|
|
- .virt.hyper
|
|
|
|
|
2012-09-22 21:55:32 +00:00
|
|
|
Exclude
|
|
|
|
=======
|
|
|
|
|
|
|
|
The exclude statement, added in Salt 0.10.3 allows an sls to hard exclude
|
|
|
|
another sls file or a specific id. The component is excluded after the
|
|
|
|
high data has been compiled, so nothing should be able to override an
|
|
|
|
exclude.
|
|
|
|
|
|
|
|
Since the exclude can remove an id or an sls the type of component to
|
|
|
|
exclude needs to be defined. an exclude statement that verifies that the
|
|
|
|
running highstate does not contain the `http` sls and the `/etc/vimrc` id
|
|
|
|
would look like this:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
exclude:
|
|
|
|
- sls: http
|
2015-01-20 05:02:26 +00:00
|
|
|
- id: /etc/vimrc
|