salt/doc/topics/tutorials/rooted.rst

81 lines
2.0 KiB
ReStructuredText
Raw Normal View History

====================================
running salt as normal user tutorial
====================================
.. include:: /_incl/requisite_incl.rst
Running Salt functions as non root user
=======================================
2015-11-03 16:40:56 +00:00
If you don't want to run salt cloud as root or even install it you can
configure it to have a virtual root in your working directory.
2015-01-07 20:58:40 +00:00
The salt system uses the ``salt.syspath`` module to find the variables
2015-01-07 20:58:40 +00:00
If you run the salt-build, it will generated in:
.. code-block:: bash
./build/lib.linux-x86_64-2.7/salt/_syspaths.py
To generate it, run the command:
.. code-block:: bash
python setup.py build
2015-01-07 20:58:40 +00:00
Copy the generated module into your salt directory
.. code-block:: bash
cp ./build/lib.linux-x86_64-2.7/salt/_syspaths.py salt/_syspaths.py
2015-01-07 20:58:40 +00:00
Edit it to include needed variables and your new paths
.. code-block:: python
# you need to edit this
ROOT_DIR = *your current dir* + '/salt/root'
# you need to edit this
INSTALL_DIR = *location of source code*
CONFIG_DIR = ROOT_DIR + '/etc/salt'
CACHE_DIR = ROOT_DIR + '/var/cache/salt'
SOCK_DIR = ROOT_DIR + '/var/run/salt'
SRV_ROOT_DIR= ROOT_DIR + '/srv'
BASE_FILE_ROOTS_DIR = ROOT_DIR + '/srv/salt'
BASE_PILLAR_ROOTS_DIR = ROOT_DIR + '/srv/pillar'
BASE_MASTER_ROOTS_DIR = ROOT_DIR + '/srv/salt-master'
LOGS_DIR = ROOT_DIR + '/var/log/salt'
PIDFILE_DIR = ROOT_DIR + '/var/run'
CLOUD_DIR = INSTALL_DIR + '/cloud'
BOOTSTRAP = CLOUD_DIR + '/deploy/bootstrap-salt.sh'
Create the directory structure
.. code-block:: bash
mkdir -p root/etc/salt root/var/cache/run root/run/salt root/srv
root/srv/salt root/srv/pillar root/srv/salt-master root/var/log/salt root/var/run
2015-01-07 20:58:40 +00:00
Populate the configuration files:
.. code-block:: bash
cp -r conf/* root/etc/salt/
2015-01-07 20:58:40 +00:00
Edit your ``root/etc/salt/master`` configuration that is used by salt-cloud:
.. code-block:: yaml
user: *your user name*
2015-01-07 20:58:40 +00:00
Run like this:
.. code-block:: bash
PYTHONPATH=`pwd` scripts/salt-cloud