2014-03-05 18:09:07 +00:00
|
|
|
.. _installing-for-development:
|
|
|
|
|
2012-10-03 19:57:36 +00:00
|
|
|
Installing Salt for development
|
2014-04-22 22:22:11 +00:00
|
|
|
===============================
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2013-08-11 02:55:51 +00:00
|
|
|
Clone the repository using:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2012-10-03 19:57:36 +00:00
|
|
|
|
|
|
|
git clone https://github.com/saltstack/salt
|
2013-01-24 06:34:05 +00:00
|
|
|
|
2013-01-17 00:42:32 +00:00
|
|
|
.. note:: tags
|
|
|
|
|
|
|
|
Just cloning the repository is enough to work with Salt and make
|
2013-02-06 18:37:20 +00:00
|
|
|
contributions. However, fetching additional tags from git is required to
|
|
|
|
have Salt report the correct version for itself. To do this, first
|
2013-08-11 02:55:51 +00:00
|
|
|
add the git repository as an upstream source:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2013-01-17 00:42:32 +00:00
|
|
|
|
2014-02-20 23:16:59 +00:00
|
|
|
git remote add upstream https://github.com/saltstack/salt
|
2013-01-17 00:42:32 +00:00
|
|
|
|
2013-08-11 02:55:51 +00:00
|
|
|
Fetching tags is done with the git 'fetch' utility:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2013-01-17 00:42:32 +00:00
|
|
|
|
|
|
|
git fetch --tags upstream
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2013-08-11 02:55:51 +00:00
|
|
|
Create a new `virtualenv`_:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2012-10-03 19:57:36 +00:00
|
|
|
|
|
|
|
virtualenv /path/to/your/virtualenv
|
|
|
|
|
2014-02-20 23:16:59 +00:00
|
|
|
.. _`virtualenv`: https://pypi.python.org/pypi/virtualenv
|
2012-12-22 00:23:33 +00:00
|
|
|
|
2015-01-07 21:24:31 +00:00
|
|
|
Avoid making your :ref:`virtualenv path too long <too_long_socket_path>`.
|
|
|
|
On Arch Linux, where Python 3 is the default installation of Python, use
|
|
|
|
the ``virtualenv2`` command instead of ``virtualenv``.
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2013-02-06 18:37:20 +00:00
|
|
|
.. note:: Using system Python modules in the virtualenv
|
2012-12-21 22:00:50 +00:00
|
|
|
|
2013-02-06 18:37:20 +00:00
|
|
|
To use already-installed python modules in virtualenv (instead of having pip
|
|
|
|
download and compile new ones), run ``virtualenv --system-site-packages``
|
|
|
|
Using this method eliminates the requirement to install the salt dependencies
|
|
|
|
again, although it does assume that the listed modules are all installed in the
|
|
|
|
system PYTHONPATH at the time of virtualenv creation.
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2013-08-11 02:55:51 +00:00
|
|
|
Activate the virtualenv:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2012-10-03 19:57:36 +00:00
|
|
|
|
|
|
|
source /path/to/your/virtualenv/bin/activate
|
|
|
|
|
2013-08-11 02:55:51 +00:00
|
|
|
Install Salt (and dependencies) into the virtualenv:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2012-12-27 02:44:15 +00:00
|
|
|
pip install M2Crypto # Don't install on Debian/Ubuntu (see below)
|
|
|
|
pip install pyzmq PyYAML pycrypto msgpack-python jinja2 psutil
|
|
|
|
pip install -e ./salt # the path to the salt git clone from above
|
2012-10-03 19:57:36 +00:00
|
|
|
|
|
|
|
.. note:: Installing M2Crypto
|
|
|
|
|
2013-02-06 18:37:20 +00:00
|
|
|
``swig`` and ``libssl-dev`` are required to build M2Crypto. To fix
|
2013-10-23 15:05:56 +00:00
|
|
|
the error ``command 'swig' failed with exit status 1`` while installing M2Crypto,
|
2013-08-11 02:55:51 +00:00
|
|
|
try installing it with the following command:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2012-10-03 19:57:36 +00:00
|
|
|
|
|
|
|
env SWIG_FEATURES="-cpperraswarn -includeall -D__`uname -m`__ -I/usr/include/openssl" pip install M2Crypto
|
|
|
|
|
|
|
|
Debian and Ubuntu systems have modified openssl libraries and mandate that
|
|
|
|
a patched version of M2Crypto be installed. This means that M2Crypto
|
2013-08-11 02:55:51 +00:00
|
|
|
needs to be installed via apt:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2012-10-03 19:57:36 +00:00
|
|
|
|
|
|
|
apt-get install python-m2crypto
|
|
|
|
|
2013-02-06 18:37:20 +00:00
|
|
|
This also means that pulling in the M2Crypto installed using apt requires using
|
|
|
|
``--system-site-packages`` when creating the virtualenv.
|
2012-12-22 00:23:33 +00:00
|
|
|
|
2013-12-21 17:45:21 +00:00
|
|
|
If you're using a platform other than Debian or Ubuntu, and you are
|
|
|
|
installing M2Crypto via pip instead of a system package, then you will also
|
|
|
|
need the ``gcc`` compiler.
|
|
|
|
|
2013-03-24 16:51:51 +00:00
|
|
|
.. note:: Installing psutil
|
|
|
|
|
|
|
|
Python header files are required to build this module, otherwise the pip
|
|
|
|
install will fail. If your distribution separates binaries and headers into
|
|
|
|
separate packages, make sure that you have the headers installed. In most
|
|
|
|
Linux distributions which split the headers into their own package, this
|
|
|
|
can be done by installing the ``python-dev`` or ``python-devel`` package.
|
|
|
|
For other platforms, the package will likely be similarly named.
|
|
|
|
|
2012-12-22 00:23:33 +00:00
|
|
|
.. _`RHEL`: https://www.redhat.com/products/enterprise-linux/
|
|
|
|
.. _`CentOS`: http://centos.org/
|
|
|
|
.. _`Fedora Linux`: http://fedoraproject.org/
|
|
|
|
.. _`Amazon Linux`: https://aws.amazon.com/amazon-linux-ami/
|
|
|
|
|
2013-02-02 08:06:40 +00:00
|
|
|
.. note:: Installing dependencies on OS X.
|
|
|
|
|
2013-02-06 18:37:20 +00:00
|
|
|
You can install needed dependencies on OS X using homebrew or macports.
|
2013-02-07 23:58:26 +00:00
|
|
|
See :doc:`OS X Installation </topics/installation/osx>`
|
2012-12-22 00:23:33 +00:00
|
|
|
|
2014-03-05 18:09:07 +00:00
|
|
|
.. warning:: Installing on RedHat-based Distros
|
|
|
|
|
|
|
|
If installing from pip (or from source using ``setup.py install``), be
|
|
|
|
advised that the ``yum-utils`` package is needed for Salt to manage
|
|
|
|
packages on RedHat-based systems.
|
|
|
|
|
2012-10-03 19:57:36 +00:00
|
|
|
Running a self-contained development version
|
2014-04-22 22:22:11 +00:00
|
|
|
--------------------------------------------
|
2012-10-03 19:57:36 +00:00
|
|
|
|
|
|
|
During development it is easiest to be able to run the Salt master and minion
|
|
|
|
that are installed in the virtualenv you created above, and also to have all
|
|
|
|
the configuration, log, and cache files contained in the virtualenv as well.
|
|
|
|
|
2013-08-11 02:55:51 +00:00
|
|
|
Copy the master and minion config files into your virtualenv:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2012-10-03 19:57:36 +00:00
|
|
|
|
|
|
|
mkdir -p /path/to/your/virtualenv/etc/salt
|
2015-01-07 20:41:19 +00:00
|
|
|
cp ./salt/conf/master ./salt/conf/minion /path/to/your/virtualenv/etc/salt/
|
2012-10-03 19:57:36 +00:00
|
|
|
|
|
|
|
Edit the master config file:
|
|
|
|
|
|
|
|
1. Uncomment and change the ``user: root`` value to your own user.
|
|
|
|
2. Uncomment and change the ``root_dir: /`` value to point to
|
|
|
|
``/path/to/your/virtualenv``.
|
2014-12-12 19:39:40 +00:00
|
|
|
3. If you are running version 0.11.1 or older, uncomment, and change the
|
2012-12-27 17:51:56 +00:00
|
|
|
``pidfile: /var/run/salt-master.pid`` value to point to
|
2012-12-28 05:32:48 +00:00
|
|
|
``/path/to/your/virtualenv/salt-master.pid``.
|
2012-12-16 08:17:44 +00:00
|
|
|
4. If you are also running a non-development version of Salt you will have to
|
2012-10-03 19:57:36 +00:00
|
|
|
change the ``publish_port`` and ``ret_port`` values as well.
|
|
|
|
|
|
|
|
Edit the minion config file:
|
|
|
|
|
|
|
|
1. Repeat the edits you made in the master config for the ``user`` and
|
|
|
|
``root_dir`` values as well as any port changes.
|
2014-12-12 19:39:40 +00:00
|
|
|
2. If you are running version 0.11.1 or older, uncomment, and change the
|
2012-12-27 17:51:56 +00:00
|
|
|
``pidfile: /var/run/salt-minion.pid`` value to point to
|
2012-12-28 05:32:48 +00:00
|
|
|
``/path/to/your/virtualenv/salt-minion.pid``.
|
2012-12-16 08:17:44 +00:00
|
|
|
3. Uncomment and change the ``master: salt`` value to point at ``localhost``.
|
|
|
|
4. Uncomment and change the ``id:`` value to something descriptive like
|
2012-10-03 19:57:36 +00:00
|
|
|
"saltdev". This isn't strictly necessary but it will serve as a reminder of
|
|
|
|
which Salt installation you are working with.
|
2014-02-11 05:09:24 +00:00
|
|
|
5. If you changed the ``ret_port`` value in the master config because you are
|
|
|
|
also running a non-development version of Salt, then you will have to
|
|
|
|
change the ``master_port`` value in the minion config to match.
|
2012-10-03 19:57:36 +00:00
|
|
|
|
|
|
|
.. note:: Using `salt-call` with a :doc:`Standalone Minion </topics/tutorials/standalone_minion>`
|
|
|
|
|
|
|
|
If you plan to run `salt-call` with this self-contained development
|
|
|
|
environment in a masterless setup, you should invoke `salt-call` with
|
|
|
|
``-c /path/to/your/virtualenv/etc/salt`` so that salt can find the minion
|
2012-12-16 07:13:32 +00:00
|
|
|
config file. Without the ``-c`` option, Salt finds its config files in
|
|
|
|
`/etc/salt`.
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2013-05-01 23:06:17 +00:00
|
|
|
Start the master and minion, accept the minion's key, and verify your local Salt
|
2013-08-11 02:55:51 +00:00
|
|
|
installation is working:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2012-12-16 07:03:47 +00:00
|
|
|
cd /path/to/your/virtualenv
|
2012-12-16 08:17:44 +00:00
|
|
|
salt-master -c ./etc/salt -d
|
|
|
|
salt-minion -c ./etc/salt -d
|
2012-10-03 19:57:36 +00:00
|
|
|
salt-key -c ./etc/salt -L
|
|
|
|
salt-key -c ./etc/salt -A
|
|
|
|
salt -c ./etc/salt '*' test.ping
|
|
|
|
|
2012-12-16 18:57:00 +00:00
|
|
|
Running the master and minion in debug mode can be helpful when developing. To
|
|
|
|
do this, add ``-l debug`` to the calls to ``salt-master`` and ``salt-minion``.
|
|
|
|
If you would like to log to the console instead of to the log file, remove the
|
|
|
|
``-d``.
|
2012-12-16 06:45:50 +00:00
|
|
|
|
2015-01-07 21:24:31 +00:00
|
|
|
.. _too_long_socket_path:
|
2015-01-07 21:20:50 +00:00
|
|
|
.. note:: Too long socket path?
|
2014-07-06 03:51:05 +00:00
|
|
|
|
2015-01-07 21:20:50 +00:00
|
|
|
Once the minion starts, you may see an error like the following:
|
2016-03-01 15:36:23 +00:00
|
|
|
|
2015-01-07 21:20:50 +00:00
|
|
|
.. code-block:: bash
|
2016-03-01 15:36:23 +00:00
|
|
|
|
2015-01-07 21:20:50 +00:00
|
|
|
zmq.core.error.ZMQError: ipc path "/path/to/your/virtualenv/
|
|
|
|
var/run/salt/minion/minion_event_7824dcbcfd7a8f6755939af70b96249f_pub.ipc"
|
|
|
|
is longer than 107 characters (sizeof(sockaddr_un.sun_path)).
|
2016-03-01 15:36:23 +00:00
|
|
|
|
2015-01-07 21:20:50 +00:00
|
|
|
This means that the path to the socket the minion is using is too long. This is
|
|
|
|
a system limitation, so the only workaround is to reduce the length of this
|
|
|
|
path. This can be done in a couple different ways:
|
2016-03-01 15:36:23 +00:00
|
|
|
|
2015-01-07 21:20:50 +00:00
|
|
|
1. Create your virtualenv in a path that is short enough.
|
|
|
|
2. Edit the :conf_minion:`sock_dir` minion config variable and reduce its
|
|
|
|
length. Remember that this path is relative to the value you set in
|
|
|
|
:conf_minion:`root_dir`.
|
2016-03-01 15:36:23 +00:00
|
|
|
|
2015-01-07 21:20:50 +00:00
|
|
|
``NOTE:`` The socket path is limited to 107 characters on Solaris and Linux,
|
|
|
|
and 103 characters on BSD-based systems.
|
2012-12-27 02:44:15 +00:00
|
|
|
|
2013-02-06 18:37:20 +00:00
|
|
|
.. note:: File descriptor limits
|
2012-12-27 02:44:15 +00:00
|
|
|
|
2013-08-11 02:55:51 +00:00
|
|
|
Ensure that the system open file limit is raised to at least 2047:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2013-02-06 18:37:20 +00:00
|
|
|
# check your current limit
|
|
|
|
ulimit -n
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2013-02-06 18:37:20 +00:00
|
|
|
# raise the limit. persists only until reboot
|
|
|
|
# use 'limit descriptors 2047' for c-shell
|
|
|
|
ulimit -n 2047
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2013-08-11 02:55:51 +00:00
|
|
|
To set file descriptors on OSX, refer to the :doc:`OS X Installation
|
|
|
|
</topics/installation/osx>` instructions.
|
2012-10-03 19:57:36 +00:00
|
|
|
|
2013-04-07 22:05:31 +00:00
|
|
|
|
2015-08-14 21:05:29 +00:00
|
|
|
Changing Default Paths
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Instead of updating your configuration files to point to the new root directory
|
|
|
|
and having to pass the new configuration directory path to all of Salt's CLI
|
|
|
|
tools, you can explicitly tweak the default system paths that Salt expects:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2015-10-17 16:35:18 +00:00
|
|
|
GENERATE_SALT_SYSPATHS=1 pip install --global-option='--salt-root-dir=/path/to/your/virtualenv/' \
|
|
|
|
-e ./salt # the path to the salt git clone from above
|
2015-08-14 21:05:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
You can now call all of Salt's CLI tools without explicitly passing the configuration directory.
|
|
|
|
|
|
|
|
Additional Options
|
|
|
|
..................
|
|
|
|
|
2017-02-09 18:02:29 +00:00
|
|
|
If you want to distribute your virtualenv, you probably don't want to
|
2015-08-14 21:05:29 +00:00
|
|
|
include Salt's clone ``.git/`` directory, and, without it, Salt won't report
|
|
|
|
the accurate version. You can tell ``setup.py`` to generate the hardcoded
|
|
|
|
version information which is distributable:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2015-10-17 16:35:18 +00:00
|
|
|
GENERATE_SALT_SYSPATHS=1 WRITE_SALT_VERSION=1 pip install --global-option='--salt-root-dir=/path/to/your/virtualenv/' \
|
|
|
|
-e ./salt # the path to the salt git clone from above
|
2015-08-14 21:05:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
Instead of passing those two environmental variables, you can just pass a
|
|
|
|
single one which will trigger the other two:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2015-10-17 16:35:18 +00:00
|
|
|
MIMIC_SALT_INSTALL=1 pip install --global-option='--salt-root-dir=/path/to/your/virtualenv/' \
|
|
|
|
-e ./salt # the path to the salt git clone from above
|
2015-08-14 21:05:29 +00:00
|
|
|
|
|
|
|
|
2015-11-04 10:02:32 +00:00
|
|
|
This last one will grant you an editable salt installation with hardcoded
|
2015-08-14 21:05:29 +00:00
|
|
|
system paths and version information.
|
|
|
|
|
|
|
|
|
2013-11-11 14:42:02 +00:00
|
|
|
Installing Salt from the Python Package Index
|
|
|
|
---------------------------------------------
|
2013-04-07 22:05:31 +00:00
|
|
|
|
|
|
|
If you are installing using ``easy_install``, you will need to define a
|
|
|
|
:strong:`USE_SETUPTOOLS` environment variable, otherwise dependencies will not
|
2013-08-11 02:55:51 +00:00
|
|
|
be installed:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2013-04-07 22:05:31 +00:00
|
|
|
|
2013-08-11 02:55:51 +00:00
|
|
|
USE_SETUPTOOLS=1 easy_install salt
|
2013-04-07 22:05:31 +00:00
|
|
|
|
2013-07-20 17:19:50 +00:00
|
|
|
|
|
|
|
Editing and previewing the documentation
|
|
|
|
----------------------------------------
|
2013-01-23 11:09:36 +00:00
|
|
|
|
2013-06-14 02:05:19 +00:00
|
|
|
You need ``sphinx-build`` command to build the docs. In Debian/Ubuntu this is
|
2014-11-26 19:23:13 +00:00
|
|
|
provided in the ``python-sphinx`` package. Sphinx can also be installed
|
|
|
|
to a virtualenv using pip:
|
2013-08-11 02:55:51 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
2013-01-23 11:09:36 +00:00
|
|
|
|
2015-01-08 07:04:11 +00:00
|
|
|
pip install Sphinx==1.3b2
|
2013-01-23 11:09:36 +00:00
|
|
|
|
2013-08-11 02:55:51 +00:00
|
|
|
Change to salt documentation directory, then:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2013-01-23 11:09:36 +00:00
|
|
|
|
|
|
|
cd doc; make html
|
|
|
|
|
2013-06-14 01:29:17 +00:00
|
|
|
- This will build the HTML docs. Run ``make`` without any arguments to see the
|
|
|
|
available make targets, which include :strong:`html`, :strong:`man`, and
|
|
|
|
:strong:`text`.
|
2013-06-14 02:05:19 +00:00
|
|
|
- The docs then are built within the :strong:`docs/_build/` folder. To update
|
|
|
|
the docs after making changes, run ``make`` again.
|
2013-01-23 11:09:36 +00:00
|
|
|
- The docs use `reStructuredText <http://sphinx-doc.org/rest.html>`_ for markup.
|
|
|
|
See a live demo at http://rst.ninjs.org/.
|
|
|
|
- The help information on each module or state is culled from the python code
|
|
|
|
that runs for that piece. Find them in ``salt/modules/`` or ``salt/states/``.
|
2013-06-14 01:29:17 +00:00
|
|
|
|
2013-06-14 02:05:19 +00:00
|
|
|
- To build the docs on Arch Linux, the :strong:`python2-sphinx` package is
|
|
|
|
required. Additionally, it is necessary to tell :strong:`make` where to find
|
2013-08-11 02:55:51 +00:00
|
|
|
the proper :strong:`sphinx-build` binary, like so:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2013-01-23 11:09:36 +00:00
|
|
|
|
|
|
|
make SPHINXBUILD=sphinx-build2 html
|
2013-06-14 01:29:17 +00:00
|
|
|
|
2013-06-14 02:05:19 +00:00
|
|
|
- To build the docs on RHEL/CentOS 6, the :strong:`python-sphinx10` package
|
2013-08-11 02:55:51 +00:00
|
|
|
must be installed from EPEL, and the following make command must be used:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
2013-06-14 01:29:17 +00:00
|
|
|
|
|
|
|
make SPHINXBUILD=sphinx-1.0-build html
|
2013-10-23 05:22:17 +00:00
|
|
|
|
|
|
|
Once you've updated the documentation, you can run the following command to
|
2013-10-25 06:31:13 +00:00
|
|
|
launch a simple Python HTTP server to see your changes:
|
2013-10-23 05:22:17 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
cd _build/html; python -m SimpleHTTPServer
|
2013-11-11 15:58:05 +00:00
|
|
|
|
|
|
|
Running unit and integration tests
|
|
|
|
----------------------------------
|
|
|
|
|
|
|
|
Run the test suite with following command:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
./setup.py test
|
|
|
|
|
|
|
|
See :doc:`here <tests/index>` for more information regarding the test suite.
|
2015-05-05 19:23:08 +00:00
|
|
|
|
|
|
|
Issue and Pull Request Labeling System
|
|
|
|
--------------------------------------
|
|
|
|
|
|
|
|
SaltStack uses several labeling schemes to help facilitate code contributions
|
2015-06-24 22:56:52 +00:00
|
|
|
and bug resolution. See the :ref:`Labels and Milestones
|
|
|
|
<labels-and-milestones>` documentation for more information.
|