2015-06-05 23:32:35 +00:00
|
|
|
.. _tutorial-standalone-minion:
|
|
|
|
|
2012-05-14 19:33:20 +00:00
|
|
|
=================
|
|
|
|
Standalone Minion
|
|
|
|
=================
|
|
|
|
|
|
|
|
Since the Salt minion contains such extensive functionality it can be useful
|
|
|
|
to run it standalone. A standalone minion can be used to do a number of
|
|
|
|
things:
|
|
|
|
|
|
|
|
- Use salt-call commands on a system without connectivity to a master
|
|
|
|
- Masterless States, run states entirely from files local to the minion
|
|
|
|
|
2014-10-03 05:35:28 +00:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
When running Salt in masterless mode, do not run the salt-minion daemon.
|
|
|
|
Otherwise, it will attempt to connect to a master and fail. The salt-call
|
|
|
|
command stands on its own and does not need the salt-minion daemon.
|
|
|
|
|
2016-05-25 17:00:12 +00:00
|
|
|
|
|
|
|
Minion Configuration
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
Throughout this document there are several references to setting different
|
|
|
|
options to configure a masterless Minion. Salt Minions are easy to configure
|
|
|
|
via a configuration file that is located, by default, in ``/etc/salt/minion``.
|
|
|
|
Note, however, that on FreeBSD systems, the minion configuration file is located
|
|
|
|
in ``/usr/local/etc/salt/minion``.
|
|
|
|
|
|
|
|
You can learn more about minion configuration options in the
|
|
|
|
:ref:`Configuring the Salt Minion <configuration-salt-minion>` docs.
|
|
|
|
|
|
|
|
|
2012-05-14 19:33:20 +00:00
|
|
|
Telling Salt Call to Run Masterless
|
|
|
|
===================================
|
|
|
|
|
|
|
|
The salt-call command is used to run module functions locally on a minion
|
|
|
|
instead of executing them from the master. Normally the salt-call command
|
2013-08-03 23:54:30 +00:00
|
|
|
checks into the master to retrieve file server and pillar data, but when
|
|
|
|
running standalone salt-call needs to be instructed to not check the master for
|
|
|
|
this data. To instruct the minion to not look for a master when running
|
|
|
|
salt-call the :conf_minion:`file_client` configuration option needs to be set.
|
|
|
|
By default the :conf_minion:`file_client` is set to ``remote`` so that the
|
|
|
|
minion knows that file server and pillar data are to be gathered from the
|
|
|
|
master. When setting the :conf_minion:`file_client` option to ``local`` the
|
|
|
|
minion is configured to not gather this data from the master.
|
2012-05-14 19:33:20 +00:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
file_client: local
|
|
|
|
|
|
|
|
Now the salt-call command will not look for a master and will assume that the
|
2014-02-27 15:03:05 +00:00
|
|
|
local system has all of the file and pillar resources.
|
2012-05-14 19:33:20 +00:00
|
|
|
|
2013-01-19 06:33:03 +00:00
|
|
|
|
2012-05-14 19:33:20 +00:00
|
|
|
Running States Masterless
|
|
|
|
=========================
|
|
|
|
|
2012-05-23 04:43:12 +00:00
|
|
|
The state system can be easily run without a Salt master, with all needed files
|
|
|
|
local to the minion. To do this the minion configuration file needs to be set
|
|
|
|
up to know how to return file_roots information like the master. The file_roots
|
2012-05-14 19:33:20 +00:00
|
|
|
setting defaults to /srv/salt for the base environment just like on the master:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
file_roots:
|
|
|
|
base:
|
|
|
|
- /srv/salt
|
|
|
|
|
2012-05-23 04:43:12 +00:00
|
|
|
Now set up the Salt State Tree, top file, and SLS modules in the same way that
|
2013-08-03 23:54:30 +00:00
|
|
|
they would be set up on a master. Now, with the :conf_minion:`file_client`
|
|
|
|
option set to ``local`` and an available state tree then calls to functions in
|
|
|
|
the state module will use the information in the file_roots on the minion
|
|
|
|
instead of checking in with the master.
|
2012-05-14 19:33:20 +00:00
|
|
|
|
|
|
|
Remember that when creating a state tree on a minion there are no syntax or
|
2012-05-23 04:43:12 +00:00
|
|
|
path changes needed, SLS modules written to be used from a master do not need
|
2012-05-14 19:33:20 +00:00
|
|
|
to be modified in any way to work with a minion.
|
|
|
|
|
2012-05-23 04:43:12 +00:00
|
|
|
This makes it easy to "script" deployments with Salt states without having to
|
|
|
|
set up a master, and allows for these SLS modules to be easily moved into a
|
|
|
|
Salt master as the deployment grows.
|
2013-01-19 04:50:08 +00:00
|
|
|
|
2014-02-27 15:03:05 +00:00
|
|
|
The declared state can now be executed with:
|
2013-01-19 04:50:08 +00:00
|
|
|
|
2013-08-12 03:17:47 +00:00
|
|
|
.. code-block:: bash
|
2013-01-19 04:50:08 +00:00
|
|
|
|
2016-03-22 03:56:17 +00:00
|
|
|
salt-call state.apply
|
2013-08-12 03:17:47 +00:00
|
|
|
|
|
|
|
Or the salt-call command can be executed with the ``--local`` flag, this makes
|
|
|
|
it unnecessary to change the configuration file:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2016-03-22 03:56:17 +00:00
|
|
|
salt-call state.apply --local
|
2015-06-05 23:32:35 +00:00
|
|
|
|
2016-05-25 17:00:12 +00:00
|
|
|
|
2015-06-05 23:32:35 +00:00
|
|
|
External Pillars
|
|
|
|
================
|
|
|
|
|
|
|
|
:ref:`External pillars <external-pillars>` are supported when running in masterless mode.
|
|
|
|
|