1
0

quickstart.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. .. _masterless-quickstart:
  2. ==========================
  3. Salt Masterless Quickstart
  4. ==========================
  5. .. _`Vagrant`: http://www.vagrantup.com/
  6. .. _`Vagrant salt provisioner`: http://docs.vagrantup.com/v2/provisioning/salt.html
  7. .. _`salt-bootstrap`: https://github.com/saltstack/salt-bootstrap
  8. Running a masterless salt-minion lets you use Salt's configuration management
  9. for a single machine without calling out to a Salt master on another machine.
  10. Since the Salt minion contains such extensive functionality it can be useful
  11. to run it standalone. A standalone minion can be used to do a number of
  12. things:
  13. - Stand up a master server via States (Salting a Salt Master)
  14. - Use salt-call commands on a system without connectivity to a master
  15. - Masterless States, run states entirely from files local to the minion
  16. It is also useful for testing out state trees before deploying to a production setup.
  17. Bootstrap Salt Minion
  18. =====================
  19. The `salt-bootstrap`_ script makes bootstrapping a server with Salt simple
  20. for any OS with a Bourne shell:
  21. .. code-block:: bash
  22. curl -L https://bootstrap.saltstack.com -o bootstrap_salt.sh
  23. sudo sh bootstrap_salt.sh
  24. See the `salt-bootstrap`_ documentation for other one liners. When using `Vagrant`_
  25. to test out salt, the `Vagrant salt provisioner`_ will provision the VM for you.
  26. Telling Salt to Run Masterless
  27. ==============================
  28. To instruct the minion to not look for a master, the :conf_minion:`file_client`
  29. configuration option needs to be set in the minion configuration file.
  30. By default the :conf_minion:`file_client` is set to ``remote`` so that the
  31. minion gathers file server and pillar data from the salt master.
  32. When setting the :conf_minion:`file_client` option to ``local`` the
  33. minion is configured to not gather this data from the master.
  34. .. code-block:: yaml
  35. file_client: local
  36. Now the salt minion will not look for a master and will assume that the local
  37. system has all of the file and pillar resources.
  38. Configuration which resided in the
  39. :ref:`master configuration <configuration-salt-master>` (e.g. ``/etc/salt/master``)
  40. should be moved to the :ref:`minion configuration <configuration-salt-minion>`
  41. since the minion does not read the master configuration.
  42. .. note::
  43. When running Salt in masterless mode, do not run the salt-minion daemon.
  44. Otherwise, it will attempt to connect to a master and fail. The salt-call
  45. command stands on its own and does not need the salt-minion daemon.
  46. Create State Tree
  47. =================
  48. Following the successful installation of a salt-minion, the next step is to create
  49. a state tree, which is where the SLS files that comprise the possible states of the
  50. minion are stored.
  51. The following example walks through the steps necessary to create a state tree that
  52. ensures that the server has the Apache webserver installed.
  53. .. note::
  54. For a complete explanation on Salt States, see the `tutorial
  55. <http://docs.saltstack.com/en/latest/topics/tutorials/states_pt1.html>`_.
  56. 1. Create the ``top.sls`` file:
  57. ``/srv/salt/top.sls:``
  58. .. code-block:: yaml
  59. base:
  60. '*':
  61. - webserver
  62. 2. Create the webserver state tree:
  63. ``/srv/salt/webserver.sls:``
  64. .. code-block:: yaml
  65. apache: # ID declaration
  66. pkg: # state declaration
  67. - installed # function declaration
  68. .. note::
  69. The apache package has different names on different platforms, for
  70. instance on Debian/Ubuntu it is apache2, on Fedora/RHEL it is httpd
  71. and on Arch it is apache
  72. The only thing left is to provision our minion using ``salt-call``.
  73. Salt-call
  74. ---------
  75. The salt-call command is used to run remote execution functions locally on a
  76. minion instead of executing them from the master. Normally the salt-call
  77. command checks into the master to retrieve file server and pillar data, but
  78. when running standalone salt-call needs to be instructed to not check the
  79. master for this data:
  80. .. code-block:: bash
  81. salt-call --local state.apply
  82. The ``--local`` flag tells the salt-minion to look for the state tree in the
  83. local file system and not to contact a Salt Master for instructions.
  84. To provide verbose output, use ``-l debug``:
  85. .. code-block:: bash
  86. salt-call --local state.apply -l debug
  87. The minion first examines the ``top.sls`` file and determines that it is a part
  88. of the group matched by ``*`` glob and that the ``webserver`` SLS should be applied.
  89. It then examines the ``webserver.sls`` file and finds the ``apache`` state, which
  90. installs the Apache package.
  91. The minion should now have Apache installed, and the next step is to begin
  92. learning how to write :ref:`more complex states<states-tutorial>`.