2016-12-15 22:36:44 +00:00
|
|
|
.. _tutorial-rooted:
|
|
|
|
|
2014-12-20 16:45:09 +00:00
|
|
|
====================================
|
|
|
|
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
|
2014-12-20 16:45:09 +00:00
|
|
|
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
|
2014-12-20 16:45:09 +00:00
|
|
|
|
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:
|
2014-12-20 16:45:09 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
python setup.py build
|
|
|
|
|
2015-01-07 20:58:40 +00:00
|
|
|
Copy the generated module into your salt directory
|
2014-12-20 16:45:09 +00:00
|
|
|
|
|
|
|
.. 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
|
2014-12-20 16:45:09 +00:00
|
|
|
|
|
|
|
.. 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:
|
2014-12-20 16:45:09 +00:00
|
|
|
|
|
|
|
.. 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
|
2014-12-20 16:45:09 +00:00
|
|
|
|
|
|
|
user: *your user name*
|
|
|
|
|
2015-01-07 20:58:40 +00:00
|
|
|
Run like this:
|
2014-12-20 16:45:09 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
PYTHONPATH=`pwd` scripts/salt-cloud
|