mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
ae38c874da
* Remove :members: from fileserver docs pages These functions can never be invoked directly from the CLI, so it is pointless to include them in the documentation. * Rename section * Add docs page clarifying how to get files from different environments * Add reminder that file_roots can be specified for masterless salt * Link to the new environments page from the states tutorial * Add information on pulling reactor configs from non-base environments * Add examples of querystring syntax to cp module
90 lines
2.8 KiB
ReStructuredText
90 lines
2.8 KiB
ReStructuredText
.. _file-server-environments:
|
|
|
|
===========================================
|
|
Requesting Files from Specific Environments
|
|
===========================================
|
|
|
|
The Salt fileserver supports multiple environments, allowing for SLS files and
|
|
other files to be isolated for better organization.
|
|
|
|
For the default backend (called :py:mod:`roots <salt.fileserver.roots>`),
|
|
environments are defined using the :conf_master:`roots <file_roots>` option.
|
|
Other backends (such as :py:mod:`gitfs <salt.fileserver.gitfs>`) define
|
|
environments in their own ways. For a list of available fileserver backends,
|
|
see :ref:`here <all-salt.fileserver>`.
|
|
|
|
.. _querystring-syntax:
|
|
|
|
Querystring Syntax
|
|
==================
|
|
|
|
Any ``salt://`` file URL can specify its fileserver environment using a
|
|
querystring syntax, like so:
|
|
|
|
.. code-block:: bash
|
|
|
|
salt://path/to/file?saltenv=foo
|
|
|
|
In :ref:`Reactor <reactor>` configurations, this method must be used to pull
|
|
files from an environment other than ``base``.
|
|
|
|
In States
|
|
=========
|
|
|
|
Minions can be instructed which environment to use both globally, and for a
|
|
single state, and multiple methods for each are available:
|
|
|
|
Globally
|
|
--------
|
|
|
|
A minion can be pinned to an environment using the :conf_minion:`environment`
|
|
option in the minion config file.
|
|
|
|
Additionally, the environment can be set for a single call to the following
|
|
functions:
|
|
|
|
- :py:mod:`state.apply <salt.modules.state.apply>`
|
|
- :py:mod:`state.highstate <salt.modules.state.highstate>`
|
|
- :py:mod:`state.sls <salt.modules.state.sls>`
|
|
- :py:mod:`state.top <salt.modules.state.top>`
|
|
|
|
.. note::
|
|
When the ``saltenv`` parameter is used to trigger a :ref:`highstate
|
|
<running-highstate>` using either :py:mod:`state.apply
|
|
<salt.modules.state.apply>` or :py:mod:`state.highstate
|
|
<salt.modules.state.highstate>`, only states from that environment will be
|
|
applied.
|
|
|
|
On a Per-State Basis
|
|
--------------------
|
|
|
|
Within an individual state, there are two ways of specifying the environment.
|
|
The first is to add a ``saltenv`` argument to the state. This example will pull
|
|
the file from the ``config`` environment:
|
|
|
|
.. code-block:: yaml
|
|
|
|
/etc/foo/bar.conf:
|
|
file.managed:
|
|
- source: salt://foo/bar.conf
|
|
- user: foo
|
|
- mode: 600
|
|
- saltenv: config
|
|
|
|
Another way of doing the same thing is to use the :ref:`querystring syntax
|
|
<querystring-syntax>` described above:
|
|
|
|
.. code-block:: yaml
|
|
|
|
/etc/foo/bar.conf:
|
|
file.managed:
|
|
- source: salt://foo/bar.conf?saltenv=config
|
|
- user: foo
|
|
- mode: 600
|
|
|
|
.. note::
|
|
Specifying the environment using either of the above methods is only
|
|
necessary in cases where a state from one environment needs to access files
|
|
from another environment. If the SLS file containing this state was in the
|
|
``config`` environment, then it would look in that environment by default.
|