1
0

environments.rst 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. .. _file-server-environments:
  2. ===========================================
  3. Requesting Files from Specific Environments
  4. ===========================================
  5. The Salt fileserver supports multiple environments, allowing for SLS files and
  6. other files to be isolated for better organization.
  7. For the default backend (called :py:mod:`roots <salt.fileserver.roots>`),
  8. environments are defined using the :conf_master:`roots <file_roots>` option.
  9. Other backends (such as :py:mod:`gitfs <salt.fileserver.gitfs>`) define
  10. environments in their own ways. For a list of available fileserver backends,
  11. see :ref:`here <all-salt.fileserver>`.
  12. .. _querystring-syntax:
  13. Querystring Syntax
  14. ==================
  15. Any ``salt://`` file URL can specify its fileserver environment using a
  16. querystring syntax, like so:
  17. .. code-block:: bash
  18. salt://path/to/file?saltenv=foo
  19. In :ref:`Reactor <reactor>` configurations, this method must be used to pull
  20. files from an environment other than ``base``.
  21. In States
  22. =========
  23. Minions can be instructed which environment to use both globally, and for a
  24. single state, and multiple methods for each are available:
  25. Globally
  26. --------
  27. A minion can be pinned to an environment using the :conf_minion:`environment`
  28. option in the minion config file.
  29. Additionally, the environment can be set for a single call to the following
  30. functions:
  31. - :py:mod:`state.apply <salt.modules.state.apply>`
  32. - :py:mod:`state.highstate <salt.modules.state.highstate>`
  33. - :py:mod:`state.sls <salt.modules.state.sls>`
  34. - :py:mod:`state.top <salt.modules.state.top>`
  35. .. note::
  36. When the ``saltenv`` parameter is used to trigger a :ref:`highstate
  37. <running-highstate>` using either :py:mod:`state.apply
  38. <salt.modules.state.apply>` or :py:mod:`state.highstate
  39. <salt.modules.state.highstate>`, only states from that environment will be
  40. applied.
  41. On a Per-State Basis
  42. --------------------
  43. Within an individual state, there are two ways of specifying the environment.
  44. The first is to add a ``saltenv`` argument to the state. This example will pull
  45. the file from the ``config`` environment:
  46. .. code-block:: yaml
  47. /etc/foo/bar.conf:
  48. file.managed:
  49. - source: salt://foo/bar.conf
  50. - user: foo
  51. - mode: 600
  52. - saltenv: config
  53. Another way of doing the same thing is to use the :ref:`querystring syntax
  54. <querystring-syntax>` described above:
  55. .. code-block:: yaml
  56. /etc/foo/bar.conf:
  57. file.managed:
  58. - source: salt://foo/bar.conf?saltenv=config
  59. - user: foo
  60. - mode: 600
  61. .. note::
  62. Specifying the environment using either of the above methods is only
  63. necessary in cases where a state from one environment needs to access files
  64. from another environment. If the SLS file containing this state was in the
  65. ``config`` environment, then it would look in that environment by default.