backends.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. .. _file-server-backends:
  2. ====================
  3. File Server Backends
  4. ====================
  5. In Salt 0.12.0, the modular fileserver was introduced. This feature added the
  6. ability for the Salt Master to integrate different file server backends. File
  7. server backends allow the Salt file server to act as a transparent bridge to
  8. external resources. A good example of this is the :mod:`git
  9. <salt.fileserver.git>` backend, which allows Salt to serve files sourced from
  10. one or more git repositories, but there are several others as well. Click
  11. :ref:`here <all-salt.fileserver>` for a full list of Salt's fileserver
  12. backends.
  13. Enabling a Fileserver Backend
  14. -----------------------------
  15. Fileserver backends can be enabled with the :conf_master:`fileserver_backend`
  16. option.
  17. .. code-block:: yaml
  18. fileserver_backend:
  19. - git
  20. See the :ref:`documentation <all-salt.fileserver>` for each backend to find the
  21. correct value to add to :conf_master:`fileserver_backend` in order to enable
  22. them.
  23. Using Multiple Backends
  24. -----------------------
  25. If :conf_master:`fileserver_backend` is not defined in the Master config file,
  26. Salt will use the :mod:`roots <salt.fileserver.roots>` backend, but the
  27. :conf_master:`fileserver_backend` option supports multiple backends. When more
  28. than one backend is in use, the files from the enabled backends are merged into a
  29. single virtual filesystem. When a file is requested, the backends will be
  30. searched in order for that file, and the first backend to match will be the one
  31. which returns the file.
  32. .. code-block:: yaml
  33. fileserver_backend:
  34. - roots
  35. - git
  36. With this configuration, the environments and files defined in the
  37. :conf_master:`file_roots` parameter will be searched first, and if the file is
  38. not found then the git repositories defined in :conf_master:`gitfs_remotes`
  39. will be searched.
  40. Defining Environments
  41. ---------------------
  42. Just as the order of the values in :conf_master:`fileserver_backend` matters,
  43. so too does the order in which different sources are defined within a
  44. fileserver environment. For example, given the below :conf_master:`file_roots`
  45. configuration, if both ``/srv/salt/dev/foo.txt`` and ``/srv/salt/prod/foo.txt``
  46. exist on the Master, then ``salt://foo.txt`` would point to
  47. ``/srv/salt/dev/foo.txt`` in the ``dev`` environment, but it would point to
  48. ``/srv/salt/prod/foo.txt`` in the ``base`` environment.
  49. .. code-block:: yaml
  50. file_roots:
  51. base:
  52. - /srv/salt/prod
  53. qa:
  54. - /srv/salt/qa
  55. - /srv/salt/prod
  56. dev:
  57. - /srv/salt/dev
  58. - /srv/salt/qa
  59. - /srv/salt/prod
  60. Similarly, when using the :mod:`git <salt.fileserver.gitfs>` backend, if both
  61. repositories defined below have a ``hotfix23`` branch/tag, and both of them
  62. also contain the file ``bar.txt`` in the root of the repository at that
  63. branch/tag, then ``salt://bar.txt`` in the ``hotfix23`` environment would be
  64. served from the ``first`` repository.
  65. .. code-block:: yaml
  66. gitfs_remotes:
  67. - https://mydomain.tld/repos/first.git
  68. - https://mydomain.tld/repos/second.git
  69. .. note::
  70. Environments map differently based on the fileserver backend. For instance,
  71. the mappings are explicitly defined in :mod:`roots <salt.fileserver.roots>`
  72. backend, while in the VCS backends (:mod:`git <salt.fileserver.gitfs>`,
  73. :mod:`hg <salt.fileserver.hgfs>`, :mod:`svn <salt.fileserver.svnfs>`) the
  74. environments are created from branches/tags/bookmarks/etc. For the
  75. :mod:`minion <salt.fileserver.minionfs>` backend, the files are all in a
  76. single environment, which is specified by the :conf_master:`minionfs_env`
  77. option.
  78. See the documentation for each backend for a more detailed explanation of
  79. how environments are mapped.