salt/doc/topics/tutorials/quickstart.rst

86 lines
2.6 KiB
ReStructuredText
Raw Normal View History

2012-12-13 23:07:10 +00:00
==========================
Salt Masterless Quickstart
==========================
.. _`Vagrant`: http://www.vagrantup.com/
.. _`salty-vagrant`: https://github.com/saltstack/salty-vagrant
.. _`salt-bootstrap`: https://github.com/saltstack/salt-bootstrap
Running a master-less salt-minion lets you use Salt's configuration management
for a single machine without calling out to a Salt master on another machine.
It is also useful for testing out state trees before deploying to a production setup.
2012-12-13 23:07:10 +00:00
The only real difference in using a standalone minion is that instead of issuing
commands with ``salt``, the ``salt-call`` command is used instead:
.. code-block:: bash
2012-12-13 23:07:10 +00:00
salt-call --local state.highstate
Bootstrap Salt Minion
=====================
2014-04-30 20:55:30 +00:00
The `salt-bootstrap`_ script makes bootstrapping a server with Salt simple
for any OS with a Bourne shell:
.. code-block:: bash
2012-12-13 23:07:10 +00:00
wget -O - https://raw.githubusercontent.com/saltstack/salt-bootstrap/stable/bootstrap-salt.sh | sudo sh
2012-12-13 23:07:10 +00:00
See the `salt-bootstrap`_ documentation for other one liners. When using `Vagrant`_
to test out salt, the `salty-vagrant`_ tool will provision the VM for you.
2012-12-13 23:07:10 +00:00
Create State Tree
=================
Following the successful installation of a salt-minion, the next step is to create
a state tree, which is where the SLS files that comprise the possible states of the
minion are stored.
The following example walks through the steps necessary to create a state tree that
ensures that the server has the Apache webserver installed.
.. note:::
For a complete explanation on Salt States, see the `tutorial
<http://docs.saltstack.org/en/latest/topics/tutorials/states_pt1.html>`_.
1. Create the ``top.sls`` file:
``/srv/salt/top.sls:``
.. code-block:: yaml
2012-12-13 23:07:10 +00:00
base:
'*':
- webserver
2013-01-24 06:34:05 +00:00
2. Create the webserver state tree:
2012-12-13 23:07:10 +00:00
``/srv/salt/webserver.sls:``
2013-01-24 06:34:05 +00:00
.. code-block:: yaml
apache: # ID declaration
pkg: # state declaration
- installed # function declaration
2012-12-13 23:07:10 +00:00
The only thing left is to provision our minion using the highstate command.
To initiate a highstate run, use the ``salt-call`` command:
.. code-block:: bash
2012-12-13 23:07:10 +00:00
salt-call --local state.highstate -l debug
The ``--local`` flag tells the salt-minion to look for the state tree in the
local file system and not to contact a Salt Master for instructions.
To provide verbose output, used ``-l debug``.
The minion first examines the ``top.sls`` file and determines that it is a part
of the group matched by ``*`` glob and that the ``webserver`` SLS should be applied.
It then examines the ``webserver.sls`` file and finds the ``apache`` state, which
installs the Apache package.
2012-12-13 23:07:10 +00:00