2012-07-01 00:26:47 +00:00
|
|
|
Developing Salt
|
|
|
|
===============
|
|
|
|
|
|
|
|
If you want to help develop Salt there is a great need and your patches are
|
|
|
|
welcome!
|
|
|
|
|
|
|
|
To assist in Salt development, you can help in a number of ways.
|
|
|
|
|
|
|
|
Setting a Github pull request
|
|
|
|
-----------------------------
|
|
|
|
|
2012-07-04 19:00:51 +00:00
|
|
|
This is the preferred method for contributions, simply create a Github
|
2012-07-01 00:26:47 +00:00
|
|
|
fork, commit your changes to the fork, and then open up a pull request.
|
|
|
|
|
2012-07-04 19:00:51 +00:00
|
|
|
Posting patches to the mailing list
|
|
|
|
-----------------------------------
|
|
|
|
|
|
|
|
If you have a patch for Salt, please format it via :command:`git format-patch`
|
|
|
|
and send it to the Salt users mailing list. This allows the patch to give you
|
|
|
|
the contributor the credit for your patch, and gives the Salt community an
|
|
|
|
archive of the patch and a place for discussion.
|
|
|
|
|
2012-07-01 00:26:47 +00:00
|
|
|
Contributions Welcome!
|
|
|
|
----------------------
|
|
|
|
|
2012-07-16 14:15:49 +00:00
|
|
|
The goal here is to make contributions clear, make sure there is a trail for
|
2012-07-01 00:26:47 +00:00
|
|
|
where the code has come from, but most importantly, to give credit where credit
|
|
|
|
is due!
|
|
|
|
|
2012-07-04 19:00:51 +00:00
|
|
|
The `Open Comparison Contributing Docs`__ explains the workflow for forking,
|
|
|
|
cloning, branching, committing, and sending a pull request for the git
|
|
|
|
repository.
|
2012-07-03 22:52:44 +00:00
|
|
|
|
2012-07-04 19:00:51 +00:00
|
|
|
``git pull upstream develop`` is a shorter way to update your local repository
|
|
|
|
to the latest version.
|
2012-07-01 00:26:47 +00:00
|
|
|
|
|
|
|
.. __: http://opencomparison.readthedocs.org/en/latest/contributing.html
|
|
|
|
|
2012-07-03 22:40:10 +00:00
|
|
|
Editing and Previewing the Docs
|
|
|
|
-------------------------------
|
2012-07-01 02:45:58 +00:00
|
|
|
You need ``sphinx-build`` to build the docs. In Debian/Ubuntu this is provided
|
2012-07-04 19:00:51 +00:00
|
|
|
in the ``python-sphinx`` package.
|
2012-07-03 22:40:10 +00:00
|
|
|
|
|
|
|
Then::
|
|
|
|
|
|
|
|
cd doc; make html
|
|
|
|
|
2012-07-04 19:00:51 +00:00
|
|
|
- The docs then are built in the ``docs/_build/html/`` folder. If you make
|
|
|
|
changes and want to see the results, ``make html`` again.
|
|
|
|
- The docs use ``reStructuredText`` 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/``
|
2012-07-03 23:06:57 +00:00
|
|
|
|
2012-07-01 02:45:58 +00:00
|
|
|
Installing Salt for development
|
|
|
|
-------------------------------
|
2012-07-01 00:26:47 +00:00
|
|
|
|
|
|
|
Clone the repository using::
|
|
|
|
|
|
|
|
git clone https://github.com/saltstack/salt
|
|
|
|
|
2012-07-01 02:45:58 +00:00
|
|
|
Create a new `virtualenv`_::
|
|
|
|
|
|
|
|
virtualenv /path/to/your/virtualenv
|
|
|
|
|
2012-08-20 19:00:35 +00:00
|
|
|
.. note:: site packages
|
|
|
|
|
|
|
|
If you wish to use installed packages rather than have pip download and
|
|
|
|
compile new ones into this environment, add "--system-site-packages".
|
|
|
|
|
2012-07-01 02:45:58 +00:00
|
|
|
.. _`virtualenv`: http://pypi.python.org/pypi/virtualenv
|
|
|
|
|
|
|
|
Activate the virtualenv::
|
|
|
|
|
|
|
|
source /path/to/your/virtualenv/bin/activate
|
|
|
|
|
|
|
|
Install Salt (and dependencies) into the virtualenv::
|
|
|
|
|
|
|
|
pip install -e ./salt # the path to the salt git clone from above
|
|
|
|
|
|
|
|
.. note:: Installing M2Crypto
|
|
|
|
|
2012-08-20 19:00:35 +00:00
|
|
|
You may need ``swig`` and ``libssl-dev`` to build M2Crypto. If you
|
|
|
|
encounter the error ``command 'swig' failed with exit status 1``
|
2012-07-01 02:45:58 +00:00
|
|
|
while installing M2Crypto, try installing it with the following command::
|
|
|
|
|
|
|
|
env SWIG_FEATURES="-cpperraswarn -includeall -D__`uname -m`__ -I/usr/include/openssl" pip install M2Crypto
|
|
|
|
|
|
|
|
Running a self-contained development version
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
Copy the master and minion config files into your virtualenv::
|
|
|
|
|
|
|
|
mkdir -p /path/to/your/virtualenv/etc/salt
|
|
|
|
cp ./salt/conf/master.template /path/to/your/virtualenv/etc/salt/master
|
|
|
|
cp ./salt/conf/minion.template /path/to/your/virtualenv/etc/salt/minion
|
|
|
|
|
|
|
|
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``.
|
|
|
|
3. If you are also running a non-development version of Salt you will have to
|
|
|
|
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.
|
|
|
|
2. Uncomment and change the ``master: salt`` value to point at ``localhost``.
|
|
|
|
3. Uncomment and change the ``id:`` value to something descriptive like
|
|
|
|
"saltdev". This isn't strictly necessary but it will serve as a reminder of
|
|
|
|
which Salt installation you are working with.
|
|
|
|
|
|
|
|
Start the master and minion, accept the minon's key, and verify your local Salt
|
|
|
|
installation is working::
|
|
|
|
|
2012-08-13 23:47:28 +00:00
|
|
|
salt-master -c ./etc/salt -d
|
|
|
|
salt-minion -c ./etc/salt -d
|
2012-07-01 02:45:58 +00:00
|
|
|
salt-key -c ./etc/salt/master -L
|
|
|
|
salt-key -c ./etc/salt/master -A
|
2012-08-13 23:47:28 +00:00
|
|
|
salt -c ./etc/salt '*' test.ping
|
2012-07-01 02:45:58 +00:00
|
|
|
|
2012-07-01 00:26:47 +00:00
|
|
|
File descriptor limit
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Check your file descriptor limit with::
|
|
|
|
|
|
|
|
ulimit -n
|
|
|
|
|
|
|
|
If it is less than 1024, you should increase it with::
|
|
|
|
|
|
|
|
ulimit -n 1024
|
|
|
|
|
2012-07-01 02:45:58 +00:00
|
|
|
Running the tests
|
|
|
|
~~~~~~~~~~~~~~~~~
|
2012-07-01 00:26:47 +00:00
|
|
|
|
2012-07-01 02:45:58 +00:00
|
|
|
You will need ``mock`` to run the tests::
|
2012-07-01 00:26:47 +00:00
|
|
|
|
|
|
|
pip install mock
|
|
|
|
|
2012-07-01 02:45:58 +00:00
|
|
|
If you are on Python < 2.7 then you will also need unittest2::
|
2012-07-01 00:26:47 +00:00
|
|
|
|
|
|
|
pip install unittest2
|
|
|
|
|
|
|
|
Finally you use setup.py to run the tests with the following command::
|
|
|
|
|
|
|
|
./setup.py test
|
2012-08-13 23:47:28 +00:00
|
|
|
|
|
|
|
For greater control while running the tests, please try::
|
|
|
|
|
|
|
|
./tests/runtests.py -h
|