rooted.rst 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. .. _tutorial-rooted:
  2. ====================================
  3. running salt as normal user tutorial
  4. ====================================
  5. .. include:: /_incl/requisite_incl.rst
  6. Running Salt functions as non root user
  7. =======================================
  8. If you don't want to run salt cloud as root or even install it you can
  9. configure it to have a virtual root in your working directory.
  10. The salt system uses the ``salt.syspath`` module to find the variables
  11. If you run the salt-build, it will generated in:
  12. .. code-block:: bash
  13. ./build/lib.linux-x86_64-2.7/salt/_syspaths.py
  14. To generate it, run the command:
  15. .. code-block:: bash
  16. python setup.py build
  17. Copy the generated module into your salt directory
  18. .. code-block:: bash
  19. cp ./build/lib.linux-x86_64-2.7/salt/_syspaths.py salt/_syspaths.py
  20. Edit it to include needed variables and your new paths
  21. .. code-block:: python
  22. # you need to edit this
  23. ROOT_DIR = *your current dir* + '/salt/root'
  24. # you need to edit this
  25. INSTALL_DIR = *location of source code*
  26. CONFIG_DIR = ROOT_DIR + '/etc/salt'
  27. CACHE_DIR = ROOT_DIR + '/var/cache/salt'
  28. SOCK_DIR = ROOT_DIR + '/var/run/salt'
  29. SRV_ROOT_DIR= ROOT_DIR + '/srv'
  30. BASE_FILE_ROOTS_DIR = ROOT_DIR + '/srv/salt'
  31. BASE_PILLAR_ROOTS_DIR = ROOT_DIR + '/srv/pillar'
  32. BASE_MASTER_ROOTS_DIR = ROOT_DIR + '/srv/salt-master'
  33. LOGS_DIR = ROOT_DIR + '/var/log/salt'
  34. PIDFILE_DIR = ROOT_DIR + '/var/run'
  35. CLOUD_DIR = INSTALL_DIR + '/cloud'
  36. BOOTSTRAP = CLOUD_DIR + '/deploy/bootstrap-salt.sh'
  37. Create the directory structure
  38. .. code-block:: bash
  39. mkdir -p root/etc/salt root/var/cache/run root/run/salt root/srv
  40. root/srv/salt root/srv/pillar root/srv/salt-master root/var/log/salt root/var/run
  41. Populate the configuration files:
  42. .. code-block:: bash
  43. cp -r conf/* root/etc/salt/
  44. Edit your ``root/etc/salt/master`` configuration that is used by salt-cloud:
  45. .. code-block:: yaml
  46. user: *your user name*
  47. Run like this:
  48. .. code-block:: bash
  49. PYTHONPATH=`pwd` scripts/salt-cloud