standalone_minion.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. .. _tutorial-standalone-minion:
  2. =================
  3. Standalone Minion
  4. =================
  5. Since the Salt minion contains such extensive functionality it can be useful
  6. to run it standalone. A standalone minion can be used to do a number of
  7. things:
  8. - Use salt-call commands on a system without connectivity to a master
  9. - Masterless States, run states entirely from files local to the minion
  10. .. note::
  11. When running Salt in masterless mode, do not run the salt-minion daemon.
  12. Otherwise, it will attempt to connect to a master and fail. The salt-call
  13. command stands on its own and does not need the salt-minion daemon.
  14. Minion Configuration
  15. --------------------
  16. Throughout this document there are several references to setting different
  17. options to configure a masterless Minion. Salt Minions are easy to configure
  18. via a configuration file that is located, by default, in ``/etc/salt/minion``.
  19. Note, however, that on FreeBSD systems, the minion configuration file is located
  20. in ``/usr/local/etc/salt/minion``.
  21. You can learn more about minion configuration options in the
  22. :ref:`Configuring the Salt Minion <configuration-salt-minion>` docs.
  23. Telling Salt Call to Run Masterless
  24. ===================================
  25. The salt-call command is used to run module functions locally on a minion
  26. instead of executing them from the master. Normally the salt-call command
  27. checks into the master to retrieve file server and pillar data, but when
  28. running standalone salt-call needs to be instructed to not check the master for
  29. this data. To instruct the minion to not look for a master when running
  30. salt-call the :conf_minion:`file_client` configuration option needs to be set.
  31. By default the :conf_minion:`file_client` is set to ``remote`` so that the
  32. minion knows that file server and pillar data are to be gathered from the
  33. master. When setting the :conf_minion:`file_client` option to ``local`` the
  34. minion is configured to not gather this data from the master.
  35. .. code-block:: yaml
  36. file_client: local
  37. Now the salt-call command will not look for a master and will assume that the
  38. local system has all of the file and pillar resources.
  39. Running States Masterless
  40. =========================
  41. The state system can be easily run without a Salt master, with all needed files
  42. local to the minion. To do this the minion configuration file needs to be set
  43. up to know how to return file_roots information like the master. The file_roots
  44. setting defaults to /srv/salt for the base environment just like on the master:
  45. .. code-block:: yaml
  46. file_roots:
  47. base:
  48. - /srv/salt
  49. Now set up the Salt State Tree, top file, and SLS modules in the same way that
  50. they would be set up on a master. Now, with the :conf_minion:`file_client`
  51. option set to ``local`` and an available state tree then calls to functions in
  52. the state module will use the information in the file_roots on the minion
  53. instead of checking in with the master.
  54. Remember that when creating a state tree on a minion there are no syntax or
  55. path changes needed, SLS modules written to be used from a master do not need
  56. to be modified in any way to work with a minion.
  57. This makes it easy to "script" deployments with Salt states without having to
  58. set up a master, and allows for these SLS modules to be easily moved into a
  59. Salt master as the deployment grows.
  60. The declared state can now be executed with:
  61. .. code-block:: bash
  62. salt-call state.apply
  63. Or the salt-call command can be executed with the ``--local`` flag, this makes
  64. it unnecessary to change the configuration file:
  65. .. code-block:: bash
  66. salt-call state.apply --local
  67. External Pillars
  68. ================
  69. :ref:`External pillars <external-pillars>` are supported when running in masterless mode.