rooted.rst 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. _your_current_dir_ = ...
  24. ROOT_DIR = _your_current_dir_ + "/salt/root"
  25. # you need to edit this
  26. _location_of_source_code_ = ...
  27. INSTALL_DIR = _location_of_source_code_
  28. CONFIG_DIR = ROOT_DIR + "/etc/salt"
  29. CACHE_DIR = ROOT_DIR + "/var/cache/salt"
  30. SOCK_DIR = ROOT_DIR + "/var/run/salt"
  31. SRV_ROOT_DIR = ROOT_DIR + "/srv"
  32. BASE_FILE_ROOTS_DIR = ROOT_DIR + "/srv/salt"
  33. BASE_PILLAR_ROOTS_DIR = ROOT_DIR + "/srv/pillar"
  34. BASE_MASTER_ROOTS_DIR = ROOT_DIR + "/srv/salt-master"
  35. LOGS_DIR = ROOT_DIR + "/var/log/salt"
  36. PIDFILE_DIR = ROOT_DIR + "/var/run"
  37. CLOUD_DIR = INSTALL_DIR + "/cloud"
  38. BOOTSTRAP = CLOUD_DIR + "/deploy/bootstrap-salt.sh"
  39. Create the directory structure
  40. .. code-block:: bash
  41. mkdir -p root/etc/salt root/var/cache/run root/run/salt root/srv
  42. root/srv/salt root/srv/pillar root/srv/salt-master root/var/log/salt root/var/run
  43. Populate the configuration files:
  44. .. code-block:: bash
  45. cp -r conf/* root/etc/salt/
  46. Edit your ``root/etc/salt/master`` configuration that is used by salt-cloud:
  47. .. code-block:: yaml
  48. user: *your user name*
  49. Run like this:
  50. .. code-block:: bash
  51. PYTHONPATH=`pwd` scripts/salt-cloud