SALT(7)

NAME
salt - Salt Documentation

INTRODUCTION TO SALT
We’re not just talking about NaCl..SS Distributed remote execution

Salt is a distributed remote execution system used to execute commands and query data. It was developed in order to bring the best solutions found in the world of remote execution together and make them better, faster, and more malleable. Salt accomplishes this through its ability to handle large loads of information, and not just dozens but hundreds and even thousands of individual servers quickly through a simple and manageable interface.

  Simplicity

Versatility between massive scale deployments and smaller systems may seem daunting, but Salt is very simple to set up and maintain, regardless of the size of the project. The architecture of Salt is designed to work with any number of servers, from a handful of local network systems to international deployments across different datacenters. The topology is a simple server/client model with the needed functionality built into a single set of daemons. While the default configuration will work with little to no modification, Salt can be fine tuned to meet specific needs.

  Parallel execution

The core function of Salt is to enable remote commands to be called in parallel rather than in serial, to use a secure and encrypted protocol, the smallest and fastest network payloads possible, and with a simple programming interface. Salt also introduces more granular controls to the realm of remote execution, allowing for commands to be executed in parallel and for systems to be targeted based on more than just hostname, but by system properties.

  Building on proven technology

Salt takes advantage of a number of technologies and techniques. The networking layer is built with the excellent ZeroMQ networking library, so Salt itself contains a viable, and transparent, AMQ broker inside the daemon. Salt uses public keys for authentication with the master daemon, then uses faster AES encryption for payload communication, this means that authentication and encryption are also built into Salt. Salt takes advantage of communication via msgpack, enabling fast and light network traffic.

  Python client interface

In order to allow for simple expansion, Salt execution routines can be written as plain Python modules and the data collected from Salt executions can be sent back to the master server, or to any arbitrary program. Salt can be called from a simple Python API, or from the command line, so that Salt can be used to execute one-off commands as well as operate as an integral part of a larger application.

  Fast, flexible, scalable

The result is a system that can execute commands across groups of varying size, from very few to very many servers at considerably high speed. A system that is very fast, easy to set up and amazingly malleable, able to suit the needs of any number of servers working within the same system. Salt’s unique architecture brings together the best of the remote execution world, amplifies its capabilities and expands its range, resulting in this system that is as versatile as it is practical, able to suit any network.

  Open

Salt is developed under the Apache 2.0 licence, and can be used for open and proprietary projects. Please submit your expansions back to the Salt project so that we can all benefit together as Salt grows. So, please feel free to sprinkle some of this around your systems and let the deliciousness come forth.

INSTALLATION

The Salt system setup is amazingly simple, as this is one of the central design goals of Salt.

  Dependencies

Salt should run on any Unix-like platform so long as the dependencies are met.

•   Python 2.6

•   ZeroMQ >= 2.1.9

•   pyzmq >= 2.1.9 - ZeroMQ Python bindings

•   PyCrypto - The Python cryptography toolkit

•   msgpack-python - High-performance message interchange format

•   YAML - Python YAML bindings

  Optional Dependencies

•   Jinja2 - parsing Salt States (configurable in the master settings)

•   gcc - dynamic Cython module compiling

  Platform-specific installation instructions

  Arch Linux

Salt has primarily been developed on Arch Linux, meaning it is known to work very well on that distribution. The lead developer, Thomas S. Hatch (thatch45) has been a TU (Trusted User) for the Arch Linux distribution, and has written a number of Arch-specific tools in the past.

Salt, while not Arch-specific, is packaged for and works well on Arch Linux.

  Installation

Salt is currently available via the Arch User Repository (AUR). There are currently stable and -git packages available.

  Stable Release

To install Salt stable releases from the Arch Linux AUR, use the commands:

wget https://aur.archlinux.org/packages/sa/salt/salt.tar.gz
tar xf salt.tar.gz
cd salt/
makepkg -is

A few of Salt's dependencies are currently only found within the AUR, so you'll need to download and run makepkg -is on these as well. As a reference, Salt currently relies on the following packages only available via the AUR:

•   https://aur.archlinux.org/packages/py/python2-msgpack/python2-msgpack.tar.gz

•   https://aur.archlinux.org/packages/py/python2-psutil/python2-psutil.tar.gz

Note
    yaourt

    If you chose to use a tool such as Yaourt the dependencies will be gathered and built for you automatically.

    The command to install salt using the yaourt tool is:

    yaourt salt

  Tracking develop

To install the bleeding edge version of Salt (may include bugs!), you can use the -git package. Installing the -git package can be done using the commands:

wget https://aur.archlinux.org/packages/sa/salt-git/salt-git.tar.gz
tar xf salt-git.tar.gz
cd salt-git/
makepkg -is

A few of Salt's dependencies are currently only found within the AUR, so you'll need to download and run makepkg -is on these as well. As a reference, Salt currently relies on the following packages only available via the AUR:

•   https://aur.archlinux.org/packages/py/python2-msgpack/python2-msgpack.tar.gz

•   https://aur.archlinux.org/packages/py/python2-psutil/python2-psutil.tar.gz

Note
    yaourt

    If you chose to use a tool such as Yaourt the dependencies will be gathered and built for you automatically.

    The command to install salt using the yaourt tool is:

    yaourt salt-git

  Configuration

In the sections below I'll outline configuration options for both the Salt Master and Salt Minions.

The Salt package installs two template configuration files, /etc/salt/master.template and /etc/salt/minion.template. You'll need to copy these .template files into place and make a few edits. First, copy them into place as seen here:

cp /etc/salt/master.template /etc/salt/master
cp /etc/salt/minion.template /etc/salt/minion

Note: You'll only need to copy the config for the service you're going to run.

Once you've copied the config into place you'll need to make changes specific to your setup. Below I'll outline suggested configuration changes to the Master, after which I'll outline configuring the Minion.

  Master Configuration

This section outlines configuration of a Salt Master, which is used to control other machines known as "minions" (see "Minion Configuration" for instructions on configuring a minion). This will outline IP configuration, and a few key configuration paths.

Interface

By default the Salt master listens on TCP ports 4505 and 4506 on all interfaces (0.0.0.0). If you have a need to bind Salt to a specific IP, redefine the "interface" directive as seen here:

- #interface: 0.0.0.0
+ interface: 10.0.0.1

rc.conf

You'll need to activate the Salt Master in your rc.conf file. Using your favorite editor, open /etc/rc.conf and add the salt-master.

-DAEMONS=(syslog-ng network crond)
+DAEMONS=(syslog-ng network crond @salt-master)

Start the Master

Once you've completed all of these steps you're ready to start your Salt Master. You should be able to start your Salt Master now using the command seen here:

rc.d start salt-master

If your Salt Master doesn't start successfully, go back through each step and see if anything was missed. Salt doesn't take much configuration (part of its beauty!), and errors are usually simple mistakes.

  Minion Configuration

Configuring a Salt Minion is surprisingly simple. Unless you have a real need for customizing your minion configuration (which there are plenty of options if you are so inclined!), there is one simple directive that needs to be updated. That option is the location of the master.

By default a Salt Minion will try to connect to the dns name "salt". If you have the ability to update DNS records for your domain you might create an A or CNAME record for "salt" that points to your Salt Master. If you are able to do this you likely can do without any minion configuration at all.

If you are not able to update DNS, you'll simply need to update one entry in the configuration file. Using your favorite editor, open the minion configuration file and update the "master" entry as seen here.

- #master: salt
+ master: 10.0.0.1

Simply update the master directive to the IP or hostname of your Salt Master. Save your changes and you're ready to start your Salt Minion. Advanced configuration options are covered in another chapter.

rc.conf

Before you're able to start the Salt Minion you'll need to update your rc.conf file. Using your favorite editor open /etc/rc.conf and add this line:

-DAEMONS=(syslog-ng network crond)
+DAEMONS=(syslog-ng network crond @salt-minion)

Start the Minion

Once you've completed all of these steps you're ready to start your Salt Minion. You should be able to start your Salt Minion now using the command seen here:

rc.d start salt-minion

If your Salt Minion doesn't start successfully, go back through each step and see if anything was missed. Salt doesn't take much configuration (part of its beauty!), and errors are usually simple mistakes.

  Tying It All Together

If you've successfully completed each of the steps above you should have a running Salt Master and a running Salt Minion. The Minion should be configured to point to the Master. To verify that there is communication flowing between the Minion and Master we'll run a few initial salt commands. These commands will validate the Minions RSA encryption key, and then send a test command to the Minion to ensure that commands and responses are flowing as expected.

Key Management

Salt uses AES encryption for all communication between the Master and the Minion. This ensures that the commands you send to your Minions (your cloud) can not be tampered with, and that communication between Master and Minion is only done through trusted, accepted keys.

Before you'll be able to do any remote execution or configuration management you'll need to accept any pending keys on the Master. Run the salt-key command to list the keys known to the Salt Master.

[root@master ~]# salt-key -L
Unaccepted Keys:
alpha
bravo
charlie
delta
Accepted Keys:

This example shows that the Salt Master is aware of four Minions, but none of the keys have been accepted. To accept the keys and allow the Minions to be controlled by the Master, again use the salt-key command:

[root@master ~]# salt-key -A
[root@master ~]# salt-key -L
Unaccepted Keys:
Accepted Keys:
alpha
bravo
charlie
delta

The salt-key command allows for signing keys individually or in bulk. The example above, using -A bulk-accepts all pending keys. To accept keys individually use the lowercase of the same option, -a keyname.

  Sending Commands

Everything should be set for you to begin remote management of your Minions. Whether you have a few or a few-dozen, Salt can help you manage them easily!

For final verification, send a test function from your Salt Master to your minions. If all of your minions are properly communicating with your Master, you should "True" responses from each of them. See the example below to send the test.ping remote command:

[root@master ~]# salt '*' test.ping
{'alpha': True}

  Where Do I Go From Here

Congratulations! You've successfully configured your first Salt Minions and are able to send remote commands. I'm sure you're eager to learn more about what Salt can do. Depending on the primary way you want to manage your machines you may either want to visit the section regarding Salt States, or the section on Modules.

  Debian & Ubuntu

  Ubuntu

  Installation

To install Salt on Ubuntu, use the following command:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:saltstack/salt
sudo apt-get update
sudo apt-get install salt-master
sudo apt-get install salt-minion

Installing on Ubuntu 11.04

    There is a conflict with msgpack-python on Ubuntu 11.04 and the current saltstack PPA. You can work around the conflict by installing msgpack-python from Oneiric:

    sudo add-apt-repository 'deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe'
    sudo add-apt-repository ppa:saltstack/salt
    sudo apt-get update
    sudo apt-get install msgpack-python
    sudo apt-get install salt-master
    sudo apt-get install salt-minion
    sudo add-apt-repository --remove 'deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe'

After installation you'll need to make a few changes to the configuration files.

  Configuration

To configure your Salt files we must modify both master and minion configuration files. We need to set where the master binds, by default salt listens on all interfaces. If you have a need to bind to a specific local IP, make the change as needed. To edit the master type in the following command:

sudo vim /etc/salt/master

From here make the following changes:

- interface: 0.0.0.0
+ interface: 192.168.0.10

To configure the minion type in the following command:

sudo vim /etc/salt/minion

Once inside the editor make the following changes:

- master: salt
+ master: 192.168.0.10

After making the following changes you need to restart both the master and the minion. To do so type in the following commands:

sudo /etc/init.d/salt-master restart
sudo /etc/inti.d/salt-minion restart

  Test

To test Salt we must first sign the key of the minion to the master. To see the pending keys type in the following command:

sudo salt-key -L

From here you will should see a key name underneath the Unaccepted Keys portion. To sign the minion key to the master type in the following command:

sudo salt-key -a $minion

Where $minion is the unaccepted key.

Now that you have signed the key we need to see if the key was accepted and that we can ping the minion and get a response. To do this you can type in one of the previous commands sudo salt-key -L and see if the key has been accepted, then also ping the minion to see if it's working by typing in the following command:

sudo salt \* test.ping

If it is working properly you should see this result:

{'$minion': True}

  Troubleshooting

To see if the Salt master is running properly type in the following command:

netstat -natp | grep 450

This should return 192.168.0.10:4505 and 192.168.0.10:4506 if the master was configured properly. If this does not return those values recheck your master and minion config files for mistakes.

To see if both master and minion are running properly type in the following command:

ps -efH | grep sal[t]

This should return 8 Salt masters and 1 Salt minion if both are configured properly. If you are still having issues with your Salt configuration please reference the trouble shooting page Troubleshooting.

  What Now?

Congratulations you have just successfully installed Salt on your Ubuntu machine and configured both the master and the minion. From this point you are now able to send remote commands. Depending on the primary way you want to manage your machines you may either want to visit the section regarding Salt States, or the section on Modules.

  Debian

A deb package is currently in testing for inclusion in apt. Until that is accepted you can install Salt by downloading the latest .deb in the downloads section on GitHub and installing that manually using dpkg -i.

Installing ZeroMQ on Squeeze (Debian 6)

    There is a python-zmq package available in Debian "wheezy (testing)". If you don't have that repo enabled the best way to install Salt and pyzmq is by using pip (or easy_install):

    pip install pyzmq salt

  Fedora & CentOS / Enterprise Linux

Beginning with version 0.9.4, Salt has been available in the primary Fedora repositories and EPEL. It is installable using yum. Fedora will have more up to date versions of Salt than other members of the Red Hat family, which makes it a great place to help improve Salt!

CentOS / RHEL 5

    Salt and all dependencies have been finally accepted into the yum reposities for EPEL5 and EPEL6. Currently, the latest is in epel-testing while awaiting promotion to epel proper. You can install it via:

    yum --enablerepo=epel-testing install salt

    On RHEL6, the proper jinja packages were moved from EPEL to the "RHEL Server Optional Channel". Verify this repository is enabled before installing salt on RHEL6.

  Installation

Salt can be installed using yum and is available in the standard Fedora repositories.

  Stable Release

Salt is packaged separately for the minion and the master. You'll only need to install the appropriate package for the role you need the machine to play. This means you're going to want one master and a whole bunch of minions!

yum install salt-master
yum install salt-minion

  Configuration

Below, we'll cover Salt Master and Minion configuration options.

  Master Configuration

This section outlines configuration of a Salt Master, which is used to control other machines known as "minions" (see "Minion Configuration" for instructions on configuring a minion). This will outline IP configuration, and a few key configuration paths.

Interface

By default the Salt master listens on TCP ports 4505 and 4506 on all interfaces (0.0.0.0). If you have a need to bind Salt to a specific IP, redefine the "interface" directive as seen here:

- #interface: 0.0.0.0
+ interface: 10.0.0.1

Enable the Master

You'll also likely want to activate the Salt Master in systemd, configuring the Salt Master to start automatically at boot.

systemctl enable salt-master.service

Start the Master

Once you've completed all of these steps you're ready to start your Salt Master. You should be able to start your Salt Master now using the command seen here:

systemctl start salt-master.service

If your Salt Master doesn't start successfully, go back through each step and see if anything was missed. Salt doesn't take much configuration (part of its beauty!), and errors are usually simple mistakes.

  Minion Configuration

Configuring a Salt Minion is surprisingly simple. Unless you have a real need for customizing your minion configuration (which there are plenty of options if you are so inclined!), there is one simple directive that needs to be updated. That option is the location of the master.

By default a Salt Minion will try to connect to the dns name "salt". If you have the ability to update DNS records for your domain you might create an A or CNAME record for "salt" that points to your Salt Master. If you are able to do this you likely can do without any minion configuration at all.

If you are not able to update DNS, you'll simply need to update one entry in the configuration file. Using your favorite editor, open the minion configuration file and update the "master" entry as seen here:

- #master: salt
+ master: 10.0.0.1

Simply update the master directive to the IP or hostname of your Salt Master. Save your changes and you're ready to start your Salt Minion. Advanced configuration options are covered in another chapter.

Enable the Minion

You'll need to configure the minion to auto-start at boot. You can toggle that option through systemd.

systemctl enable salt-minion.service

Start the Minion

Once you've completed all of these steps, start the Minion. This command should do the trick:

systemctl start salt-minion.service

If your Salt Minion doesn't start successfully, go back through each step and see if anything was missed. Salt doesn't take much configuration (part of its beauty!), and errors are usually simple mistakes.

  Tying It All Together

If you've successfully completed each of the steps above you should have a running Salt Master and a running Salt Minion. The Minion should be configured to point to the Master. To verify that there is communication flowing between the Minion and Master we'll run a few initial salt commands. These commands will validate the Minions RSA encryption key, and then send a test command to the Minion to ensure that commands and responses are flowing as expected.

Key Management

Salt uses AES encryption for all communication between the Master and the Minion. This ensures that the commands you send to your Minions (your cloud) can not be tampered with, and that communication between Master and Minion is only done through trusted, accepted keys.

Before you'll be able to do any remote execution or configuration management you'll need to accept any pending keys on the Master. Run the salt-key command to list the keys known to the Salt Master:

[root@master ~]# salt-key -L
Unaccepted Keys:
alpha
bravo
charlie
delta
Accepted Keys:

This example shows that the Salt Master is aware of four Minions, but none of the keys have been accepted. To accept the keys and allow the Minions to be controlled by the Master, again use the salt-key command:

[root@master ~]# salt-key -A
[root@master ~]# salt-key -L
Unaccepted Keys:
Accepted Keys:
alpha
bravo
charlie
delta

The salt-key command allows for signing keys individually or in bulk. The example above, using -A bulk-accepts all pending keys. To accept keys individually use the lowercase of the same option, -a keyname.

  Sending Commands

Everything should be set for you to begin remote management of your Minions. Whether you have a few or a few-dozen, Salt can help you manage them easily!

For final verification, send a test function from your Salt Master to your minions. If all of your minions are properly communicating with your Master, you should "True" responses from each of them. See the example below to send the test.ping remote command:

[root@master ~]# salt '*' test.ping
{'alpha': True}

  Where Do I Go From Here

Congratulations! You've successfully configured your first Salt Minions and are able to send remote commands. I'm sure you're eager to learn more about what Salt can do. Depending on the primary way you want to manage your machines you may either want to visit the section regarding Salt States, or the section on Modules.

  FreeBSD

Salt was added to the FreeBSD ports tree Dec 26th, 2011 by Christer Edwards <christer.edwards@gmail.com>. It has been tested on FreeBSD 7.4, 8.2 and 9.0 releases.

Salt is dependent on the following additional ports. These will be installed as dependencies of the sysutils/salt port.

/devel/py-yaml
/devel/py-pyzmq
/devel/py-Jinja2
/devel/py-msgpack
/security/py-pycrypto
/security/py-m2crypto

  Installation

To install Salt from the FreeBSD ports tree, use the command:

cd /usr/ports/sysutils/salt && make install clean

Once the port is installed you'll need to make a few configuration changes. These include defining the IP to bind to (optional), and some configuration path changes to make salt fit more natively into the FreeBSD filesystem tree.

  Configuration

In the sections below I'll outline configuration options for both the Salt Master and Salt Minions.

The Salt port installs two sample configuration files, salt/master.sample and salt/minion.sample (these should be installed in /usr/local/etc/, unless you use a different %%PREFIX%%). You'll need to copy these as seen here:

cp /usr/local/etc/salt/master.sample /usr/local/etc/salt/master
cp /usr/local/etc/salt/minion.sample /usr/local/etc/salt/minion

Note: You'll only need to copy the config for the service you're going to run.

Once you've copied the config into place you'll need to make changes specific to your setup. Below I'll outline suggested configuration changes to the Master, after which I'll outline configuring the Minion.

  Master Configuration

This section outlines configuration of a Salt Master, which is used to control other machines known as "minions" (see "Minion Configuration" for instructions on configuring a minion). This will outline IP configuration, and a few key configuration paths.

Interface

By default the Salt master listens on ports 4505 and 4506 on all interfaces (0.0.0.0). If you have a need to bind Salt to a specific IP, redefine the "interface" directive as seen here.

- #interface: 0.0.0.0
+ interface: 10.0.0.1

rc.conf

Last but not least you'll need to activate the Salt Master in your rc.conf file. Using your favorite editor, open /etc/rc.conf or /etc/rc.conf.local and add this line.

+ salt_master_enable="YES"

Start the Master

Once you've completed all of these steps you're ready to start your Salt Master. The Salt port installs an rc script which should be used to manage your Salt Master. You should be able to start your Salt Master now using the command seen here:

service salt_master start

If your Salt Master doesn't start successfully, go back through each step and see if anything was missed. Salt doesn't take much configuration (part of its beauty!), and errors are usually simple mistakes.

  Minion Configuration

Configuring a Salt Minion is surprisingly simple. Unless you have a real need for customizing your minion configuration (which there are plenty of options if you are so inclined!), there is one simple directive that needs to be updated. That option is the location of the master.

By default a Salt Minion will try to connect to the dns name "salt". If you have the ability to update DNS records for your domain you might create an A or CNAME record for "salt" that points to your Salt Master. If you are able to do this you likely can do without any minion configuration at all.

If you are not able to update DNS, you'll simply need to update one entry in the configuration file. Using your favorite editor, open the minion configuration file and update the "master" entry as seen here.

- #master: salt
+ master: 10.0.0.1

Simply update the master directive to the IP or hostname of your Salt Master. Save your changes and you're ready to start your Salt Minion. Advanced configuration options are covered in another chapter.

rc.conf

Before you're able to start the Salt Minion you'll need to update your rc.conf file. Using your favorite editor open /etc/rc.conf or /etc/rc.conf.local and add this line.

+ salt_minion_enable="YES"

Once you've completed all of these steps you're ready to start your Salt Minion. The Salt port installs an rc script which should be used to manage your Salt Minion. You should be able to start your Salt Minion now using the command seen here.

service salt_minion start

If your Salt Minion doesn't start successfully, go back through each step and see if anything was missed. Salt doesn't take much configuration (part of its beauty!), and errors are usually simple mistakes.

  Tying It All Together

If you've successfully completed each of the steps above you should have a running Salt Master and a running Salt Minion. The Minion should be configured to point to the Master. To verify that there is communication flowing between the Minion and Master we'll run a few initial salt commands. These commands will validate the Minions RSA encryption key, and then send a test command to the Minion to ensure that commands and responses are flowing as expected.

Key Management

Salt uses AES encryption for all communication between the Master and the Minion. This ensures that the commands you send to your Minions (your cloud) can not be tampered with, and that communication between Master and Minion is only done through trusted, accepted keys.

Before you'll be able to do any remote execution or state management you'll need to accept any pending keys on the Master. Run the salt-key command to list the keys known to the Salt Master:

[root@master ~]# salt-key -L
Unaccepted Keys:
alpha
bravo
charlie
delta
Accepted Keys:

This example shows that the Salt Master is aware of four Minions, but none of the keys have been accepted. To accept the keys and allow the Minions to be controlled by the Master, again use the salt-key command:

[root@master ~]# salt-key -A
[root@master ~]# salt-key -L
Unaccepted Keys:
Accepted Keys:
alpha
bravo
charlie
delta

The salt-key command allows for signing keys individually or in bulk. The example above, using -A bulk-accepts all pending keys. To accept keys individually use the lowercase of the same option, -a keyname.

  Sending Commands

Everything should be set for you to begin remote management of your Minions. Whether you have a few or a few-dozen, Salt can help you manage them easily!

For final verification, send a test function from your Salt Master to your minions. If all of your minions are properly communicating with your Master, you should "True" responses from each of them. See the example below to send the test.ping remote command.

[root@master ~]# salt 'alpha' test.ping
{'alpha': True}

  Where Do I Go From Here

Congratulations! You've successfully configured your first Salt Minions and are able to send remote commands. I'm sure you're eager to learn more about what Salt can do. Depending on the primary way you want to manage your machines you may either want to visit the section regarding Salt States, or the section on Modules.

  Gentoo

Salt can be easily installed on Gentoo:

emerge pyyaml m2crypto pycrypto jinja pyzmq

Then download and install from source:

1.  Download the latest source tarball from the GitHub downloads directory for the Salt project.

2.  Untar the tarball and run the setup.py as root:

    tar xf salt-<version>.tar.gz
    cd salt-<version>
    python setup.py install

  Windows

Salt currently has experimental support for Salt Minions on Windows.

There are no plans for the forseeable future to develop a Salt Master on Windows. For now you must run your Salt Master on a supported operating system to control your Salt Minions on Windows.

Many of the standard Salt modules have been ported to work on Windows and many of the Salt States currently work on Windows, as well.

  Installation from source

Work is under way to create a Windows installer for Salt, but for now one must install each dependency separately and configure Salt to run on your Windows host.

Rather than send you on a wild goose chase across the Internet, we've collected some of the more difficult to find installers in our github repo for you.

  Install on Windows XP 32bit

1.  Install msysgit

1.  Clone the Salt git repository from github

    git clone git://github.com/saltstack/salt.git

2.  Install Microsoft Visual Studio 2008 Express with the web installer. Or download a full iso with the installer . You must use Visual Studio 2008 Express, not Visual Studio 2010 Express.

3.  Install Python 2.7.x

4.  Add c:\Python27 to your system path

5.  Install the Microsoft Visuall C++ 2008 SP1 Redistributable, vcredist_x86.

6.  Install Win32OpenSSL-1_0_0e.exe

1.  Choose first option to install in Windows system directory

7.  Install pyzmq-2.1.11.win32-py2.7.msi

8.  Install pycrypto-2.3.win32-py2.7.msi

9.  Install PyYAML-3.10.win32-py2.7.msi

10. Install Cython-0.15.1.win32-py2.79.exe

11. Download and run distribute_setup.py

    python distribute_setup.py

12. Download and run pip

    python get-pip.py

13. Add c:\python27\scripts to your path

14. Close terminal window and open a new terminal window (cmd)

15. Install jinja2

    pip install jinja2

16. Install Messagepack

    pip install msgpack-python

17. Install Salt

    cd ./salt
    python setup.py install

18. Edit c:\etc\salt\minon

    master: ipaddress or hostname of your salt-master
    master_port: 4506
    root_dir: c:\
    pki_dir: /etc/salt/pki
    cachedir: /var/cache/salt
    renderer: yaml_jinja
    open_mode: False
    multiprocessing: False

19. Start the salt-minion

    cd c:\python27\scripts
    python salt-minion

20. On the salt-master accept the new minion's key

    sudo salt-key -A
    (This accepts all unaccepted keys. If you're concerned about security just accept the key for this specific minion)

21. Test that your minion is responding

a.  On the salt-master run:

    sudo salt '*' test.ping
    You should get the following response: {'your minion hostname': True}

CONFIGURING SALT

Salt configuration is very simple. The default configuration for the master will work for most installations and the only requirement for setting up a minion is to set the location of the master in the minion configuration file.

master
    The Salt master is the central server that all minions connect to. You run commands on the minions through the master and minions send data back to the master (unless otherwise redirected with a returner). It is started with the salt-master program.

minion
    Salt minions are the potentially hundreds or thousands of servers that you query and control from the master.

    The configuration files will be installed to /etc/salt and are named after the respective components, /etc/salt/master and /etc/salt/minion.

    To make a minion check into the correct master simply edit the master variable in the minion configuration file to reference the master DNS name or IPv4 address.

  Running Salt

1.  Start the master in the foreground (to daemonize the process, pass the -d flag):

    # salt-master

2.  Start the minion in the foreground (to daemonize the process, pass the -d flag):

    # salt-minion

Having trouble?

    The simplest way to troubleshoot Salt is to run the master and minion in the foreground with log level set to debug:

    salt-master --log-level=debug

Run as an unprivileged (non-root) user?

    To run Salt as another user, specify --user in the command line or assign user in the configuration file.

There is also a full troubleshooting guide available.

  Manage Salt public keys

Salt manages authentication with RSA public keys. The keys are managed on the master via the salt-key command. Once a minion checks into the master the master will save a copy of the minion key. Before the master can send commands to the minion the key needs to be "accepted".

1.  List the accepted and unaccepted Salt keys:

    salt-key -L

2.  Accept a minion key:

    salt-key -a <minion id>

    or accept all unaccepted minion keys:

    salt-key -A

See also

    salt-key manpage

TARGETING

Targeting
    Specifying which minions should run a command or execute a state by matching against hostnames, or system information, or defined groups, or even combinations thereof.

    For example the command salt web1 apache.signal restart to restart the Apache httpd server specifies the machine web1 as the target and the command will only be run on that one minion.

    Similarly when using States, the following top file specifies that only the web1 minion should execute the contents of webserver.sls:

    base:
      'web1':
        - webserver

    There are many ways to target individual minions or groups of minions in Salt:

  Matching the minion id

minion id
    A unique identifier for a given minion. By default the minion id is the FQDN of that host but this can be overridden.

    Each minion needs a unique identifier. By default when a minion starts for the first time it chooses its FQDN as that identifier. The minion id can be overridden via the minion's id configuration setting.

Tip minion id and minion keys

    The minion id is used to generate the minion's public/private keys and if it ever changes the master must then accept the new key as though the minion was a new host.

  Globbing

The default matching that Salt utilizes is shell-style globbing around the minion id. This also works for states in the top file.

Note
    You must wrap salt calls that use globbing in single-quotes to prevent the shell from expanding the globs before Salt is invoked.

Match all minions:

salt '*' test.ping

Match all minions in the example.net domain or any of the example domains:

salt '*.example.net' test.ping
salt '*.example.*' test.ping

Match all the webN minions in the example.net domain (web1.example.net, web2.example.net … webN.example.net):

salt 'web?.example.net test.ping

Match the web1 through web5 minions:

salt 'web[1-5]' test.ping

Match the web-x, web-y, and web-z minions:

salt 'web-[x-z]' test.ping

  Regular Expressions

Minions can be matched using Perl-compatible regular expressions (which is globbing on steroids and a ton of caffeine).

Match both web1-prod and web1-devel minions:

salt -E 'web1-(prod|devel)' test.ping

When using regular expressions in a State's top file, you must specify the matcher as the first option. The following example executes the contents of webserver.sls on the above-mentioned minions.

base:
  'web1-(prod|devel)':
  - match: pcre
  - webserver

  Lists

At the most basic level, you can specify a flat list of minion IDs:

salt -L 'web1,web2,web3' test.ping

  Grains

Salt comes with an interface to derive information about the underlying system. This is called the grains interface, because it presents salt with grains of information.

The grains interface is made available to Salt modules and components so that the right salt minion commands are automatically available on the right systems.

It is important to remember that grains are bits of information loaded when the salt minion starts, so this information is static. This means that the information in grains is unchanging, therefore the nature of the data is static. So grains information are things like the running kernel, or the operating system.

Match all CentOS minions:

salt -G 'os:CentOS' test.ping

Match all minions with 64-bit CPUs and return number of available cores:

salt -G 'cpuarch:x86_64' grains.item num_cpus

  Grains in the Minion Config

Grains can also be statically assigned within the minion configuration file. Just add the option grains and pass options to it:

grains:
  roles:
    - webserver
    - memcache
  deployment: datacenter4
  cabinet: 13
  cab_u: 14-15

Then status data specific to your servers can be retrieved via Salt, or used inside of the State system for matching. It also makes targeting, in the case of the example above, simply based on specific data about your deployment.

  Writing Grains

Grains are easy to write. The grains interface is derived by executing all of the "public" functions found in the modules located in the grains package or the custom grains directory. The functions in the modules of the grains must return a Python dict, where the keys in the dict are the names of the grains and the values are the values.

Custom grains should be placed in a _grains directory located under your file_roots. Before adding a grain to Salt, consider what the grain is and remember that grains need to be static data.

  Examples of Grains

The core module in the grains package is where the main grains are loaded by the Salt minion and provides the principal example of how to write grains:

https://github.com/saltstack/salt/blob/v0.10.0/salt/grains/core.py

  Syncing Grains

Syncing grains can be done a number of ways, they are automatically synced when state.highstate is called, or the grains can be synced and reloaded by calling the saltutil.sync_grains or saltutil.sync_all functions.

  Node groups

Node group
    A predefined group of minions declared in the master configuration file nodegroups setting as a compound target.

    For example, in the master config file nodegroups setting:

    nodegroups:
      group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com'
      group2: 'G@os:Debian and foo.domain.com'

    Specify a nodegroup via the -N option at the command-line:

    salt -N group1 test.ping

    Specify a nodegroup with - match: nodegroup in a top file:

    base:
      group1:
        - match: nodegroup
        - webserver

  Compound matchers

Compound matcher
    A combination of many target definitions that can be combined with boolean operators.

    Compound matchers allow very granular minion targeting using any of the previously discussed matchers. The default matcher is a glob, as usual. For matching via anything other than glob, preface it with the letter denoting the match type. The currently implemented "letters" are:
    Letter | Meaning | Example
    G | Grains glob match | G@os:Ubuntu
    E | PCRE Minion id match | E@web\d+\.(dev|qa|prod)\.loc
    P | Grains PCRE match | P@os:(RedHat|Fedora|CentOS)
    L | List of minions | L@minion1.example.com,minion3.domain.com and bl*.domain.com
    I | Pillar glob match | I@pdata:foobar

    Matchers can be joined using boolean and, or, and not operators.

    For example, the following command matches all minions that have a hostname that begins with "webserv" and that are running Debian or it matches any minions that have a hostname that matches the regular expression web-dc1-srv.*:

    salt -C 'webserv* and G@os:Debian or E@web-dc1-srv.*' test.ping

    That same example expressed in a top file looks like the following:

    base:
      'webserv* and G@os:Debian or E@web-dc1-srv.*':
        - match: compound
        - webserver

  Batch Size

The batch size option allows commands to be executed while maintaining that only so many hosts are executing the command at one time. This option can take a percentage or a finite number:

salt \* -b 10 test.ping
salt -G 'os:RedHat' --batch-size 25% apache.signal restart

This will only run test.ping on 10 of the targeted minions at a time and then restart apache on 25% of the minions matching os:RedHat at a time and work through them all until the task is complete. This makes jobs like rolling web server restarts behind a load balancer or doing maintenance on BSD firewalls using carp much easier with salt.

The batch system maintains a window of running minions, so, if there are a total of 150 minions targeted and the batch size is 10, then the command is sent to 10 minions, when one minion returns then the command is sent to one additional minion, so that the job is constantly running on 10 minions.

REMOTE EXECUTION TUTORIAL

orphan

    Before continuing make sure you have a working Salt installation by following the installation and the configuration instructions.

Stuck?

    If you get stuck at any point, there are many ways to get help from the Salt community including our mailing list and our IRC channel.

  Order your minions around

Now that you have a master and at least one minion communicating with each other you can perform commands on the minion via the salt command. Salt calls are comprised of three main components:

salt '<target>' <function> [arguments]

See also

    salt manpage

  target

The target component allows you to filter which minions should run the following function. The default filter is a glob on the minion id. For example:

salt '*' test.ping
salt '*.example.org' test.ping

Targets can be based on minion system information using the Grains system:

salt -G 'os:Ubuntu' test.ping

See also

    Grains system

Targets can be filtered by regular expression:

salt -E 'virtmach[0-9]' test.ping

Finally, targets can be explicitly specified in a list:

salt -L foo,bar,baz,quo test.ping

  function

A function is some functionality provided by a module. Salt ships with a large collection of available functions. List all available functions on your minions:

salt '*' sys.doc

Here are some examples:

Show all currently available minions:

salt '*' test.ping

Run an arbitrary shell command:

salt '*' cmd.run 'uname -a'

See also

    the full list of modules

  arguments

Space-delimited arguments to the function:

salt '*' cmd.exec_code python 'import sys; print sys.version'

HOW DO I USE SALT STATES?

Simplicity, Simplicity, Simplicity

Many of the most powerful and useful engineering solutions are founded on simple principals, the Salt SLS system strives to do just that. K.I.S.S.

The core of the Salt State system is the SLS, or the SaLt State file. The SLS is a representation of the state in which a system should be in, and is set up to contain this data simply. This is often called configuration management.

  It is All Just Data

Before delving into the particulars, it will help to understand that the SLS is just a data structure under the hood. While understanding that the SLS is just a data structure is not at all critical to understand to make use Salt States, it should help bolster the understanding of where the real power is.

SLS files are therefore, in reality, just dictionaries, lists, strings, and numbers. By using this approach Salt can be much more flexible. As someone writes more state files, it becomes clear exactly what is being written. The result is a system that is easy to understand, yet grows with the needs of the admin or developer.

In the section titled "State Data Structures" a reference exists, explaining in depth how the data is laid out.

  Default Data - YAML

By default Salt represents the SLS data in what is one of the simplest serialization formats available - YAML.

A typical SLS file will often look like this in YAML:

 apache:
   pkg:
     - installed
   service:
     - running
     - require:
       - pkg: apache

This SLS data will ensure that the package named apache is installed, and that the apache service is running. The components can be explained in a simple way.

The first line is the ID for a set of data, and it is called the ID Declaration. This ID sets the name of the thing that needs to be manipulated.

The second and fourth lines are the start of the State Declarations, so they are using the pkg and service states respectively. The pkg state manages a software package to get installed via the system's native package manager, and the service state manages a system daemon. Below the pkg and service lines are the function to run. This function defines what state the named package and service should be in. Here the package is to be installed, and the service should be running.

Finally, on line 6, is the word require. This is called a Requisite Statement, and it makes sure that the Apache service is only started after the successful installation of the apache package.

  Adding Configs and Users

When setting up a service like an Apache web server, many more components may need to be added. The Apache configuration file will most likely be managed, and a user and group may need to be set up.

 apache:
   pkg:
     - installed
   service:
     - running
     - watch:
       - pkg: apache
       - file: /etc/httpd/conf/httpd.conf
       - user: apache
   user:
     - present
     - uid: 87
     - gid: 87
     - home: /var/www/html
     - shell: /bin/nologin
     - require:
       - group: apache
   group:
     - present
     - gid: 87
     - require:
       - pkg: apache
 /etc/httpd/conf/httpd.conf:
   file:
     - managed
     - source: salt://apache/httpd.conf
     - user: root
     - group: root
     - mode: 644

This SLS data greatly extends the first example, and includes a config file, a user, a group and new requisite statement: watch.

Adding more states is easy, since the new user and group states are under the Apache ID, the user and group will be the Apache user and group. The require statements will make sure that the user will only be made after the group, and that the group will be made only after the Apache package is installed.

Next,the require statement under service was changed to watch, and is now watching 3 states instead of just one. The watch statement does the same thing as require, making sure that the other states run before running the state with a watch, but it adds an extra component. The watch statement will run the state's watcher function if any of the watched states changed anything. So if the package was updated, the config file changed, or the user uid modified, then the service state's watcher will be run. The service state's watcher just restarts the service, so in this case, a change in the config file will also trigger a restart of the respective service.

  Moving Beyond a Single SLS

When setting up Salt States, more than one SLS will need to be used. The above examples were just in a single SLS file, but more than one SLS file can be combined to build out a State Tree. The above example also references a file with a strange source - salt://apache/httpd.conf. That file will need to be available as well.

The SLS files are laid out in a directory on the Salt master. Files are laid out as just files. A SLS is just a file and files to download are just files.

The Apache example would be laid out in the root of the Salt file server like this:

/apache/init.sls
/apache/httpd.conf

So the httpd.conf is just a file in the apache directory, and is referenced directly.

But with more than a single SLS file, more components can be added to the toolkit, consider this SSH example:

/ssh/init.sls:

 openssh-client:
   pkg:
     - installed
 /etc/ssh/ssh_config
   file:
     - managed
     - user: root
     - group: root
     - mode: 644
     - source: salt://ssh/ssh_config
     - require:
       - pkg: openssh-client

ssh/server.sls:

 include:
   - ssh
 openssh-server:
   pkg:
     - installed
 sshd:
   service:
     - running
     - require:
       - pkg: openssh-client
       - pkg: openssh-server
       - file: /etc/ssh/banner
       - file: /etc/ssh/sshd_config
 /etc/ssh/sshd_config:
     - managed
     - user: root
     - group: root
     - mode: 644
     - source: salt://ssh/sshd_config
     - require:
       - pkg: openssh-server
 /etc/ssh/banner:
   file:
     - managed
     - user: root
     - group: root
     - mode: 644
     - source: salt://ssh/banner
     - require:
       - pkg: openssh-server

Now our State Tree looks like this:

/apache/init.sls
/apache/httpd.conf
/ssh/init.sls
/ssh/server.sls
/ssh/banner
/ssh/ssh_config
/ssh/sshd_config

This example now introduces the include statement. The include statement includes another SLS file so that components found in it can be required, watched or as will soon be demonstrated - extended.

The include statement allows for states to be cross linked. When an SLS has an include statement it is literally extended to include the contents of the included SLS files.

  Extending Included SLS Data

Sometimes SLS data needs to be extended. Perhaps the apache service needs to watch additional resources, or under certain circumstances a different file needs to be placed.

These examples will add more watchers to apache and change the ssh banner.

/ssh/custom-server.sls:

 include:
   - ssh.server
 extend:
   /etc/ssh/banner:
     file:
       - source: salt://ssh/custom-banner

/python/mod_python.sls:

 include:
   - apache
 extend:
   apache:
     service:
       - watch:
         - pkg: mod_python
 mod_python:
   pkg:
     - installed

The custom-server.sls file uses the extend statement to overwrite where the banner is being downloaded from, and therefore changing what file is being used to configure the banner.

In the new mod_python SLS the mod_python package is added, but more importantly the apache service was extended to also watch the mod_python package.

There is a bit of a trick here, in the extend statement Requisite Statements are extended, so the - pkg: mod_python is appended to the watch list. But all other statements are overwritten.

  Understanding the Render System

Since the SLS data is just plain old data, it does not need to be represented with YAML. Salt defaults to YAML because it is very straightforward and easy to learn and use. But the SLS files can be rendered from almost any imaginable medium, so long as a renderer module is provided.

The default rendering system is the yaml_jinja renderer. The yaml_jinja renderer will first pass the template through the Jinja2 templating system, and then through the YAML parser. The benefit here is that full programming constructs are available when creating SLS files.

Other renderers available are yaml_mako which uses the Mako templating system rather than the jinja templating system, and more notably, the pure Python or py renderer. The py renderer allows for SLS files to be written in pure Python, allowing for the utmost level of flexibility and power when preparing SLS data.

  Getting to Know the Default - yaml_jinja

The default renderer - yaml_jinja, allows for the use of the jinja templating system. A guide to the Jinja templating system can be found here: http://jinja.pocoo.org/docs

When working with renderers a few very useful bits of data are passed in. In the case of templating engine based renderers, three critical components are available, salt, grains, and pillar. The salt object allows for any Salt function to be called from within the template, and grains allows for the Grains to be accessed from within the template. A few examples:

/apache/init.sls:

 apache:
   pkg:
     - installed
     {% if grains['os'] == 'RedHat'%}
     - name: httpd
     {% endif %}
   service:
     - running
     {% if grains['os'] == 'RedHat'%}
     - name: httpd
     {% endif %}
     - watch:
       - pkg: apache
       - file: /etc/httpd/conf/httpd.conf
       - user: apache
   user:
     - present
     - uid: 87
     - gid: 87
     - home: /var/www/html
     - shell: /bin/nologin
     - require:
       - group: apache
   group:
     - present
     - gid: 87
     - require:
       - pkg: apache
 /etc/httpd/conf/httpd.conf:
   file:
     - managed
     - source: salt://apache/httpd.conf
     - user: root
     - group: root
     - mode: 644

This example is simple. If the os grain states that the operating system is Red Hat, then the name of the Apache package and service needs to be httpd.

A more aggressive way to use Jinja can be found here, in a module to set up a MooseFS distributed filesystem chunkserver:

/moosefs/chunk.sls:

 include:
   - moosefs
 {% for mnt in salt['cmd.run']('ls /dev/data/moose*').split() %}
 /mnt/moose{{ mnt[-1] }}:
   mount:
     - mounted
     - device: {{ mnt }}
     - fstype: xfs
     - mkmnt: True
   file:
     - directory
     - user: mfs
     - group: mfs
     - require:
       - user: mfs
       - group: mfs
 {% endfor %}
 '/etc/mfshdd.cfg':
   file:
     - managed
     - source: salt://moosefs/mfshdd.cfg
     - user: root
     - group: root
     - mode: 644
     - template: jinja
     - require:
       - pkg: mfs-chunkserver
 '/etc/mfschunkserver.cfg':
   file:
     - managed
     - source: salt://moosefs/mfschunkserver.cfg
     - user: root
     - group: root
     - mode: 644
     - template: jinja
     - require:
       - pkg: mfs-chunkserver
 mfs-chunkserver:
   pkg:
     - installed
 mfschunkserver:
   service:
     - running
     - require:
 {% for mnt in salt['cmd.run']('ls /dev/data/moose*') %}
       - mount: /mnt/moose{{ mnt[-1] }}
       - file: /mnt/moose{{ mnt[-1] }}
 {% endfor %}
       - file: /etc/mfschunkserver.cfg
       - file: /etc/mfshdd.cfg
       - file: /var/lib/mfs

This example shows much more of the available power provided by Jinja. Multiple for loops are used to dynamically detect available hard drives and set them up to be mounted, and the salt object is used multiple times to call shell commands to gather data.

  Introducing the Python Renderer

Sometimes the chosen default renderer might not have enough logical power to accomplish the needed task. When this happens, the Python renderer can be used. Normally a YAML renderer should be used for the majority of SLS files, but a SLS file set to use another renderer can be easily added to the tree.

This example shows a very basic Python SLS file:

/python/django.sls:

 #!py
 def run():
     '''
     Install the django package
     '''
     return {'include': ['python'],
             'django': {'pkg': ['installed']}}

This is a very simple example, the first line has a SLS shebang line that tells Salt to not use the default renderer, but to use the py renderer. Then the run function is defined, the return value from the run function must be a Salt friendly data structure, or better known as a Salt HighState data structure.

This Python example would look like this if it were written in YAML:

 include:
   - python
 django:
   pkg:
     - installed

This clearly illustrates, that not only is using the YAML renderer a wise decision as the default, but that unbridled power can be obtained where needed by using a pure Python SLS.

Now onto the States tutorial, part 1.

STATES TUTORIAL, PART 1

The purpose of this tutorial is to demonstrate how quickly you can configure a system to be managed by Salt States. For detailed information about the state system please refer to the full states reference.

This tutorial will walk you through using Salt to configure a minion to run the Apache HTTP server and to ensure the server is running.

orphan

    Before continuing make sure you have a working Salt installation by following the installation and the configuration instructions.

Stuck?

    If you get stuck at any point, there are many ways to get help from the Salt community including our mailing list and our IRC channel.

  Setting up the Salt State Tree

States are stored in text files on the master and transfered to the minions on demand via the master's File Server. The collection of state files make up the State Tree.

To start using a central state system in Salt you must first set up the Salt File Server. Edit your master config file (file_roots) and uncomment the following lines:

file_roots:
  base:
    - /srv/salt

Note
    If you are deploying on FreeBSD via ports, the file_roots path defaults to /usr/local/etc/salt/states.

Restart the Salt master in order to pick up this change:

% pkill salt-master
% salt-master -d

  Preparing the Top File

On the master in the directory you uncommented in the previous step (/srv/salt by default), create a new file called top.sls and add the following:

base:
  '*':
    - webserver

The top file is separated into environments (discussed later). The default environment is base. Under the base environment a collection of minion matches is defined; for now simply specify all hosts (*).

Targeting minions

    The expressions can use any of the targeting mechanisms used by Salt — minions can be matched by glob, pcre regular expression, or by grains. For example:

    base:
      'os:Fedora':
        - match: grain
        - webserver

  Create an sls module

In the same directory as your top file, create an empty file, called an SLS module, named webserver.sls. Type the following and save the file:

apache:                 # ID declaration
  pkg:                  # state declaration
    - installed         # function declaration

The first line, called the ID declaration, is an arbitrary identifier. In this case it defines the name of the package to be installed. NOTE: the package name for the Apache httpd web server may differ on your OS or distro — for example, on Fedora it is httpd but on Debian/Ubuntu it is apache2.

The second line, called the state declaration, defines which of the Salt States we are using. In this example, we are using the pkg state to ensure that a given package is installed.

The third line, called the function declaration, defines which function in the pkg state module to call.

Renderers

    States sls files can be written in many formats. Salt requires only a simple data structure and is not concerned with how that data structure is built. Templating languages and DSLs are a dime-a-dozen and everyone has a favorite.

    Building the expected data structure is the job of Salt renderers and they are dead-simple to write.

    In this tutorial we will be using YAML in Jinja2 templates, which is the default format. You can change the default by changing renderer in the master configuration file.

  Install the package

Next, let's run the state we created. Open a terminal on the master and run:

% salt '*' state.highstate

Our master is instructing all targeted minions to run state.highstate. When a minion executes a highstate call it will download the top file and attempt to match the expressions. When it does match an expression the modules listed for it will be downloaded, compiled, and executed.

Once completed, the minion will report back with a summary of all actions taken and all changes made.

Troubleshooting Salt

    In case you don't see the expected output, the following tips can help you narrow down the problem.

Turn up logging
    Salt can be quite chatty when you change the logging setting to debug:

    salt-minion -l debug

Run the minion in the foreground
    By not starting the minion in daemon mode (-d) you can view any output from the minion as it works:

    salt-minion &

    Increase the default timeout value when running salt. For example, to change the default timeout to 60 seconds:

    salt -t 60

    For best results, combine all three:

    salt-minion -l debug &          # On the minion
    salt '*' state.highstate -t 60  # On the master

  Next steps

This tutorial focused on getting a simple Salt States configuration working. Part 2 will build on this example to cover more advanced sls syntax and will explore more of the states that ship with Salt.

STATES TUTORIAL, PART 2

This tutorial builds on the topic covered in part 1. It is recommended that you begin there.

In the last Salt States tutorial we covered the basics of installing a package. In this tutorial we will modify our webserver.sls file to be more complicated, have requirements, and use even more Salt States.

  Call multiple States

You can specify multiple state declarations under an ID declaration. For example, a quick modification to our webserver.sls to also start Apache if it is not running:

apache:
  pkg:
    - installed
  service:
    - running

Try stopping Apache before running state.highstate once again and observe the output.

  Expand the SLS module

As you have seen, SLS modules are appended with the file extension .sls and are referenced by name starting at the root of the state tree. An SLS module can be also defined as a directory. Demonstrate that now by creating a directory named webserver and moving and renaming webserver.sls to webserver/init.sls. Your state directory should now resemble:

|- top.sls
`- webserver/
   `- init.sls

Organizing SLS modules

    You can place additional .sls files in a state file directory. This affords much cleaner organization of your state tree on the filesystem. For example, if we created a webserver/django.sls file that module would be referenced as webserver.django.

    In addition, States provide powerful includes and extending functionality which we will cover in Part 3.

  Require other states

We now have a working installation of Apache so let's add an HTML file to customize our website. It isn't exactly useful to have a website without a webserver so we don't want Salt to install our HTML file until Apache is installed and running. Include the following at the bottom of your webserver/init.sls file:

apache:
  pkg:
    - installed
  service:
    - running
/var/www/index.html:                        # ID declaration
  file:                                     # state declaration
    - managed                               # function
    - source: salt://webserver/index.html   # function arg
    - require:                              # requisite declaration
      - pkg: apache                         # requisite reference

line 7 is the ID declaration. In this example it is the location we want to install our custom HTML file. (Note: the default location that Apache serves may differ from the above on your OS or distro. /srv/www could also be a likely place to look.)

Line 8 the state declaration. This example uses the Salt file state.

Line 9 is the function declaration. The managed function will download a file from the master and install it in the location specified.

Line 10 is a function arg declaration which, in this example, passes the source argument to the managed function.

Line 11 is a requisite declaration.

Line 12 is a requisite reference which refers to a state and an ID. In this example, it is referring to the ID declaration from our example in part 1. This declaration tells Salt not to install the HTML file until Apache is installed.

Next, create the index.html file and save it in the webserver directory:

<html>
    <head><title>Salt rocks</title></head>
    <body>
        <h1>This file brought to you by Salt</h1>
    </body>
</html>

Last, call state.highstate again and the minion will fetch and execute the highstate as well as our HTML file from the master using Salt's File Server:

salt '*' state.highstate

Verify that Apache is now serving your custom HTML.

require vs. watch

    There are two requisite declarations, “require” and “watch”. Not every state supports “watch”. The service state does support “watch” and will restart a service based on the watch condition.

    For example, if you use Salt to install an Apache virtual host configuration file and want to restart Apache whenever that file is changed you could modify our Apache example from earlier as follows:

    /etc/httpd/extra/httpd-vhosts.conf:
      file:
        - managed
        - source: salt://webserver/httpd-vhosts.conf
    apache:
      pkg:
        - installed
      service:
        - running
        - watch:
          - file: /etc/httpd/extra/httpd-vhosts.conf

    If the pkg and service names differ on your OS or distro of choice you can specify each one separately using a name declaration which explained in Part 3.

  Next steps

In part 3 we will discuss how to use includes, extends and templating to make hugely complicated State Tree configurations dead-simple.

STATES TUTORIAL, PART 3

This tutorial builds on the topic covered in part 2. It is recommended that you begin there.

This tutorial will cover more advanced templating and configuration techniques for sls files.

  Templating SLS modules

SLS modules may require programming logic or inline executions. This is accomplished with module templating. The default module templating system used is Jinja2 and may be configured by changing the renderer value in the master config.

All states are passed through a templating system when they are initially read, so all that is required to make use of the templating system is to add some templating code. An example of an sls module with templating may look like this:

{% for usr in 'moe','larry','curly' %}
{{ usr }}:
  user:
    - present
{% endfor %}

This templated sls file once generated will look like this:

moe:
  user:
    - present
larry:
  user:
    - present
curly:
  user:
    - present

  Using Grains in SLS modules

Often times a state will need to behave differently on different systems. Salt grains can be used from within sls modules. An object called grains is made available in the template context:

apache:
  pkg:
    {% if grains['os'] == 'RedHat' %}
    - name: httpd
    {% elif grains['os'] == 'Ubuntu' %}
    - name: apache2
    {% endif %}
    - installed

  Calling Salt modules from templates

All of the Salt modules loaded by the minion are available within the templating system. This allows data to be gathered in real time on the target system. It also allows for shell commands to be run easily from within the sls modules.

The Salt module functions are also made available in the template context as salt:

{% for usr in 'moe','larry','curly' %}
{{ usr }}:
  group:
    - present
  user:
    - present
    - gid: {{ salt['file.group_to_gid'](usr) }}
    - require:
      - group: {{ usr }}
{% endfor %}

Below is an example that uses the network.hwaddr function to retrieve the MAC address for eth0: salt['network.hwaddr']('eth0')

  Advanced SLS module syntax

Last we will cover some incredibly useful techniques for more complex State trees.

  Include declaration

You have seen an example of how to spread a Salt tree across several files but in order to be able to have requisite references span multiple files you must use an include declaration. For example:

python-libs.sls:

python-dateutil:
  pkg:
    - installed

django.sls:

include:
  - python-libs
django:
  pkg:
    - installed
    - require:
      - pkg: python-dateutil

  Extend declaration

You can modify previous declarations by using an extend declaration. For example the following modifies the Apache tree to also restart Apache when the vhosts file is changed:

apache.sls:

apache:
  pkg:
    - installed

mywebsite.sls:

include:
  - apache
extend:
  apache:
    service:
      - watch:
        - file: /etc/httpd/extra/httpd-vhosts.conf
/etc/httpd/extra/httpd-vhosts.conf:
  file:
    - managed
    - source: salt://httpd-vhosts.conf

  Name declaration

You can override the ID declaration by using a name declaration. For example, the previous example is a bit more maintainable if rewritten as follows:

mywebsite.sls:

include:
  - apache
extend:
  apache
    service:
      - watch:
        - file: mywebsite
mywebsite:
  file:
    - managed
    - name: /etc/httpd/extra/httpd-vhosts.conf
    - source: salt://httpd-vhosts.conf

  Names declaration

Even more powerful is using a names declaration to override the ID declaration for multiple states at once. This often can remove the need for looping in a template. For example, the first example in this tutorial can be rewritten without the loop:

stooges:
  user:
    - present
    - names:
      - moe
      - larry
      - curly

  Continue learning

The best way to continue learning about Salt States is to read through the reference documentation and to look through examples of existing state trees. You can find examples in the salt-states repository and please send a pull-request on GitHub with any state trees that you build and want to share!

If you have any questions, suggestions, or just want to chat with other people who are using Salt we have an active community.

OPENING THE FIREWALL UP FOR SALT

The Salt master communicates with the minions using an AES-encrypted ZeroMQ connection. These communications are done over ports 4505 and 4506, which need to be accessible on the master only. This document outlines suggested firewall rules for allowing these incoming connections to the master.

Note
    No firewall configuration needs to be done on Salt minions. These changes refer to the master only.

  iptables

Different Linux distributions store their iptables rules in different places, which makes it difficult to standardize firewall documentation. I've included some of the more common locations, but your mileage may vary.

Fedora / Red Hat / CentOS

/etc/sysconfig/iptables

Arch Linux

/etc/iptables/iptables.rules

Debian

Follow these instructions: http://wiki.debian.org/iptables

Once you've found your firewall rules, you'll need to add the two lines below to allow traffic on tcp/4505 and tcp/4506:

+ -A INPUT -m state --state new -m tcp -p tcp --dport 4505 -j ACCEPT
+ -A INPUT -m state --state new -m tcp -p tcp --dport 4506 -j ACCEPT

Ubuntu

Create a file named /etc/ufw/applications.d/salt-master

[Salt Master]
title=Salt master
description=Salt is a remote execution and configuration management tool.
ports=4505,4506/tcp

  pf.conf

The BSD-family of operating systems uses packet filter (pf). The following example describes the additions to pf.conf needed to access the Salt master.

+ pass in on $int_if proto tcp from any to $int_if port 4505
+ pass in on $int_if proto tcp from any to $int_if port 4506

Once you've made these additions to your pf.conf you'll need to reload the new rules with the new additions. This can be done using the pfctl command.

pfctl -vf /etc/pf.conf

BOOTSTRAPPING SALT ON LINUX EC2 WITH CLOUD-INIT

Salt is a great tool for remote execution and configuration management, however you will still need to bootstrap the daemon when spinning up a new node. One option is to create and save a custom AMI, but this creates another resource to maintain and document.

A better method for Linux machines uses Canonical's CloudInit to run a bootstrap script during an EC2 Instance initialization. Cloud-init takes the user_data string passed into a new AWS instance and runs it in a manner similar to rc.local. The bootstrap script needs to:

1.  Install Salt with dependencies

2.  Point the minion to the master

    Here is a sample script:

    #!/bin/bash
    # Install saltstack
    add-apt-repository ppa:saltstack/salt -y
    apt-get update -y
    apt-get install salt -y
    apt-get upgrade -y
    # Set salt master location and start minion
    cp /etc/salt/minion.template /etc/salt/minion
    sed -i '' -e 's/#master: salt/master: [salt_master_fqdn]' /etc/salt/minion
    salt-minion -d

    First the script adds the saltstack ppa and installs the package. Then we copy over the minion config template and tell it where to find the master. You will have to replace [salt_master_fqdn] with something that resolves to your Salt master.

  Used With Boto

Boto will accept a string for user data which can be used to pass our bootstrap script. If the script is saved to a file, you can read it into a string:

import boto
user_data = open('salt_bootstrap.sh')
conn = boto.connect_ec2(<AWS_ACCESS_ID>, <AWS_SECRET_KEY>)
reservation = conn.run_instances(image_id=<ami_id>,
                                 key_name=<key_name>,
                                 user_data=user_data.read())

  Additional Notes

Sometime in the future the ppa will include and install an upstart file. In the meantime, you can use the bootstrap to build one.

It may also be useful to set the node's role during this phase. One option would be saving the node's role to a file and then using a custom Grain to select it.

PILLAR OF SALT

Pillar is an interface for Salt designed to offer global values that can be distributed to all minions. Pillar data is managed in a similar way to the Salt State Tree.

Pillar was added to Salt in version 0.9.8 as an experimental add on.

  Declaring the Master Pillar

The Salt Master server maintains a pillar_roots setup that matches the structure of the file_roots used in the Salt file server. Like the Salt file server the pillar_roots option in the master config is based on environments mapping to directories. The pillar data is then mapped to minions based on matchers in a top file which is laid out in the same way as the state top file.

The configuration for the pillar_roots in the master config is identical in behavior and function as the file_roots configuration:

pillar_roots:
  base:
    - /srv/pillar

This example configuration declares that the base environment will be located in the /srv/pillar directory. The top file used matches the name of the top file used for States, and has the same structure:

/srv/pillar/top.sls

base:
  '*':
    - packages
  'someminion':
    - someminion-specials

This simple pillar top file declares that information for all minions can be found in the packages.sls file [1], while someminion-specials.sls contains overriding or additional information just for one special minion.

/srv/pillar/packages.sls

{% if grains['os'] == 'RedHat' %}
apache: httpd
git: git
{% elif grains['os'] == 'Debian' %}
apache: apache2
git: git-core
{% endif %}
somekey: globalvalue

/srv/pillar/someminion-specials.sls

somekey: specialvalue

Now this data can be used from within modules, renderers, State SLS files, and more via the shared pillar dict:

apache:
  pkg:
    - installed
    - name: {{ pillar['apache'] }}

git:
  pkg:
    - installed
    - name: {{ pillar['git'] }}

To use pillar data in a file that is managed on a minion, use a file state like this:

/srv/salt/top.sls

base:
  '*':
    - managed_files

/srv/salt/managed_files.sls

/tmp/some-managed-file.txt:
  file:
    - managed
    - template: jinja
    - source: salt://files/some-managed-file.txt

/srv/salt/files/some-managed-file.txt

This will yield 'globalvalue' on all minions but will yield 'specialvalue'
on 'someminion':
somekey has value: {{ pillar['somekey'] }}

  Footnotes

[1] Note that you cannot just list key/value-information in top.sls.

  Refreshing Pillar Data

When pillar data is changed on the master the minions need to refresh the data locally. This is done with the saltutil.refresh_pillar function.

salt '*' saltutil.refresh_pillar

  Targeting with Pillar

Pillar data can be used when targeting minions. This allows for ultimate control and flexibility when targeting minions.

salt -I 'somekey:specialvalue' test.ping

JOB MANAGEMENT

New in version 0.9.7.

Since Salt executes jobs running on many systems, Salt needs to be able to manage jobs running on many systems. As of Salt 0.9.7, the capability was added for more advanced job management.

  The Minion proc System

The Salt Minions now maintain a proc directory in the Salt cachedir, the proc directory maintains files named after the executed job ID. These files contain the information about the current running jobs on the minion and allow for jobs to be looked up. This is located in the proc directory under the cachedir, with a default configuration it is under /var/cache/salt/proc.

  Functions in the saltutil Module

Salt 0.9.7 introduced a few new functions to the saltutil module for managing jobs. These functions are:

1.  running Returns the data of all running jobs that are found in the proc directory.

2.  find_job Returns specific data about a certain job based on job id.

3.  signal_job Allows for a given jid to be sent a signal.

4.  term_job Sends a termination signal (SIGTERM, 15) to the process controlling the specified job.

5.  kill_job Sends a kill signal (SIGKILL, 9) to the process controlling the specified job.

    These functions make up the core of the back end used to manage jobs at the minion level.

  The jobs Runner

A convenience runner front end and reporting system has been added as well. The jobs runner contains functions to make viewing data easier and cleaner.

The jobs runner contains a number of functions...

  active

The active function runs saltutil.running on all minions and formats the return data about all running jobs in a much more usable and compact format. The active function will also compare jobs that have returned and jobs that are still running, making it easier to see what systems have completed a job and what systems are still being waited on.

# salt-run jobs.active

  lookup_jid

When jobs are executed the return data is sent back to the master and cached. By default is is cached for 24 hours, but this can be configured via the keep_jobs option in the master configuration. Using the lookup_jid runner will display the same return data that the initial job invocation with the salt command would display.

# salt-run jobs.lookup_jid <job id number>

  list_jobs

Before finding a historic job, it may be required to find the job id. list_jobs will parse the cached execution data and display all of the job data for jobs that have already, or partially returned.

# salt-run jobs.list_jobs

RUNNING THE SALT MASTER AS UNPRIVILEGED USER

While the default setup runs the Salt Master as the root user, it is generally wise to run servers as an unprivileged user. In Salt 0.9.10 the management of the running user was greatly improved, the only change needed is to alter the option user in the master configuration file and all salt system components will be updated to function under the new user when the master is started.

If running a version older that 0.9.10 then a number of files need to be owned by the user intended to run the master:

# chown -R <user> /var/cache/salt
# chown -R <user> /var/log/salt
# chown -R <user> /etc/salt/pki

TROUBLESHOOTING

The intent of the troubleshooting section is to introduce solutions to a number of common issues encountered by users and the tools that are available to aid in developing States and Salt code.

  Running in the Foreground

A great deal of information is available via the debug logging system, if you are having issues with minions connecting or not starting run the minion and/or master in the foreground:

# salt-master -l debug
# salt-minion -l debug

Anyone wanting to run Salt daemons via a process supervisor such as monit, runit, or supervisord, should omit the -d argument to the daemons and run them in the foreground.

  What Ports do the Master and Minion Need Open?

No ports need to be opened up on each minion. For the master, TCP ports 4505 and 4506 need to be open. If you've put both your Salt master and minion in debug mode and don't see an acknowledgement that your minion has connected, it could very well be a firewall.

You can check port connectivity from the minion with the nc command:

# nc -v -z salt.master.ip 4505
# nc -v -z salt.master.ip 4506

There is also a firewall configuration document that might help as well.

If you've enabled the right TCP ports on your operating system or Linux distribution's firewall and still aren't seeing connections, check that no additional access control system such as SELinux or AppArmor is blocking Salt.

  Using salt-call

The salt-call command was originally developed for aiding in the development of new Salt modules. Since then, many applications have been developed for running any Salt module locally on a minion. These range from the original intent of salt-call, development assistance, to gathering more verbose output from calls like state.highstate.

When developing the State Tree it is generally recommended to invoke state.highstate with salt-call. This displays far more information about the highstate execution than calling it remotely. For even more verbosity, increase the loglevel with the same argument as salt-minion:

salt-call -l debug state.highstate

  Too many open files

The salt-master needs at least 2 sockets per host that connects to it, one for the Publisher and one for response port. Thus, large installations may, upon scaling up the number of minions accessing a given master, encounter:

12:45:29,289 [salt.master    ][INFO    ] Starting Salt worker process 38
Too many open files
sock != -1 (tcp_listener.cpp:335)

The solution to this would be to check the number of files allowed to be opened by the user running salt-master (root by default):

[root@salt-master ~]# ulimit -n
1024

And modify that value to be at least equal to the number of minions x 2. This setting can be changed in limits.conf as the nofile value(s), and activated upon new a login of the specified user.

So, an environment with 1800 minions, would need 1800 x 2 = 3600 as a minimum.

  Salt Master Stops Responding

There are known bugs with ZeroMQ versions less than 2.1.11 which can cause the Salt master to not respond properly. If you're running a ZeroMQ version greater than or equal to 2.1.9, you can work around the bug by setting the sysctls net.core.rmem_max and net.core.wmem_max to 16777216. Next, set the third field in net.ipv4.tcp_rmem and net.ipv4.tcp_wmem to at least 16777216.

You can do it manually with something like:

# echo 16777216 > /proc/sys/net/core/rmem_max
# echo 16777216 > /proc/sys/net/core/wmem_max
# echo "4096 87380 16777216" > /proc/sys/net/ipv4/tcp_rmem
# echo "4096 87380 16777216" > /proc/sys/net/ipv4/tcp_wmem

Or with the following Salt state:

net.core.rmem_max:
  sysctl:
    - present
    - value: 16777216
net.core.wmem_max:
  sysctl:
    - present
    - value: 16777216
net.ipv4.tcp_rmem:
  sysctl:
    - present
    - value: 4096 87380 16777216
net.ipv4.tcp_wmem:
  sysctl:
    - present
    - value: 4096 87380 16777216

  Salt and SELinux

Currently there are no SELinux policies for Salt. For the most part Salt runs without issue when SELinux is running in Enforcing mode. This is because when the minion executes as a daemon the type context is changed to initrc_t. The problem with SELinux arises when using salt-call or running the minion in the foreground, since the type context stays unconfined_t.

This problem is generally manifest in the rpm install scripts when using the pkg module. Until a full SELinux Policy is available for Salt the solution to this issue is to set the execution context of salt-call and salt-minion to rpm_exec_t:

# chcon -t system_u:system_r:rpm_exec_t:s0 /usr/bin/salt-minion
# chcon -t system_u:system_r:rpm_exec_t:s0 /usr/bin/salt-call

This works well, because the rpm_exec_t context has very broad control over other types.

  Red Hat Enterprise Linux 5

Salt requires Python 2.6 or 2.7. Red Hat Enterprise Linux 5 and its variants come with Python 2.4 installed by default. When installing on RHEL 5 from the EPEL repository this is handled for you. But, if you run Salt from git, be advised that its dependencies need to be installed from EPEL and that Salt needs to be run with the python26 executable.

  Common YAML Gotchas

An extensive list of YAML idiosyncrasies has been compiled.

YAML IDIOSYNCRASIES

One of Salt's strengths, the use of existing serialization systems for representing SLS data, can also backfire. YAML is a general purpose system and there are a number of things that would seem to make sense in an sls file that cause YAML issues. It is wise to be aware of these issues. While reports or running into them are generally rare they can still crop up at unexpected times.

  Spaces vs Tabs

YAML uses spaces, period. Do not use tabs in your SLS files! If strange errors are coming up in rendering SLS files, make sure to check that no tabs have crept in! In vi / vim, you can check with :se spell.

  Indentation

The suggested syntax for YAML files is to use 2 spaces for indentation, but YAML will follow whatever indentation system that the individual file uses. Indentation of two spaces works very well for SLS files given the fact that the data is uniform and not deeply nested.

  Nested Dicts (key=value)

When dicts: are more deeply nested, they no longer follow the same indentation logic. This is rarely something that comes up in Salt, since deeply nested options like these are discouraged when making State modules, but some do exist. A good example is the context and default options in the file.managed state:

/etc/http/conf/http.conf:
  file:
    - managed
    - source: salt://apache/http.conf
    - user: root
    - group: root
    - mode: 644
    - template: jinja
    - context:
        custom_var: "override"
    - defaults:
        custom_var: "default value"
        other_var: 123

Notice that the spacing used is 2 spaces, and that when defining the context and defaults options there is a 4 space indent. If only a 2 space indent is used then the information will not be loaded correctly. If using double spacing is not desirable, then a deeply nested dict can be declared with curly braces:

/etc/http/conf/http.conf:
  file:
    - managed
    - source: salt://apache/http.conf
    - user: root
    - group: root
    - mode: 644
    - template: jinja
    - context: {
      custom_var: "override" }
    - defaults: {
      custom_var: "default value",
      other_var: 123 }

  Integers are Parsed as Integers

NOTE: This has been fixed in salt 0.9.10, as of this release passing an integer that is preceded by a 0 will be correctly parsed

When passing integers into an SLS file, they are passed as integers. This means that if a state accepts a string value and an integer is passed, that an integer will be sent. The solution here is to send the integer as a string.

This is best explained when setting the mode for a file:

/etc/vimrc:
  file:
    - managed
    - source: salt://edit/vimrc
    - user: root
    - group: root
    - mode: 644

Salt manages this well, since the mode is passed as 644, but if the mode is zero padded as 0644, then it is read by YAML as an integer and evaluated as a hexadecimal value, 0644 becomes 420. Therefore, if the file mode is preceded by a 0 then it needs to be passed as a string:

/etc/vimrc:
  file:
    - managed
    - source: salt://edit/vimrc
    - user: root
    - group: root
    - mode: '0644'

  YAML does not like Double Short Decs

If I can find a way to make YAML accept "Double Short Decs" then I will, since I think that double short decs would be awesome. So what is a "Double Short Dec"? It is when you declare a multiple short decs in one ID. Here is a standard short dec, it works great:

vim:
  pkg.installed

The short dec means that there are no arguments to pass, so it is not required to add any arguments, and it can save space.

YAML though, gets upset when declaring multiple short decs, for the record...

THIS DOES NOT WORK:

vim:
  pkg.installed
  user.present

Similarly declaring a short dec in the same ID dec as a standard dec does not work either...

ALSO DOES NOT WORK:

fred:
  user.present
  ssh.present:
    - name: AAAAB3NzaC...
    - enc: dsa

So, to make these work they would need to be defined the "old way", or with multiple "full decs"

WORKS:

vim:
  pkg:
    - installed
  user:
    - present
fred:
  user:
    - present
  ssh.present:
    - name: AAAAB3NzaC...
    - enc: dsa

COMMUNITY

Join the Salt!

There are many ways to participate in and communicate with the Salt community.

Salt has an active IRC channel and a mailing list.

  Mailing List

Join the salt-users mailing list. It is the best place to ask questions about Salt and see whats going on with Salt development! The Salt mailing list is hosted by Google Groups. It is open to new members.

https://groups.google.com/forum/#!forum/salt-users

  IRC

The #salt IRC channel is hosted on the popular Freenode network. You can use the Freenode webchat client right from your browser.

Logs of the IRC channel activity are being collected courtesy of Moritz Lenz.

  Follow on Github

The Salt code is developed via Github. Follow Salt for constant updates on what is happening in Salt development:

https://github.com/saltstack/salt

  The Red45 Blog

News and thoughts on Salt and related projects is often posted on Thomas' blog The Red45:

http://red45.wordpress.com/

  Example Salt States

The official salt-states repository is: https://github.com/saltstack/salt-states

A few examples of salt states from the community:

•   https://github.com/blast-hardcheese/blast-salt-states

•   https://github.com/kevingranade/kevingranade-salt-state

•   https://github.com/uggedal/states

•   https://github.com/mattmcclean/salt-openstack/tree/master/salt

  Follow on ohloh

https://www.ohloh.net/p/salt

  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.

  Posting patches to the mailing list

If you have a patch for Salt, please format it via 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.

  Setting a Github pull request

This is probably the preferred method for contributions, simply create a Github fork, commit your changes to the fork, and then open up a pull request.

  Contributions Welcome!

The goal here it to make contributions clear, make sure there is a trail for where the code has come from, but most importantly, to give credit where credit is due!

The Open Comparison Contributing Docs has some good suggestions and tips for those who are looking forward to contribute.

STANDALONE MINION

Since the Salt minion contains such extensive functionality it can be useful to run it standalone. A standalone minion can be used to do a number of things:

•   Stand up a master server via States (Salting a Salt Master)

•   Use salt-call commands on a system without connectivity to a master

•   Masterless States, run states entirely from files local to the minion

  Telling Salt Call to Run Masterless

The salt-call command is used to run module functions locally on a minion instead of executing them from the master. Normally the salt-call command checks into the master to retrieve file server and pillar data, but when running standalone salt-call needs to be instructed to not check the master for this data. To instruct the minion to not look for a master when running salt-call the file_client configuration option needs to be set. By default the file_client is set to remote so that the minion knows that file server and pillar data are to be gathered from the master. When setting the file_client option to local the minion is configured to not gather this data from the master.

file_client: local

Now the salt-call command will not look for a master and will assume that the local system has all of the file ad pillar resources.

  Running States Masterless

The state system can be easily run without a Salt master, with all needed files local to the minion. To do this the minion configuration file needs to be set up to know how to return file_roots information like the master. The file_roots setting defaults to /srv/salt for the base environment just like on the master:

file_roots:
  base:
    - /srv/salt

Now set up the Salt State Tree, top file, and SLS modules in the same way that they would be set up on a master. Now, with the file_client option set to local and an available state tree then calls to functions in the state module will use the information in the file_roots on the minion instead of checking in with the master.

Remember that when creating a state tree on a minion there are no syntax or path changes needed, SLS modules written to be used from a master do not need to be modified in any way to work with a minion.

This makes it easy to "script" deployments with Salt states without having to set up a master, and allows for these SLS modules to be easily moved into a Salt master as the deployment grows.

SALT BASED PROJECTS

A number of unofficial open source projects, based on Salt, or written to enhance Salt have been created.

  Salt Sandbox

Created by Aaron Bull Schaefer, aka "elasticdog".

https://github.com/elasticdog/salt-sandbox

Salt Sandbox is a multi-VM Vagrant-based Salt development environment used for creating and testing new Salt state modules outside of your production environment. It's also a great way to learn firsthand about Salt and its remote execution capabilities.

Salt Sandbox will set up three separate virtual machines:

•   salt.example.com - the Salt master server

•   minion1.example.com - the first Salt minion machine

•   minion2.example.com - the second Salt minion machine

    These VMs can be used in conjunction to segregate and test your modules based on node groups, top file environments, grain values, etc. You can even test modules on different Linux distributions or release versions to better match your production infrastructure.

SALT EVENT SYSTEM

Salt 0.9.10 introduced the Salt Event System. This system is used to fire off events enabling third party applications or external processes to react to behavior within Salt.

The event system is comprised of a few components, the event sockets which publish events, and the event library which can listen to events and send events into the salt system.

  Listening for Events

The event system is accessed via the event library and can only be accessed by the same system user that Salt is running as. To listen to events a SaltEvent object needs to be created and then the get_event function needs to be run. The SaltEvent object needs to know the location that the Salt unix sockets are kept. In the configuration this is the sock_dir option. The sock_dir option defaults to "/tmp/.salt-unix" on most systems.

The following code will check for a single event:

import salt.utils.event
event = salt.utils.event.MasterEvent('/tmp/.salt-unix')
data = event.get_event()

Events will also use a "tag". A "tag" allows for events to be filtered. By default all events will be returned, but if only authentication events are desired, then pass the tag "auth". Also, the get_event method has a default poll time assigned of 5 seconds, to change this time set the "wait" option. This example will only listen for auth events and will wait for 10 seconds instead of the default 5.

import salt.utils.event
event = salt.utils.event.MasterEvent('/tmp/.salt-unix')
data = event.get_event(wait=10, tag='auth')

Instead of looking for a single event, the iter_event method can be used to make a generator which will continually yield salt events. The iter_event method also accepts a tag, but not a wait time:

import salt.utils.event
event = salt.utils.event.MasterEvent('/tmp/.salt-unix')
for data in event.iter_event(tag='auth'):
    print(data)

INTRODUCTION TO EXTENDING SALT

Salt is made to be used, and made to be extended. The primary goal of Salt is to provide a foundation which can be used to solve problems. And the goal of Salt is to not assume what those problems might be.

One of the greatest benefit of developing Salt has been the vast array of ways in which people have wanted to use it, while the original intention was as a communication layer for a cloud controller Salt has been extended to facilitate so much more.

  Client API

The primary interface used to extend Salt, is to simply use it. Salt executions can be called via the Salt client api, making programming master side solutions with Salt is easy.

  Adding Loadable Plugins

Salt is comprised of a core platform that loads many types of easy to write plugins. The idea is to enable all of the breaking points in the Salt processes to have a point of pluggable interaction. This means that all of the main features of Salt can be extended, modified or used.

The breaking points and helping interfaces span from convenience master side executions to manipulating the flow of how data is handled by Salt.

  Minion Execution Modules

The minion execution modules or just modules are the core to what Salt is and does. These modules are found in:

https://github.com/saltstack/salt/blob/v0.10.0/salt/modules

These modules are what is called by the Salt command line and the salt client API. Adding modules is done by simply adding additional Python modules to the modules directory and restarting the minion.

  Grains

Salt grains, or "grains of truth" are bits of static information that are generated when the minion starts. This information is useful when determining what package manager to default to, or where certain configuration files are stored on the minion.

The Salt grains are the interface used for auto detection and dynamic assignment of execution modules and types to specific Salt minions.

The code used to generate the Salt grains can be found here:

https://github.com/saltstack/salt/blob/v0.10.0/salt/grains

  States

Salt supports state enforcement, this makes Salt a high speed and very efficient solution for system configuration management.

States can be easily added to Salt by dropping a new state module in:

https://github.com/saltstack/salt/blob/v0.10.0/salt/states

  Renderers

Salt states are controlled by simple data structures, these structures can be abstracted in a number of ways. While the default is to be in a yaml file wrapped in a jinja template, any abstraction can be used. This means that any format that can be dreamed is possible, so long as a renderer is written for it.

The existing renderers can be found here:

https://github.com/saltstack/salt/blob/v0.10.0/salt/renderers

  Returners

The Salt commands all produce a return value, that return value is sent to the Salt master by default, but it can be sent anywhere. The returner interface makes it programmatically possible for the information to be sent to anything from an SQL or NoSQL database, to a custom application made to use Salt.

The existing returners can be found here:

https://github.com/saltstack/salt/blob/v0.10.0/salt/returners

  Runners

Sometimes a certain application can be made to execute and run from the existing Salt command line. This is where the Salt runners come into play. The Salt Runners what is called by the Salt-run command and are meant to act as a generic interface for encapsulating master side executions.

Existing Salt runners are located here:

https://github.com/saltstack/salt/blob/v0.10.0/salt/runners

MODULES

Salt modules are the functions called by the salt command.

See also

    Full list of builtin modules

    Salt ships with many modules that cover a wide variety of tasks.

  Easy Modules to write

Salt modules are amazingly simple to write. Just write a regular Python module or a regular Cython module and place it in the salt/modules directory. You can also place them in a directory called _modules/ in your state directory.

Since Salt modules are just Python/Cython modules, there are no restraints on what you can put inside of a Salt module. If a Salt module has errors and cannot be imported, the Salt minion will continue to load without issue and the module with errors will simply be omitted.

If adding a Cython module the file must be named <modulename>.pyx so that the loader knows that the module needs to be imported as a Cython module. The compilation of the Cython module is automatic and happens when the minion starts, so only the *.pyx file is required.

  Cross Calling Modules

All of the Salt modules are available to each other, and can be "cross called". This means that, when creating a module, functions in modules that already exist can be called.

The variable __salt__ is packed into the modules after they are loaded into the Salt minion. This variable is a Python dictionary of all of the Salt functions, laid out in the same way that they are made available to the Salt command.

Salt modules can be cross called by accessing the value in the __salt__ dict:

def foo(bar):
    return __salt__['cmd.run'](bar)

This code will call the Salt cmd module's run function and pass the argument bar.

  Preloaded Modules Data

When interacting with modules often it is nice to be able to read information dynamically about the minion, or load in configuration parameters for a module. Salt allows for different types of data to be loaded into the modules by the minion, as of this writing Salt loads information gathered from the Salt Grains system and from the minion configuration file.

  Grains Data

The Salt minion detects information about the system when started. This allows for modules to be written dynamically with respect to the underlying hardware and operating system. This information is referred to as Salt Grains, or "grains of salt". The Grains system was introduced to replace Facter, since relying on a Ruby application from a Python application was both slow and inefficient. Grains support replaces Facter in all Salt releases after 0.8

The values detected by the Salt Grains on the minion are available in a dict named __grains__ and can be accessed from within callable objects in the Python modules.

To see the contents of the grains dict for a given system in your deployment run the grains.items() function:

salt 'hostname' grains.items

To use the __grains__ dict simply call it as a Python dict from within your code, an excellent example is available in the Grains module: salt.modules.grains.

  Module Configuration

Since parameters for configuring a module may be desired, Salt allows for configuration information stored in the main minion config file to be passed to the modules.

Since the minion configuration file is a YAML document, arbitrary configuration data can be passed in the minion config that is read by the modules. It is strongly recommended that the values passed in the configuration file match the module. This means that a value intended for the test module should be named test.<value>.

Configuration also requires that default configuration parameters need to be loaded as well. This can be done simply by adding the __opts__ dict to the top level of the module.

The test module contains usage of the module configuration, and the default configuration file for the minion contains the information and format used to pass data to the modules. salt.modules.test, conf/minion.

  Printout Configuration

Since module functions can return different data, and the way the data is printed can greatly change the presentation, Salt has a printout configuration.

When writing a module the __outputter__ dict can be declared in the module. The __outputter__ dict contains a mapping of function name to Salt Outputter.

__outputter__ = {
                'run': 'txt'
                }

This will ensure that the text outputter is used.

  Virtual Modules

Sometimes a module should be presented in a generic way. A good example of this can be found in the package manager modules. The package manager changes from one operating system to another, but the Salt module that interfaces with the package manager can be presented in a generic way.

The Salt modules for package managers all contain a __virtual__ function which is called to define what systems the module should be loaded on.

The __virtual__ function is used to return either a string or False. If False is returned then the module is not loaded, if a string is returned then the module is loaded with the name of the string.

This means that the package manager modules can be presented as the pkg module regardless of what the actual module is named.

The package manager modules are the best example of using the __virtual__ function: https://github.com/saltstack/salt/blob/v0.10.0/salt/modules/pacman.py https://github.com/saltstack/salt/blob/v0.10.0/salt/modules/yumpkg.py https://github.com/saltstack/salt/blob/v0.10.0/salt/modules/apt.py

  Documentation

Salt modules are self documenting, the sys.doc() function will return the documentation for all available Facter modules:

salt '*' sys.doc

This function simple prints out the docstrings found in the modules, when writing Salt modules, please follow the formating conventions for docstrings as they appear in the other modules.

  Adding Documentation to Salt Modules

Since life is much better with documentation, it is strongly suggested that all Salt modules have documentation added. Any Salt modules submitted for inclusion in the main distribution of Salt will be required to have documentation.

Documenting Salt modules is easy! Just add a Python docstring to the function.

def spam(eggs):
    '''
    A function to make some spam with eggs!
    CLI Example::
        salt '*' test.spam eggs
    '''
    return eggs

Now when the sys.doc call is executed the docstring will be cleanly returned to the calling terminal.

  How Functions are Read

In Salt, Python callable objects contained within a module are made available to the Salt minion for use. The only exception to this rule is a callable object with a name starting with an underscore _.

  Objects Loaded Into the Salt Minion

def foo(bar):
    return bar
class baz:
    def __init__(self, quo):
        pass

  Objects NOT Loaded into the Salt Minion

def _foobar(baz): # Preceded with an _
    return baz
cheese = {} # Not a callable Python object

  Examples of Salt Modules

The existing Salt modules should be fairly easy to read and understand, the goal of the main distribution's Salt modules is not only to build a set of functions for Salt, but to stand as examples for building out more Salt modules.

The existing modules can be found here: https://github.com/saltstack/salt/blob/v0.10.0/salt/modules

The most simple module is the test module, it contains the simplest Salt function, test.ping:

def ping():
    '''
    Just used to make sure the minion is up and responding
    Return True
    CLI Example::
        salt '*' test.ping
    '''
    return True

FULL LIST OF BUILTIN MODULES

Virtual modules

  salt.modules.pkg

pkg is a virtual module that is fulfilled by one of the following modules:

•   salt.modules.apt

•   salt.modules.ebuild

•   salt.modules.freebsdpkg

•   salt.modules.pacman

•   salt.modules.yumpkg

•   salt.modules.yumpkg5

•   salt.modules.zypper

•   salt.modules.brew

•   salt.modules.win_pkg

  salt.modules.sys

The regular salt modules execute in a separate context from the salt minion and manipulating the actual salt modules needs to happen in a higher level context within the minion process. This is where the sys pseudo module is used.

The sys pseudo module comes with a few functions that return data about the available functions on the minion or allows for the minion modules to be refreshed. These functions are as follows:

salt.modules.sys.doc([module[, module.function]])
    Display the inline documentation for all available modules, or for the specified module or function.

salt.modules.sys.reload_modules()
    Instruct the minion to reload all available modules in memory. This function can be called if the modules need to be re-evaluated for availability or new modules have been made available to the minion.

salt.modules.sys.list_modules()
    List all available (loaded) modules.

salt.modules.sys.list_functions()
    List all known functions that are in available (loaded) modules.
aliases | Manage the information in the aliases file
apache | Support for Apache
apt | Support for APT (Advanced Packaging Tool)
archive | A module to wrap archive calls
brew |
butterkvm | Specialized routines used by the butter cloud component
cluster | The cluster module is used to distribute and activate salt HA cluster
cmdmod | A module for shelling out
cp | Minion side functions for salt-cp
cron | Work with cron
data | Manage a local persistent data structure that can hold any arbitrary data
debconfmod | Support for Debconf
disk | Module for gathering disk information
django | Manage Django sites
ebuild | Support for Portage
file | Manage information about files on the minion, set/read user, group, and mode
freebsdjail | The jail module for FreeBSD
freebsdkmod | Module to manage FreeBSD kernel modules
freebsdpkg | Package support for FreeBSD
freebsdservice | The service module for FreeBSD
gem | Manage ruby gems.
gentoo_service | Top level package command wrapper, used to translate the os detected by the
git | Support for the Git SCM
grains | Control aspects of the grains data
groupadd | Manage groups on Linux
grub | Support for GRUB
hg | Support for the Mercurial SCM
hosts | Manage the information in the hosts file
kmod | Module to manage Linux kernel modules
kvm_hyper | Provide the hyper module for kvm hypervisors.
launchctl | Module for the management of MacOS systems that use launchd/launchctl
linux_sysctl | Module for viewing and modifying sysctl parameters
mdadm | Salt module to manage RAID arrays with mdadm
moosefs | Module for gathering and managing information about MooseFS
mount | Salt module to manage unix mounts and the fstab file
mysql | Module to provide MySQL compatibility to salt.
network | Module for gathering and managing network information
nginx | Support for nginx
osxdesktop | Mac OS X implementations of various commands in the "desktop" interface
pacman | A module to wrap pacman calls, since Arch is the best
pillar | Extract the pillar data for this minion
pip | Install Python packages with pip to either the system or a virtualenv
postgres | Module to provide Postgres compatibility to salt.
ps | A salt interface to psutil, a system and process library.
publish | Publish a command from a minion to a target
puppet | Execute puppet routines
pw_group | Manage groups on FreeBSD
pw_user | Manage users with the useradd command
rabbitmq_server | Module to provide rabbitMQ compatibility to salt.
reg | Manage the registry on Windows
rh_ip | The networking module for RHEL/Fedora based distros
rh_service | Service support for classic Red Hat type systems. This interface uses the
rvm | Manage ruby installations and gemsets with RVM, the Ruby Version Manager.
saltutil | The Saltutil module is used to manage the state of the salt minion itself. It is
selinux | Execute calls on selinux
service | The default service module, if not otherwise specified salt will fall back
shadow | Manage the shadow file
solr | Apache Solr Salt Module
sqlite3 | Support for SQLite3
ssh | Manage client ssh components
state | Control the state system on the minion
status | Module for returning various status data about a minion.
systemd | Provide the service module for systemd
test | Module for running arbitrary tests
tomcat | Support for Tomcat
upstart | Module for the management of upstart systems.
useradd | Manage users with the useradd command
virt | Work with virtual machines managed by libvirt
virtualenv | Create virtualenv environments
win_disk | Module for gathering disk information on Windows
win_file | Manage information about files on the minion, set/read user, group
win_groupadd | Manage groups on Windows
win_network | Module for gathering and managing network information
win_pkg | A module to manage software on Windows
win_service | Windows Service module.
win_shadow | Manage the shadow file
win_useradd | Manage Windows users with the net user command
yumpkg | Support for YUM
yumpkg5 | Support for YUM
zypper | Package support for openSUSE via the zypper package manager

  salt.modules.aliases

Manage the information in the aliases file

salt.modules.aliases.get_target(alias)
    Return the target associated with an alias

    CLI Example:

    salt '*' aliases.get_target <alias>

salt.modules.aliases.has_target(alias, target)
    Return true if the alias/target is set

    CLI Example:

    salt '*' aliases.has_target <alias> <target>

salt.modules.aliases.list_aliases()
    Return the aliases found in the aliases file in this format:

    {'<alias>': '<target>'}

    CLI Example:

    salt '*' aliases.list_aliases

salt.modules.aliases.rm_alias(alias)
    Remove an entry from the aliases file

    CLI Example:

    salt '*' aliases.rm_alias <alias>

salt.modules.aliases.set_target(alias, target)
    Set the entry in the aliases file for the given alias, this will overwrite any previous entry for the given alias or create a new one if it does not exist.

    CLI Example:

    salt '*' aliases.set_target <alias> <target>

  salt.modules.apache

Support for Apache

salt.modules.apache.directives()
    Return list of directives together with expected arguments and places where the directive is valid (apachectl -L)

    CLI Example:

    salt '*' apache.directives

salt.modules.apache.fullversion()
    Return server version from apachectl -V

    CLI Example:

    salt '*' apache.fullversion

salt.modules.apache.modules()
    Return list of static and shared modules from apachectl -M

    CLI Example:

    salt '*' apache.modules

salt.modules.apache.servermods()
    Return list of modules compiled into the server (apachectl -l)

    CLI Example:

    salt '*' apache.servermods

salt.modules.apache.signal(signal=None)
    Signals httpd to start, restart, or stop.

    CLI Example:

    salt '*' apache.signal restart

salt.modules.apache.version()
    Return server version from apachectl -v

    CLI Example:

    salt '*' apache.version

salt.modules.apache.vhosts()
    Show the settings as parsed from the config file (currently only shows the virtualhost settings). (apachectl -S) Because each additional virtual host adds to the execution time, this command may require a long timeout be specified.

    CLI Example:

    salt -t 10 '*' apache.vhosts

  salt.modules.apt

Support for APT (Advanced Packaging Tool)

salt.modules.apt.available_version(name)
    Return the latest version of the named package available for upgrade or installation via the available apt repository

    CLI Example:

    salt '*' pkg.available_version <package name>

salt.modules.apt.install(pkg, refresh=False, repo='', skip_verify=False, debconf=None, version=None, **kwargs)
    Install the passed package

pkg The name of the package to be installed

refresh
    False Update apt before continuing

repo
    (default) Specify a package repository to install from (e.g., apt-get -t unstable install somepackage)

skip_verify
    False Skip the GPG verification check (e.g., --allow-unauthenticated)

debconf
    None Provide the path to a debconf answers file, processed before installation.

version
    None Install a specific version of the package, e.g. 1.0.9~ubuntu

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
            'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.install <package name>

salt.modules.apt.list_pkgs(regex_string='')
    List the packages currently installed in a dict:

    {'<package_name>': '<version>'}

    External dependencies:

    Virtual package resolution requires aptitude.
    Without aptitude virtual packages will be reported as not installed.

    CLI Example:

    salt '*' pkg.list_pkgs
    salt '*' pkg.list_pkgs httpd

salt.modules.apt.list_upgrades()
    List all available package upgrades.

    CLI Example:

    salt '*' pkg.list_upgrades

salt.modules.apt.purge(pkg)
    Remove a package via apt-get purge along with all configuration files and unused dependencies.

    Returns a list containing the names of the removed packages

    CLI Example:

    salt '*' pkg.purge <package name>

salt.modules.apt.refresh_db()
    Updates the APT database to latest packages based upon repositories

    Returns a dict:

    {'<database name>': Bool}

    CLI Example:

    salt '*' pkg.refresh_db

salt.modules.apt.remove(pkg)
    Remove a single package via apt-get remove

    Returns a list containing the names of the removed packages.

    CLI Example:

    salt '*' pkg.remove <package name>

salt.modules.apt.upgrade(refresh=True, **kwargs)
    Upgrades all packages via apt-get dist-upgrade

    Returns a list of dicts containing the package names, and the new and old versions:

    [
        {'<package>':  {'old': '<old-version>',
                    'new': '<new-version>']
        }',
        ...
    ]

    CLI Example:

    salt '*' pkg.upgrade

salt.modules.apt.upgrade_available(name)
    Check whether or not an upgrade is available for a given package

    CLI Example:

    salt '*' pkg.upgrade_available <package name>

salt.modules.apt.version(name)
    Returns a string representing the package version or an empty string if not installed

    CLI Example:

    salt '*' pkg.version <package name>

  salt.modules.archive

A module to wrap archive calls

salt.modules.archive.gunzip(gzipfile)
    Uses the gunzip command to unpack gzip files

    CLI Example to create /tmp/sourcefile.txt:

    salt '*' archive.gunzip /tmp/sourcefile.txt.gz

salt.modules.archive.gzip(sourcefile)
    Uses the gzip command to create gzip files

    CLI Example to create /tmp/sourcefile.txt.gz:

    salt '*' archive.gzip /tmp/sourcefile.txt

salt.modules.archive.rar(rarfile, *sources)
    Uses the rar command to create rar files Uses rar for Linux from http://www.rarlab.com/

    CLI Example:

    salt '*' archive.rar /tmp/rarfile.rar /tmp/sourcefile1 /tmp/sourcefile2

salt.modules.archive.tar(options, tarfile, *sources)
    Uses the tar command to pack, unpack, etc tar files

    CLI Example:

    salt '*' archive.tar cjvf /tmp/tarfile.tar.bz2 /tmp/file1 /tmp/file2

salt.modules.archive.unrar(rarfile, dest, *xfiles)
    Uses the unrar command to unpack rar files Uses rar for Linux from http://www.rarlab.com/

    CLI Example:

    salt '*' archive.unrar /tmp/rarfile.rar /home/strongbad/ file1 file2

salt.modules.archive.unzip(zipfile, dest, *xfiles)
    Uses the unzip command to unpack zip files

    CLI Example:

    salt '*' archive.unzip /tmp/zipfile.zip /home/strongbad/ file1 file2

salt.modules.archive.zip(zipfile, *sources)
    Uses the zip command to create zip files

    CLI Example:

    salt '*' archive.zip /tmp/zipfile.zip /tmp/sourcefile1 /tmp/sourcefile2

  salt.modules.brew

salt.modules.brew.install(pkgs)
    Install the passed package(s) with brew install

pkgs
    The names of the packages to be installed

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.install 'package package package'

salt.modules.brew.list_pkgs(*args)
    List the packages currently installed in a dict:

    {'<package_name>': '<version>'}

    CLI Example:

    salt '*' pkg.list_pkgs

salt.modules.brew.list_upgrades()
    Check whether or not an upgrade is available for all packages

    CLI Example:

    salt '*' pkg.list_upgrades

salt.modules.brew.remove(pkgs)
    Removes packages with brew uninstall

    Return a list containing the removed packages:

    CLI Example:

    salt '*' pkg.remove <package,package,package>

salt.modules.brew.upgrade_available(pkg)
    Check whether or not an upgrade is available for a given package

    CLI Example:

    salt '*' pkg.upgrade_available <package name>

salt.modules.brew.version(name)
    Returns a version if the package is installed, else returns an empty string

    CLI Example:

    salt '*' pkg.version <package name>

  salt.modules.butterkvm

Specialized routines used by the butter cloud component

salt.modules.butterkvm.create(instance, vda, image, pin)
    Create a virtual machine, this is part of the butter vm system and assumes that the files prepared by butter are available via shared storage. AKA - don't call this from the command line!

instance
    string The path to the instance directory for the given vm on shared storage

vda The location where the virtual machine image needs to be placed

image
    The image to move into place

pin A "pin" data structure defining the myriad of possible vdb-vbz disk images to generate

    CLI Example:

    salt '*' butterkvm.create <instance dir> <root image location>\
        <Destination> <pin data>

salt.modules.butterkvm.full_butter_data(local_path)
    Return the full virt info, but add butter data!

    CLI Example:

    salt '*' buttervm.full_butter_data <image_path>

salt.modules.butterkvm.libvirt_creds()
    Returns the user and group that the disk images should be owned by

    CLI Example:

    salt '*' butterkvm.libvirt_creds

salt.modules.butterkvm.local_images(local_path)
    return the virtual machine names for all of the images located in the butter cloud's local_path in a list:

    ['vm1.boo.com', 'vm2.foo.com']

    CLI Example:

    salt '*' buttervm.local_images <image_path>

  salt.modules.cluster

The cluster module is used to distribute and activate salt HA cluster components

salt.modules.cluster.distrib(minions, master_conf, master_pem, conf_file)
    Set up this minion as a failover master - only intended for use by the cluster interface

  salt.modules.cmd

A module for shelling out

Keep in mind that this module is insecure, in that it can give whomever has access to the master root execution access to all salt minions

salt.modules.cmdmod.exec_code(lang, code, cwd=None)
    Pass in two strings, the first naming the executable language, aka - python2, python3, ruby, perl, lua, etc. the second string containing the code you wish to execute. The stdout and stderr will be returned

    CLI Example:

    salt '*' cmd.exec_code ruby 'puts "cheese"'

salt.modules.cmdmod.has_exec(cmd)
    Returns true if the executable is available on the minion, false otherwise

    CLI Example:

    salt '*' cmd.has_exec cat

salt.modules.cmdmod.retcode(cmd, cwd=None, runas=None, shell='/bin/bash', env=())
    Execute a shell command and return the command's return code.

    CLI Example:

    salt '*' cmd.retcode "file /bin/bash"

salt.modules.cmdmod.run(cmd, cwd=None, runas=None, shell='/bin/bash', env=())
    Execute the passed command and return the output as a string

    CLI Example:

    salt '*' cmd.run "ls -l | awk '/foo/{print $2}'"

salt.modules.cmdmod.run_all(cmd, cwd=None, runas=None, shell='/bin/bash', env=())
    Execute the passed command and return a dict of return data

    CLI Example:

    salt '*' cmd.run_all "ls -l | awk '/foo/{print $2}'"

salt.modules.cmdmod.run_stderr(cmd, cwd=None, runas=None, shell='/bin/bash', env=())
    Execute a command and only return the standard error

    CLI Example:

    salt '*' cmd.run_stderr "ls -l | awk '/foo/{print $2}'"

salt.modules.cmdmod.run_stdout(cmd, cwd=None, runas=None, shell='/bin/bash', env=())
    Execute a command, and only return the standard out

    CLI Example:

    salt '*' cmd.run_stdout "ls -l | awk '/foo/{print $2}'"

salt.modules.cmdmod.which(cmd)
    Returns the path of an executable available on the minion, None otherwise

    CLI Example:

    salt '*' cmd.which cat

salt.modules.cmdmod.which_bin(cmds)
    Returns the first command found in a list of commands

    CLI Example:

    salt '*' cmd.which_bin '[pip2, pip, pip-python]'

  salt.modules.cp

Minion side functions for salt-cp

salt.modules.cp.cache_dir(path, env='base', include_empty=False)
    Download and cache everything under a directory from the master

    CLI Example:

    salt '*' cp.cache_dir salt://path/to/dir

salt.modules.cp.cache_file(path, env='base')
    Used to cache a single file in the local salt-master file cache.

    CLI Example:

    salt '*' cp.cache_file salt://path/to/file

salt.modules.cp.cache_files(paths, env='base')
    Used to gather many files from the master, the gathered files will be saved in the minion cachedir reflective to the paths retrieved from the master.

    CLI Example:

    salt '*' cp.cache_files salt://pathto/file1,salt://pathto/file1

salt.modules.cp.cache_local_file(path)
    Cache a local file on the minion in the localfiles cache

    CLI Example:

    salt '*' cp.cache_local_file /etc/hosts

salt.modules.cp.cache_master(env='base')
    Retrieve all of the files on the master and cache them locally

    CLI Example:

    salt '*' cp.cache_master

salt.modules.cp.get_dir(path, dest, env='base')
    Used to recursively copy a directory from the salt master

    CLI Example:

    salt '*' cp.get_dir salt://path/to/dir/ /minion/dest

salt.modules.cp.get_file(path, dest, env='base')
    Used to get a single file from the salt master

    CLI Example:

    salt '*' cp.get_file salt://path/to/file /minion/dest

salt.modules.cp.get_template(path, dest, template='jinja', env='base', **kwargs)
    Render a file as a template before settign it down

    CLI Example:

    salt '*' cp.get_template salt://path/to/template /minion/dest

salt.modules.cp.get_url(path, dest, env='base')
    Used to get a single file from a URL.

    CLI Example:

    salt '*' cp.get_url salt://my/file /tmp/mine
    salt '*' cp.get_url http://www.slashdot.org /tmp/index.html

salt.modules.cp.hash_file(path, env='base')
    Return the hash of a file, to get the hash of a file on the salt master file server prepend the path with salt://<file on server> otherwise, prepend the file with / for a local file.

    CLI Example:

    salt '*' cp.hash_file salt://path/to/file

salt.modules.cp.is_cached(path, env='base')
    Return a boolean if the given path on the master has been cached on the minion

    CLI Example:

    salt '*' cp.is_cached salt://path/to/file

salt.modules.cp.list_master(env='base')
    List all of the files stored on the master

    CLI Example:

    salt '*' cp.list_master

salt.modules.cp.list_minion(env='base')
    List all of the files cached on the minion

    CLI Example:

    salt '*' cp.list_minion

salt.modules.cp.list_states(env='base')
    List all of the available state modules in an environment

    CLI Example:

    salt '*' cp.list_states

salt.modules.cp.recv(files, dest)
    Used with salt-cp, pass the files dict, and the destination.

    This function receives small fast copy files from the master via salt-cp

  salt.modules.cron

Work with cron

salt.modules.cron.list_tab(user)
    Return the contents of the specified user's crontab

    CLI Example:

    salt '*' cron.list_tab root

salt.modules.cron.ls(user)
    Return the contents of the specified user's crontab

    CLI Example:

    salt '*' cron.list_tab root

salt.modules.cron.raw_cron(user)
    Return the contents of the user's crontab

    CLI Example:

    salt '*' cron.raw_cron root

salt.modules.cron.rm(user, minute, hour, dom, month, dow, cmd)
    Remove a cron job for a specified user.

    CLI Example:

    salt '*' cron.rm_job root \* \* \* \* 1 /usr/local/weekly

salt.modules.cron.rm_env(user, name)
    Remove cron environment variable for a specified user.

    CLI Example:

    salt '*' cron.rm_env root MAILTO

salt.modules.cron.rm_job(user, minute, hour, dom, month, dow, cmd)
    Remove a cron job for a specified user.

    CLI Example:

    salt '*' cron.rm_job root \* \* \* \* 1 /usr/local/weekly

salt.modules.cron.set_env(user, name, value=None)
    Set up an environment variable in the crontab.

    CLI Example:

    salt '*' cron.set_env root MAILTO user@example.com

salt.modules.cron.set_job(user, minute, hour, dom, month, dow, cmd)
    Sets a cron job up for a specified user.

    CLI Example:

    salt '*' cron.set_job root \* \* \* \* 1 /usr/local/weekly

salt.modules.cron.set_special(user, special, cmd)
    Set up a special command in the crontab.

    CLI Example:

    salt '*' cron.set_special @hourly 'echo foobar'

  salt.modules.data

Manage a local persistent data structure that can hold any arbitrary data specific to the minion

salt.modules.data.clear()
    Clear out all of the data in the minion datastore, this function is destructive!

    CLI Example:

    salt '*' data.clear

salt.modules.data.dump(new_data)
    Replace the entire datastore with a passed data structure

    CLI Example:

    salt '*' data.dump '{'eggs': 'spam'}'

salt.modules.data.getval(key)
    Get a value from the minion datastore

    CLI Example:

    salt '*' data.getval <key>

salt.modules.data.getvals(keys)
    Get values from the minion datastore

    CLI Example:

    salt '*' data.getvals <key>

salt.modules.data.load()
    Return all of the data in the minion datastore

    CLI Example:

    salt '*' data.load

salt.modules.data.update(key, value)
    Update a key with a value in the minion datastore

    CLI Example:

    salt '*' data.update <key> <value>

  salt.modules.debconfmod

Support for Debconf

salt.modules.debconfmod.get_selections(fetchempty=True)
    Answers to debconf questions for all packages in the following format:

    {'package': [['question', 'type', 'value'], ...]}

    CLI Example:

    salt '*' debconf.get_selections

salt.modules.debconfmod.set(package, question, type, value, *extra)
    Set answers to debconf questions for a package.

    CLI Example:

    salt '*' debconf.set <package> <question> <type> <value> [<value> ...]

salt.modules.debconfmod.set_file(path)
    Set answers to debconf questions from a file.

    CLI Example:

    salt '*' debconf.set_file salt://pathto/pkg.selections

salt.modules.debconfmod.show(name)
    Answers to debconf questions for a package in the following format:

    [['question', 'type', 'value'], ...]

    If debconf doesn't know about a package, we return None.

    CLI Example:

    salt '*' debconf.show <package name>

  salt.modules.disk

Module for gathering disk information

salt.modules.disk.inodeusage()
    Return inode usage information for volumes mounted on this minion

    CLI Example:

    salt '*' disk.inodeusage

salt.modules.disk.usage()
    Return usage information for volumes mounted on this minion

    CLI Example:

    salt '*' disk.usage

  salt.modules.django

Manage Django sites

salt.modules.django.collectstatic(settings_module, bin_env=None, no_post_process=False, ignore=None, dry_run=False, clear=False, link=False, no_default_ignore=False, pythonpath=None)
    Collect static files from each of your applications into a single location that can easily be served in production.

    CLI Example:

    salt '*' django.collectstatic settings.py

salt.modules.django.command(settings_module, command, bin_env=None, pythonpath=None, *args, **kwargs)
    Run arbitrary django management command

salt.modules.django.createsuperuser(settings_module, username, email, bin_env=None, database=None, pythonpath=None)
    Create a super user for the database. This function defaults to use the --noinput flag which prevents the creation of a password for the superuser.

    CLI Example:

    salt '*' django.createsuperuser settings.py user user@example.com

salt.modules.django.loaddata(settings_module, fixtures, bin_env=None, database=None, pythonpath=None)
    Load fixture data

Fixtures:
    comma separated list of fixtures to load

    CLI Example:

    salt '*' django.loaddata settings.py <comma delimited list of fixtures>

salt.modules.django.syncdb(settings_module, bin_env=None, migrate=False, database=None, pythonpath=None, noinput=True)
    Run syncdb

    Execute the Django-Admin syncdb command, if South is available on the minion the migrate option can be passed as True calling the migrations to run after the syncdb completes

    CLI Example:

    salt '*' django.syncdb settings.py

  salt.modules.ebuild

Support for Portage

salt.modules.ebuild.available_version(name)
    The available version of the package in the repository

    CLI Example:

    salt '*' pkg.available_version <package name>

salt.modules.ebuild.install(pkg, refresh=False, **kwargs)
    Install the passed package

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
            'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.install <package name>

salt.modules.ebuild.list_pkgs()
    List the packages currently installed in a dict:

    {'<package_name>': '<version>'}

    CLI Example:

    salt '*' pkg.list_pkgs

salt.modules.ebuild.purge(pkg)
    Portage does not have a purge, this function calls remove

    Return a list containing the removed packages:

    CLI Example:

    salt '*' pkg.purge <package name>

salt.modules.ebuild.refresh_db()
    Updates the portage tree (emerge --sync)

    CLI Example:

    salt '*' pkg.refresh_db

salt.modules.ebuild.remove(pkg)
    Remove a single package via emerge --unmerge

    Return a list containing the names of the removed packages:

    CLI Example:

    salt '*' pkg.remove <package name>

salt.modules.ebuild.update(pkg, refresh=False)
    Updates the passed package (emerge --update package)

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
            'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.update <package name>

salt.modules.ebuild.upgrade(refresh=False)
    Run a full system upgrade (emerge --update world)

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
            'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.upgrade

salt.modules.ebuild.version(name)
    Returns a version if the package is installed, else returns an empty string

    CLI Example:

    salt '*' pkg.version <package name>

  salt.modules.file

Manage information about files on the minion, set/read user, group, and mode data

salt.modules.file.append(path, *args)
    Append text to the end of a file

    CLI Example:

    salt '*' file.append /etc/motd \
            "With all thine offerings thou shalt offer salt."\
            "Salt is what makes things taste bad when it isn't in them."

    New in version 0.9.5.

salt.modules.file.chgrp(path, group)
    Change the group of a file

    CLI Example:

    salt '*' file.chgrp /etc/passwd root

salt.modules.file.chown(path, user, group)
    Chown a file, pass the file the desired user and group

    CLI Example:

    salt '*' file.chown /etc/passwd root root

salt.modules.file.comment(path, regex, char='#', backup='.bak')
    Comment out specified lines in a file

path
    The full path to the file to be edited

regex
    A regular expression used to find the lines that are to be commented; this pattern will be wrapped in parenthesis and will move any preceding/trailing ^ or $ characters outside the parenthesis (e.g., the pattern ^foo$ will be rewritten as ^(foo)$)

char
    # The character to be inserted at the beginning of a line in order to comment it out

backup
    .bak The file will be backed up before edit with this file extension

Warning
    This backup will be overwritten each time sed / comment / uncomment is called. Meaning the backup will only be useful after the first invocation.

CLI Example:

salt '*' file.comment /etc/modules pcspkr

New in version 0.9.5.

salt.modules.file.contains(path, text)
    Return True if the file at path contains text

    CLI Example:

    salt '*' file.contains /etc/crontab 'mymaintenance.sh'

    New in version 0.9.5.

salt.modules.file.contains_glob(path, glob)
    Return True if the given glob matches a string in the named file

    CLI Example:

    salt '*' /etc/foobar '*cheese*'

salt.modules.file.contains_regex(path, regex, lchar='')
    Return True if the given regular expression matches anything in the text of a given file

    CLI Example:

    salt '*' /etc/crontab '^maint'

salt.modules.file.find(path, **kwargs)
    Approximate the Unix find(1) command and return a list of paths that meet the specified critera.

    The options include match criteria:

    name    = path-glob                 # case sensitive
    iname   = path-glob                 # case insensitive
    regex   = path-regex                # case sensitive
    iregex  = path-regex                # case insensitive
    type    = file-types                # match any listed type
    user    = users                     # match any listed user
    group   = groups                    # match any listed group
    size    = [+-]number[size-unit]     # default unit = byte
    mtime   = interval                  # modified since date
    grep    = regex                     # search file contents

    and/or actions:

    delete [= file-types]               # default type = 'f'
    exec    = command [arg ...]         # where {} is replaced by pathname
    print  [= print-opts]

    The default action is 'print=path'.

    file-glob:

    *                = match zero or more chars
    ?                = match any char
    [abc]            = match a, b, or c
    [!abc] or [^abc] = match anything except a, b, and c
    [x-y]            = match chars x through y
    [!x-y] or [^x-y] = match anything except chars x through y
    {a,b,c}          = match a or b or c

    path-regex: a Python re (regular expression) pattern to match pathnames

    file-types: a string of one or more of the following:

    a: all file types
    b: block device
    c: character device
    d: directory
    p: FIFO (named pipe)
    f: plain file
    l: symlink
    s: socket

    users: a space and/or comma separated list of user names and/or uids

    groups: a space and/or comma separated list of group names and/or gids

    size-unit:

    b: bytes
    k: kilobytes
    m: megabytes
    g: gigabytes
    t: terabytes

    interval:

    [<num>w] [<num>[d]] [<num>h] [<num>m] [<num>s]
    where:
        w: week
        d: day
        h: hour
        m: minute
        s: second

    print-opts: a comma and/or space separated list of one or more of the following:

    group: group name
    md5:   MD5 digest of file contents
    mode:  file permissions (as integer)
    mtime: last modification time (as time_t)
    name:  file basename
    path:  file absolute path
    size:  file size in bytes
    type:  file type
    user:  user name

    CLI Examples:

    salt '*' file.find / type=f name=\*.bak size=+10m
    salt '*' file.find /var mtime=+30d size=+10m print=path,size,mtime
    salt '*' file.find /var/log name=\*.[0-9] mtime=+30d size=+10m delete

salt.modules.file.get_gid(path)
    Return the id of the group that owns a given file

    CLI Example:

    salt '*' file.get_gid /etc/passwd

salt.modules.file.get_group(path)
    Return the group that owns a given file

    CLI Example:

    salt '*' file.get_group /etc/passwd

salt.modules.file.get_mode(path)
    Return the mode of a file

    CLI Example:

    salt '*' file.get_mode /etc/passwd

salt.modules.file.get_sum(path, form='md5')
    Return the sum for the given file, default is md5, sha1, sha224, sha256, sha384, sha512 are supported

    CLI Example:

    salt '*' file.get_sum /etc/passwd sha512

salt.modules.file.get_uid(path)
    Return the id of the user that owns a given file

    CLI Example:

    salt '*' file.get_uid /etc/passwd

salt.modules.file.get_user(path)
    Return the user that owns a given file

    CLI Example:

    salt '*' file.get_user /etc/passwd

salt.modules.file.gid_to_group(gid)
    Convert the group id to the group name on this system

    CLI Example:

    salt '*' file.gid_to_group 0

salt.modules.file.group_to_gid(group)
    Convert the group to the gid on this system

    CLI Example:

    salt '*' file.group_to_gid root

salt.modules.file.sed(path, before, after, limit='', backup='.bak', options='-r -e', flags='g', escape_all=False)
    Make a simple edit to a file

    Equivalent to:

    sed <backup> <options> "/<limit>/ s/<before>/<after>/<flags> <file>"

path
    The full path to the file to be edited

before
    A pattern to find in order to replace with after

after
    Text that will replace before

limit
    '' An initial pattern to search for before searching for before

backup
    .bak The file will be backed up before edit with this file extension; WARNING: each time sed/comment/uncomment is called will overwrite this backup

options
    -r -e Options to pass to sed

flags
    g Flags to modify the sed search; e.g., i for case-insensitve pattern matching

    Forward slashes and single quotes will be escaped automatically in the before and after patterns.

    CLI Example:

    salt '*' file.sed /etc/httpd/httpd.conf 'LogLevel warn' 'LogLevel info'

    New in version 0.9.5.

salt.modules.file.set_mode(path, mode)
    Set the mode of a file

    CLI Example:

    salt '*' file.set_mode /etc/passwd 0644

salt.modules.file.stats(path, hash_type='md5', follow_symlink=False)
    Return a dict containing the stats for a given file

    CLI Example:

    salt '*' file.stats /etc/passwd

salt.modules.file.touch(name, atime=None, mtime=None)
    Just like 'nix's "touch" command, create a file if it doesn't exist or simply update the atime and mtime if it already does.

atime:
    Access time in Unix epoch time

mtime:
    Last modification in Unix epoch time

    CLI Example:

    salt '*' file.touch /var/log/emptyfile

    New in version 0.9.5.

salt.modules.file.uid_to_user(uid)
    Convert a uid to a user name

    CLI Example:

    salt '*' file.uid_to_user 0

salt.modules.file.uncomment(path, regex, char='#', backup='.bak')
    Uncomment specified commented lines in a file

path
    The full path to the file to be edited

regex
    A regular expression used to find the lines that are to be uncommented. This regex should not include the comment character. A leading ^ character will be stripped for convenience (for easily switching between comment() and uncomment()).

char
    # The character to remove in order to uncomment a line; if a single whitespace character follows the comment it will also be removed

backup
    .bak The file will be backed up before edit with this file extension; WARNING: each time sed/comment/uncomment is called will overwrite this backup

    CLI Example:

    salt '*' file.uncomment /etc/hosts.deny 'ALL: PARANOID'

    New in version 0.9.5.

salt.modules.file.user_to_uid(user)
    Convert user name to a uid

    CLI Example:

    salt '*' file.user_to_uid root

  salt.modules.freebsdjail

The jail module for FreeBSD

salt.modules.freebsdjail.fstab(jail)
    Display contents of a fstab(5) file defined in specified jail's configuration. If no file defined return False.

    CLI Example:

    salt '*' jail.fstab <jail name>

salt.modules.freebsdjail.get_enabled()
    Return which jails are set to be run

salt.modules.freebsdjail.is_enabled()
    See if jail service is actually enabled on boot

salt.modules.freebsdjail.restart(jail='')
    Restart the specified jail or all, if none specified

    CLI Example:

    salt '*' jail.restart [<jail name>]

salt.modules.freebsdjail.show_config(jail)
    Display specified jail's configuration

    CLI Example:

    salt '*' jail.show_config <jail name>

salt.modules.freebsdjail.start(jail='')
    Start the specified jail or all, if none specified

    CLI Example:

    salt '*' jail.start [<jail name>]

salt.modules.freebsdjail.status(jail)
    See if specified jail is currently running

    CLI Example:

    salt '*' jail.status <jail name>

salt.modules.freebsdjail.stop(jail='')
    Stop the specified jail or all, if none specified

    CLI Example:

    salt '*' jail.stop [<jail name>]

salt.modules.freebsdjail.sysctl()
    Dump all jail related kernel states (sysctl)

  salt.modules.freebsdkmod

Module to manage FreeBSD kernel modules

salt.modules.freebsdkmod.available()
    Return a list of all available kernel modules

    CLI Example:

    salt '*' kmod.available

salt.modules.freebsdkmod.check_available(mod)
    Check to see if the specified kernel module is available

    CLI Example:

    salt '*' kmod.check_available kvm

salt.modules.freebsdkmod.load(mod)
    Load the specified kernel module

    CLI Example:

    salt '*' kmod.load kvm

salt.modules.freebsdkmod.lsmod()
    Return a dict containing information about currently loaded modules

    CLI Example:

    salt '*' kmod.lsmod

salt.modules.freebsdkmod.remove(mod)
    Remove the specified kernel module

    CLI Example:

    salt '*' kmod.remove kvm

  salt.modules.freebsdpkg

Package support for FreeBSD

salt.modules.freebsdpkg.available_version(name)
    The available version of the package in the repository

    CLI Example:

    salt '*' pkg.available_version <package name>

salt.modules.freebsdpkg.install(name, *args, **kwargs)
    Install the passed package

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.install <package name>

salt.modules.freebsdpkg.list_pkgs()
    List the packages currently installed as a dict:

    {'<package_name>': '<version>'}

    CLI Example:

    salt '*' pkg.list_pkgs

salt.modules.freebsdpkg.purge(name)
    Remove a single package with pkg_delete

    Returns a list containing the removed packages.

    CLI Example:

    salt '*' pkg.purge <package name>

salt.modules.freebsdpkg.refresh_db()
    Update the ports tree with portsnap. If the ports tree does not exist it will be downloaded and set up.

    CLI Example:

    salt '*' pkg.refresh_db

salt.modules.freebsdpkg.rehash()
    Recomputes internal hash table for the PATH variable. Use whenever a new command is created during the current session.

    CLI Example:

    salt '*' pkg.rehash

salt.modules.freebsdpkg.remove(name)
    Remove a single package with pkg_delete

    Returns a list containing the removed packages.

    CLI Example:

    salt '*' pkg.remove <package name>

salt.modules.freebsdpkg.search(pkg_name)
    Use pkg search if pkg is being used.

    CLI Example:

    salt '*' pkg.pkgng_search 'mysql-server'

salt.modules.freebsdpkg.upgrade()
    Run a full system upgrade, a freebsd-update fetch install

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.upgrade

salt.modules.freebsdpkg.version(name)
    Returns a version if the package is installed, else returns an empty string

    CLI Example:

    salt '*' pkg.version <package name>

  salt.modules.freebsdservice

The service module for FreeBSD

salt.modules.freebsdservice.get_all()
    Return a list of all available services

    CLI Example:

    salt '*' service.get_all

salt.modules.freebsdservice.get_disabled()
    Return what services are available but not enabled to start at boot

    CLI Example:

    salt '*' service.get_disabled

salt.modules.freebsdservice.get_enabled()
    Return what services are set to run on boot

    CLI Example:

    salt '*' service.get_enabled

salt.modules.freebsdservice.restart(name)
    Restart the named service

    CLI Example:

    salt '*' service.restart <service name>

salt.modules.freebsdservice.start(name)
    Start the specified service

    CLI Example:

    salt '*' service.start <service name>

salt.modules.freebsdservice.status(name, sig=None)
    Return the status for a service, returns the PID or an empty string if the service is running or not, pass a signature to use to find the service via ps

    CLI Example:

    salt '*' service.status <service name> [service signature]

salt.modules.freebsdservice.stop(name)
    Stop the specified service

    CLI Example:

    salt '*' service.stop <service name>

  salt.modules.gem

Manage ruby gems.

salt.modules.gem.install(gems, ruby=None, runas=None)
    Installs one or several gems.

gems
    The gems to install.

ruby
    None If RVM is installed, the ruby version and gemset to use.

runas
    None The user to run gem as.

salt.modules.gem.list(prefix='', ruby=None, runas=None)
    List locally installed gems.

prefix :
    Only list gems when the name matches this prefix.

ruby
    None If RVM is installed, the ruby version and gemset to use.

runas
    None The user to run gem as.

salt.modules.gem.sources_add(source_uri, ruby=None, runas=None)
    Add a gem source.

source_uri
    The source URI to add.

ruby
    None If RVM is installed, the ruby version and gemset to use.

runas
    None The user to run gem as.

salt.modules.gem.sources_list(ruby=None, runas=None)
    List the configured gem sources.

ruby
    None If RVM is installed, the ruby version and gemset to use.

runas
    None The user to run gem as.

salt.modules.gem.sources_remove(source_uri, ruby=None, runas=None)
    Remove a gem source.

source_uri
    The source URI to remove.

ruby
    None If RVM is installed, the ruby version and gemset to use.

runas
    None The user to run gem as.

salt.modules.gem.uninstall(gems, ruby=None, runas=None)
    Uninstall one or several gems.

gems
    The gems to uninstall.

ruby
    None If RVM is installed, the ruby version and gemset to use.

runas
    None The user to run gem as.

salt.modules.gem.update(gems, ruby=None, runas=None)
    Update one or several gems.

gems
    The gems to update.

ruby
    None If RVM is installed, the ruby version and gemset to use.

runas
    None The user to run gem as.

salt.modules.gem.update_system(version='', ruby=None, runas=None)
    Update rubygems.

version
    (newest) The version of rubygems to install.

ruby
    None If RVM is installed, the ruby version and gemset to use.

runas
    None The user to run gem as.

  salt.modules.gentoo_service

Top level package command wrapper, used to translate the os detected by the grains to the correct service manager

salt.modules.gentoo_service.disable(name)
    Disable the named service to start at boot

    CLI Example:

    salt '*' service.disable <service name>

salt.modules.gentoo_service.disabled(name)
    Return True if the named servioce is enabled, false otherwise

    CLI Example:

    salt '*' service.disabled <service name>

salt.modules.gentoo_service.enable(name)
    Enable the named service to start at boot

    CLI Example:

    salt '*' service.enable <service name>

salt.modules.gentoo_service.enabled(name)
    Return True if the named servioce is enabled, false otherwise

    CLI Example:

    salt '*' service.enabled <service name>

salt.modules.gentoo_service.get_all()
    Return all available boot services

    CLI Example:

    salt '*' service.get_all

salt.modules.gentoo_service.get_disabled()
    Return a set of services that are installed but disabled

    CLI Example:

    salt '*' service.get_disabled

salt.modules.gentoo_service.get_enabled()
    Return a list of service that are enabled on boot

    CLI Example:

    salt '*' service.get_enabled

salt.modules.gentoo_service.restart(name)
    Restart the named service

    CLI Example:

    salt '*' service.restart <service name>

salt.modules.gentoo_service.start(name)
    Start the specified service

    CLI Example:

    salt '*' service.start <service name>

salt.modules.gentoo_service.status(name, sig=None)
    Return the status for a service, returns the PID or an empty string if the service is running or not, pass a signature to use to find the service via ps

    CLI Example:

    salt '*' service.status <service name> [service signature]

salt.modules.gentoo_service.stop(name)
    Stop the specified service

    CLI Example:

    salt '*' service.stop <service name>

  salt.modules.git

Support for the Git SCM

salt.modules.git.archive(cwd, output, rev='HEAD', fmt=None, prefix=None, user=None)
    Export a tarball from the repository

cwd The path to the Git repository

output
    The path to the archive tarball

rev: HEAD
    The revision to create an archive from

fmt: None
    Format of the resulting archive, zip and tar are commonly used

prefix
    None Prepend <prefix>/ to every filename in the archive

user
    None Run git as a user other than what the minion runs as

    If prefix is not specified it defaults to the basename of the repo directory.

    CLI Example:

    salt '*' git.archive /path/to/repo /path/to/archive.tar.gz

salt.modules.git.checkout(cwd, rev, force=False, opts=None, user=None)
    Checkout a given revision

cwd The path to the Git repository

rev The remote branch or revision to checkout

force
    False Force a checkout even if there might be overwritten changes

opts
    None Any additional options to add to the command line

user
    None Run git as a user other than what the minion runs as

    CLI Examples:

    salt '*' git.checkout /path/to/repo somebranch user=jeff
    salt '*' git.checkout /path/to/repo opts='testbranch -- conf/file1 file2'
    salt '*' git.checkout /path/to/repo rev=origin/mybranch opts=--track

salt.modules.git.clone(cwd, repository, opts=None, user=None)
    Clone a new repository

cwd The path to the Git repository

repository
    The git uri of the repository

opts
    None Any additional options to add to the command line

user
    None Run git as a user other than what the minion runs as

    CLI Example:

    salt '*' git.clone /path/to/repo git://github.com/saltstack/salt.git
    salt '*' git.clone /path/to/repo.git\
            git://github.com/saltstack/salt.git '--bare --origin github'

salt.modules.git.describe(cwd, rev='HEAD', user=None)
    Returns the git describe string (or the SHA hash if there are no tags) for the given revision

cwd The path to the Git repository

rev: HEAD
    The revision to describe

user
    None Run git as a user other than what the minion runs as

    CLI Examples:

    salt '*' git.describe /path/to/repo
    salt '*' git.describe /path/to/repo develop

salt.modules.git.fetch(cwd, opts=None, user=None)
    Perform a fetch on the given repository

cwd The path to the Git repository

opts
    None Any additional options to add to the command line

user
    None Run git as a user other than what the minion runs as

    CLI Example:

    salt '*' git.fetch /path/to/repo '--all'
    salt '*' git.fetch cwd=/path/to/repo opts='--all' user=johnny

salt.modules.git.init(cwd, opts=None, user=None)
    Initialize a new git repository

cwd The path to the Git repository

opts
    None Any additional options to add to the command line

user
    None Run git as a user other than what the minion runs as

    CLI Example:

    salt '*' git.init /path/to/repo.git opts='--bare'

salt.modules.git.merge(cwd, branch='@{upstream}', opts=None, user=None)
    Merge a given branch

cwd The path to the Git repository

branch
    @{upstream} The remote branch or revision to merge into the current branch

opts
    None Any additional options to add to the command line

user
    None Run git as a user other than what the minion runs as

    CLI Example:

    salt '*' git.fetch /path/to/repo
    salt '*' git.merge /path/to/repo @{upstream}

salt.modules.git.pull(cwd, opts=None, user=None)
    Perform a pull on the given repository

cwd The path to the Git repository

opts
    None Any additional options to add to the command line

user
    None Run git as a user other than what the minion runs as

    CLI Example:

    salt '*' git.pull /path/to/repo opts='--rebase origin master'

salt.modules.git.rebase(cwd, rev='master', opts=None, user=None)
    Rebase the current branch

cwd The path to the Git repository

rev master The revision to rebase onto the current branch

opts
    None Any additional options to add to the command line

user
    None Run git as a user other than what the minion runs as

    CLI Example:

    salt '*' git.rebase /path/to/repo master

    That is the same as: git rebase master

salt.modules.git.revision(cwd, rev='HEAD', short=False, user=None)
    Returns the long hash of a given identifier (hash, branch, tag, HEAD, etc)

cwd The path to the Git repository

rev: HEAD
    The revision

short: False
    Return an abbreviated SHA1 git hash

user
    None Run git as a user other than what the minion runs as

    CLI Example:

    salt '*' git.revision /path/to/repo mybranch

  salt.modules.grains

Control aspects of the grains data

salt.modules.grains.item(key=None)
    Return a singe component of the grains data

    CLI Example:

    salt '*' grains.item os

salt.modules.grains.items()
    Return the grains data

    CLI Example:

    salt '*' grains.items

salt.modules.grains.ls()
    Return a list of all available grains

    CLI Example:

    salt '*' grains.ls

  salt.modules.groupadd

Manage groups on Linux

salt.modules.groupadd.add(name, gid=None, system=False)
    Add the specified group

    CLI Example:

    salt '*' group.add foo 3456

salt.modules.groupadd.chgid(name, gid)
    Change the gid for a named group

    CLI Example:

    salt '*' group.chgid foo 4376

salt.modules.groupadd.delete(name)
    Remove the named group

    CLI Example:

    salt '*' group.delete foo

salt.modules.groupadd.getent()
    Return info on all groups

    CLI Example:

    salt '*' group.getent

salt.modules.groupadd.info(name)
    Return information about a group

    CLI Example:

    salt '*' group.info foo

  salt.modules.grub

Support for GRUB

salt.modules.grub.conf()
    Parse GRUB conf file

    CLI Example:

    salt '*' grub.conf

salt.modules.grub.version()
    Return server version from grub --version

    CLI Example:

    salt '*' grub.version

  salt.modules.hg

Support for the Mercurial SCM

salt.modules.hg.archive(cwd, output, rev='tip', fmt=None, prefix=None, user=None)
    Export a tarball from the repository

cwd The path to the Mercurial repository

output
    The path to the archive tarball

rev: tip
    The revision to create an archive from

fmt: None
    Format of the resulting archive. Mercurial supports: tar, tbz2, tgz, zip, uzip, and files formats.

prefix
    None Prepend <prefix>/ to every filename in the archive

user
    None Run hg as a user other than what the minion runs as

    If prefix is not specified it defaults to the basename of the repo directory.

    CLI Example:

    salt '*' hg.archive /path/to/repo output=/tmp/archive.tgz fmt=tgz

salt.modules.hg.clone(cwd, repository, opts=None, user=None)
    Clone a new repository

cwd The path to the Mercurial repository

repository
    The hg uri of the repository

opts
    None Any additional options to add to the command line

user
    None Run hg as a user other than what the minion runs as

    CLI Example:

    salt '*' hg.clone /path/to/repo https://bitbucket.org/birkenfeld/sphinx

salt.modules.hg.describe(cwd, rev='tip', user=None)
    Mimick git describe and return an identifier for the given revision

cwd The path to the Mercurial repository

rev: tip
    The path to the archive tarball

user
    None Run hg as a user other than what the minion runs as

    CLI Example:

    salt '*' hg.describe /path/to/repo

salt.modules.hg.pull(cwd, opts=None, user=None)
    Perform a pull on the given repository

cwd The path to the Mercurial repository

opts
    None Any additional options to add to the command line

user
    None Run hg as a user other than what the minion runs as

    CLI Example:

    salt '*' hg.pull /path/to/repo '-u'

salt.modules.hg.revision(cwd, rev='tip', short=False, user=None)
    Returns the long hash of a given identifier (hash, branch, tag, HEAD, etc)

cwd The path to the Mercurial repository

rev: tip
    The revision

short: False
    Return an abbreviated commit hash

user
    None Run hg as a user other than what the minion runs as

    CLI Example:

    salt '*' hg.revision /path/to/repo mybranch

salt.modules.hg.update(cwd, rev, force=False, user=None)
    Update to a given revision

cwd The path to the Mercurial repository

rev The revision to update to

force
    False Force an update

user
    None Run hg as a user other than what the minion runs as

    CLI Example:

    salt devserver1 hg.update /path/to/repo somebranch

  salt.modules.hosts

Manage the information in the hosts file

salt.modules.hosts.add_host(ip, alias)
    Add a host to an existing entry, if the entry is not in place then create it with the given host

    CLI Example:

    salt '*' hosts.add_host <ip> <alias>

salt.modules.hosts.get_alias(ip)
    Return the list of aliases associated with an ip

    CLI Example:

    salt '*' hosts.get_alias <ip addr>

salt.modules.hosts.get_ip(host)
    Return the ip associated with the named host

    CLI Example:

    salt '*' hosts.get_ip <hostname>

salt.modules.hosts.has_pair(ip, alias)
    Return true if the alias is set

    CLI Example:

    salt '*' hosts.has_pair <ip> <alias>

salt.modules.hosts.list_hosts()
    Return the hosts found in the hosts file in this format:

    {'<ip addr>': ['alias1', 'alias2', ...]}

    CLI Example:

    salt '*' hosts.list_hosts

salt.modules.hosts.rm_host(ip, alias)
    Remove a host entry from the hosts file

    CLI Example:

    salt '*' hosts.rm_host <ip> <alias>

salt.modules.hosts.set_host(ip, alias)
    Set the host entry in the hosts file for the given ip, this will overwrite any previous entry for the given ip

    CLI Example:

    salt '*' hosts.set_host <ip> <alias>

  salt.modules.kmod

Module to manage Linux kernel modules

salt.modules.kmod.available()
    Return a list of all available kernel modules

    CLI Example:

    salt '*' kmod.available

salt.modules.kmod.check_available(mod)
    Check to see if the specified kernel module is available

    CLI Example:

    salt '*' kmod.check_available kvm

salt.modules.kmod.load(mod)
    Load the specified kernel module

    CLI Example:

    salt '*' kmod.load kvm

salt.modules.kmod.lsmod()
    Return a dict containing information about currently loaded modules

    CLI Example:

    salt '*' kmod.lsmod

salt.modules.kmod.remove(mod)
    Remove the specified kernel module

    CLI Example:

    salt '*' kmod.remove kvm

  salt.modules.kvm_hyper

Provide the hyper module for kvm hypervisors. This is the interface used to interact with kvm on behalf of the salt-virt interface

Required python modules: libvirt

salt.modules.kvm_hyper.freecpu()
    Return an int representing the number of unallocated cpus on this hypervisor

    CLI Example:

    salt '*' hyper.freecpu

salt.modules.kvm_hyper.freemem()
    Return an int representing the amount of memory that has not been given to virtual machines on this node

    CLI Example:

    salt '*' hyper.freemem

salt.modules.kvm_hyper.get_conf(name)
    Returns the xml for a given vm

    CLI Example:

    salt '*' hyper.get_conf <vm name>

salt.modules.kvm_hyper.get_disks(name)
    Return the disks of a named virt

    CLI Example:

    salt '*' hyper.get_disks <vm name>

salt.modules.kvm_hyper.halt(name)
    Hard power down a virtual machine

    CLI Example:

    salt '*' hyper.halt webserver

salt.modules.kvm_hyper.hyper_info()
    Return a dict with information about this hypervisor

    CLI Example:

    salt '*' hyper.hyper_info

salt.modules.kvm_hyper.hyper_type()
    Return that type of hypervisor this is

    CLI Example:

    salt '*' hyper.hyper_type

salt.modules.kvm_hyper.init(name, cpus, mem, image, storage_dir, network={'eth0': {'bridge': 'br0', 'mac': ''}}, desc='', opts={})
    Create a KVM virtual machine based on these passed options, the virtual machine will be started upon creation

    CLI Example: salt '*' hyper.init webserver 2 2048 salt://fedora/f16.img:virt /srv/vm/images

salt.modules.kvm_hyper.list_virts()
    Return a list of virtual machine names on the minion

    CLI Example:

    salt '*' hyper.list_virts

salt.modules.kvm_hyper.pause(name)
    Pause the named virtual machine

    CLI Example:

    salt '*' hyper.pause webserver

salt.modules.kvm_hyper.purge(name)
    Hard power down and purge a virtual machine, this will destroy a vm and all associated vm data

    CLI Example:

    salt '*' hyper.purge webserver

salt.modules.kvm_hyper.resume(name)
    Resume the named virtual machine

    CLI Example:

    salt '*' hyper.resume webserver

salt.modules.kvm_hyper.set_autostart(name)
    Set the named virtual machine to autostart when the hypervisor boots

    CLI Example:

    salt '*' hyper.set_autostart webserver

salt.modules.kvm_hyper.start(config)
    Start an already defined virtual machine that has been shut down

    CLI Example:

    salt '*' hyper.start webserver

salt.modules.kvm_hyper.virt_info()
    Return detailed information about the vms on this hyper in a dict:

    {'cpu': <int>,
    'maxMem': <int>,
    'mem': <int>,
    'state': '<state>',
    'cputime' <int>}

    CLI Example:

    salt '*' hyper.virt_info

  salt.modules.launchctl

Module for the management of MacOS systems that use launchd/launchctl

salt.modules.launchctl.get_all()
    Return all installed services

    CLI Example:

    salt '*' service.get_all

salt.modules.launchctl.get_launchctl_data(job_label, runas=None)

salt.modules.launchctl.restart(job_label, runas=None)
    Restart the named service

    CLI Example:

    salt '*' service.restart <service name>

salt.modules.launchctl.start(job_label, runas=None)
    Start the specified service

    CLI Example:

    salt '*' service.start <service name>

salt.modules.launchctl.status(job_label, runas=None)
    Return the status for a service, returns a bool whether the service is running.

    CLI Example:

    salt '*' service.status <service name>

salt.modules.launchctl.stop(job_label, runas=None)
    Stop the specified service

    CLI Example:

    salt '*' service.stop <service name>

  salt.modules.linux_sysctl

Module for viewing and modifying sysctl parameters

salt.modules.linux_sysctl.assign(name, value)
    Assign a single sysctl parameter for this minion

    CLI Example:

    salt '*' sysctl.assign net.ipv4.ip_forward 1

salt.modules.linux_sysctl.get(name)
    Return a single sysctl parameter for this minion

    CLI Example:

    salt '*' sysctl.get net.ipv4.ip_forward

salt.modules.linux_sysctl.persist(name, value, config='/etc/sysctl.conf')
    Assign and persist a simple sysctl parameter for this minion

    CLI Example:

    salt '*' sysctl.persist net.ipv4.ip_forward 1

salt.modules.linux_sysctl.show()
    Return a list of sysctl parameters for this minion

    CLI Example:

    salt '*' sysctl.show

  salt.modules.mdadm

Salt module to manage RAID arrays with mdadm

salt.modules.mdadm.detail(device='/dev/md0')
    Show detail for a specified RAID device

    CLI Example:

    salt '*' raid.detail '/dev/md0'

salt.modules.mdadm.list()
    List the RAID devices.

    CLI Example:

    salt '*' raid.list

  salt.modules.moosefs

Module for gathering and managing information about MooseFS

salt.modules.moosefs.dirinfo(path, opts=None)
    Return information on a directory located on the Moose

    CLI Example:

    salt '*' moosefs.dirinfo /path/to/dir/ [-[n][h|H]]

salt.modules.moosefs.fileinfo(path)
    Return information on a file located on the Moose

    CLI Example:

    salt '*' moosefs.fileinfo /path/to/dir/

salt.modules.moosefs.getgoal(path, opts=None)
    Return goal(s) for a file or directory

    CLI Example:

    salt '*' moosefs.getgoal /path/to/file [-[n][h|H]]
    salt '*' moosefs.getgoal /path/to/dir/ [-[n][h|H][r]]

salt.modules.moosefs.mounts()
    Return a list of current MooseFS mounts

    CLI Example:

    salt '*' moosefs.mounts

  salt.modules.mount

Salt module to manage unix mounts and the fstab file

salt.modules.mount.active()
    List the active mounts.

    CLI Example:

    salt '*' mount.active

salt.modules.mount.fstab(config='/etc/fstab')
    List the contents of the fstab

    CLI Example:

    salt '*' mount.fstab

salt.modules.mount.is_fuse_exec(cmd)
    Returns true if the command passed is a fuse mountable application.

    CLI Example:

    salt '*' mount.is_fuse_exec sshfs

salt.modules.mount.mount(name, device, mkmnt=False, fstype='', opts='defaults')
    Mount a device

    CLI Example:

    salt '*' mount.mount /mnt/foo /dev/sdz1 True

salt.modules.mount.remount(name, device, mkmnt=False, fstype='', opts='defaults')
    Attempt to remount a device, if the device is not already mounted, mount is called

    CLI Example:

    salt '*' mount.remount /mnt/foo /dev/sdz1 True

salt.modules.mount.rm_fstab(name, config='/etc/fstab')
    Remove the mount point from the fstab

    CLI Example:

    salt '*' mount.rm_fstab /mnt/foo

salt.modules.mount.set_fstab(name, device, fstype, opts='defaults', dump=0, pass_num=0, config='/etc/fstab')
    Verify that this mount is represented in the fstab, chage the mount point to match the data passed, or add the mount if it is not present.

    CLI Example:

    salt '*' mount.set_fstab /mnt/foo /dev/sdz1 ext4

  salt.modules.mysql

Module to provide MySQL compatibility to salt.

In order to connect to MySQL, certain configuration is required in /etc/salt/minion on the relevant minions. Some sample configs might look like:

mysql.host: 'localhost'
mysql.port: 3306
mysql.user: 'root'
mysql.pass: ''
mysql.db: 'mysql'

You can also use a defaults file:

mysql.default_file: '/etc/mysql/debian.cnf'

Required python modules: MySQLdb

salt.modules.mysql.connect(**kwargs)
    wrap authentication credentials here

salt.modules.mysql.db_check(name, table=None)
    Repairs the full database or just a given table

    CLI Example:

    salt '*' mysql.db_check dbname

salt.modules.mysql.db_create(name)
    Adds a databases to the MySQL server.

    CLI Example:

    salt '*' mysql.db_create 'dbname'

salt.modules.mysql.db_exists(name)
    Checks if a database exists on the MySQL server.

    CLI Example:

    salt '*' mysql.db_exists 'dbname'

salt.modules.mysql.db_list()
    Return a list of databases of a MySQL server using the output from the SHOW DATABASES query.

    CLI Example:

    salt '*' mysql.db_list

salt.modules.mysql.db_optimize(name, table=None)
    Optimizes the full database or just a given table

    CLI Example:

    salt '*' mysql.db_optimize dbname

salt.modules.mysql.db_remove(name)
    Removes a databases from the MySQL server.

    CLI Example:

    salt '*' mysql.db_remove 'dbname'

salt.modules.mysql.db_repair(name, table=None)
    Repairs the full database or just a given table

    CLI Example:

    salt '*' mysql.db_repair dbname

salt.modules.mysql.db_tables(name)
    Shows the tables in the given MySQL database (if exists)

    CLI Example:

    salt '*' mysql.db_tables 'database'

salt.modules.mysql.free_slave()
    Frees a slave from its master. This is a WIP, do not use.

salt.modules.mysql.grant_add(grant, database, user, host='localhost', grant_option=False, escape=True)
    Adds a grant to the MySQL server.

    CLI Example:

    salt '*' mysql.grant_add 'SELECT|INSERT|UPDATE|...' 'database.*' 'frank' 'localhost'

salt.modules.mysql.grant_exists(grant, database, user, host='localhost', grant_option=False, escape=True)

salt.modules.mysql.grant_revoke(grant, database, user, host='localhost', grant_option=False)
    Removes a grant from the MySQL server.

    CLI Example:

    salt '*' mysql.grant_revoke 'SELECT,INSERT,UPDATE' 'database.*' 'frank' 'localhost'

salt.modules.mysql.slave_lag()
    Return the number of seconds that a slave SQL server is lagging behind the master, if the host is not a slave it will return -1. If the server is configured to be a slave for replication but slave IO is not running then -2 will be returned.

    CLI Example:

    salt '*' mysql.slave_lag

salt.modules.mysql.status()
    Return the status of a MySQL server using the output from the SHOW STATUS query.

    CLI Example:

    salt '*' mysql.status

salt.modules.mysql.user_chpass(user, host='localhost', password=None, password_hash=None)
    Change password for MySQL user

    CLI Examples:

    salt '*' mysql.user_chpass frank localhost newpassword
    salt '*' mysql.user_chpass frank localhost password_hash='hash'

salt.modules.mysql.user_create(user, host='localhost', password=None, password_hash=None)
    Creates a MySQL user.

    CLI Examples:

    salt '*' mysql.user_create 'username' 'hostname' 'password
    salt '*' mysql.user_create 'username' 'hostname' password_hash='hash'

salt.modules.mysql.user_exists(user, host='localhost')
    Checks if a user exists on the MySQL server.

    CLI Example:

    salt '*' mysql.user_exists 'username' 'hostname'

salt.modules.mysql.user_grants(user, host='localhost')
    Shows the grants for the given MySQL user (if it exists)

    CLI Example:

    salt '*' mysql.user_grants 'frank' 'localhost'

salt.modules.mysql.user_info(user, host='localhost')
    Get full info on a MySQL user

    CLI Example:

    salt '*' mysql.user_info root localhost

salt.modules.mysql.user_list()
    Return a list of users on a MySQL server

    CLI Example:

    salt '*' mysql.user_list

salt.modules.mysql.user_remove(user, host='localhost')
    Delete MySQL user

    CLI Example:

    salt '*' mysql.user_remove frank localhost

salt.modules.mysql.version()
    Return the version of a MySQL server using the output from the SELECT VERSION() query.

    CLI Example:

    salt '*' mysql.version

  salt.modules.network

Module for gathering and managing network information

salt.modules.network.dig(host)
    Performs a DNS lookup with dig

    CLI Example:

    salt '*' network.dig archlinux.org

salt.modules.network.host_to_ip(host)
    Returns the IP address of a given hostname

    CLI Example:

    salt '*' network.host_to_ip example.com

salt.modules.network.hwaddr(interface)
    Returns the hwaddr for a given interface

    CLI Example:

    salt '*' network.hwaddr eth0

salt.modules.network.interfaces()
    Returns a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr)

    CLI Example:

    salt '*' network.interfaces

salt.modules.network.ip_to_host(ip)
    Returns the hostname of a given IP

    CLI Example:

    salt '*' network.ip_to_host 8.8.8.8

salt.modules.network.ipaddr(interface=None)
    Returns the IP address for a given interface

    CLI Example:

    salt '*' network.ipaddr eth0

salt.modules.network.isportopen(host, port)
    Return status of a port

    CLI Example:

    salt '*' network.isportopen 127.0.0.1 22

salt.modules.network.netmask(interface)
    Returns the netmask for a given interface

    CLI Example:

    salt '*' network.netmask eth0

salt.modules.network.netstat()
    Return information on open ports and states

    CLI Example:

    salt '*' network.netstat

salt.modules.network.ping(host)
    Performs a ping to a host

    CLI Example:

    salt '*' network.ping archlinux.org

salt.modules.network.traceroute(host)
    Performs a traceroute to a 3rd party host

    CLI Example:

    salt '*' network.traceroute archlinux.org

salt.modules.network.up(interface)
    Returns True if interface is up, otherwise returns False

    CLI Example:

    salt '*' network.up eth0

  salt.modules.nginx

Support for nginx

salt.modules.nginx.signal(signal=None)
    Signals httpd to start, restart, or stop.

    CLI Example:

    salt '*' nginx.signal reload

salt.modules.nginx.version()
    Return server version from nginx -v

    CLI Example:

    salt '*' nginx.version

  salt.modules.osxdesktop

Mac OS X implementations of various commands in the "desktop" interface

salt.modules.osxdesktop.get_output_volume()
    Get the output volume (range 0 to 100)

    CLI Example:

    salt '*' desktop.get_output_volume

salt.modules.osxdesktop.lock()
    Lock the desktop session

    CLI Example:

    salt '*' desktop.lock

salt.modules.osxdesktop.screensaver()
    Launch the screensaver

    CLI Example:

    salt '*' desktop.screensaver

salt.modules.osxdesktop.set_output_volume(volume)
    Set the volume of sound (range 0 to 100)

    CLI Example:

    salt '*' desktop.set_output_volume <volume>

  salt.modules.pacman

A module to wrap pacman calls, since Arch is the best (https://wiki.archlinux.org/index.php/Arch_is_the_best)

salt.modules.pacman.available_version(name)
    The available version of the package in the repository

    CLI Example:

    salt '*' pkg.available_version <package name>

salt.modules.pacman.install(name, refresh=False, **kwargs)
    Install the passed package, add refresh=True to install with an -Sy

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.install <package name>

salt.modules.pacman.list_pkgs()
    List the packages currently installed as a dict:

    {'<package_name>': '<version>'}

    CLI Example:

    salt '*' pkg.list_pkgs

salt.modules.pacman.list_upgrades()
    List all available package upgrades on this system

    CLI Example:

    salt '*' pkg.list_upgrades

salt.modules.pacman.purge(name)
    Recursively remove a package and all dependencies which were installed with it, this will call a pacman -Rsc

    Return a list containing the removed packages.

    CLI Example:

    salt '*' pkg.purge <package name>

salt.modules.pacman.refresh_db()
    Just run a pacman -Sy, return a dict:

    {'<database name>': Bool}

    CLI Example:

    salt '*' pkg.refresh_db

salt.modules.pacman.remove(name)
    Remove a single package with pacman -R

    Return a list containing the removed packages.

    CLI Example:

    salt '*' pkg.remove <package name>

salt.modules.pacman.upgrade()
    Run a full system upgrade, a pacman -Syu

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.upgrade

salt.modules.pacman.upgrade_available(name)
    Check whether or not an upgrade is available for a given package

    CLI Example:

    salt '*' pkg.upgrade_available <package name>

salt.modules.pacman.version(name)
    Returns a version if the package is installed, else returns an empty string

    CLI Example:

    salt '*' pkg.version <package name>

  salt.modules.pillar

Extract the pillar data for this minion

salt.modules.pillar.data()
    Returns the pillar derived from the configured pillar source. The pillar source is derived from the file_client option in the minion config

    CLI Example:

    salt '*' pillar.data

  salt.modules.pip

Install Python packages with pip to either the system or a virtualenv

salt.modules.pip.freeze(bin_env=None, runas=None, cwd=None)
    Return a list of installed packages either globally or in the specified virtualenv

bin_env
    path to pip bin or path to virtualenv. If doing an uninstall from the system python and want to use a specific pip bin (pip-2.7, pip-2.6, etc..) just specify the pip bin you want. If uninstalling from a virtualenv, just use the path to the virtualenv (/home/code/path/to/virtualenv/)

runas
    User to run pip as

cwd Current working directory to run pip from

    CLI Example:

    salt '*' pip.freeze /home/code/path/to/virtualenv/

salt.modules.pip.install(pkgs=None, requirements=None, env=None, bin_env=None, log=None, proxy=None, timeout=None, editable=None, find_links=None, index_url=None, extra_index_url=None, no_index=False, mirrors=None, build=None, target=None, download=None, download_cache=None, source=None, upgrade=False, force_reinstall=False, ignore_installed=False, no_deps=False, no_install=False, no_download=False, install_options=None, runas=None, cwd=None)
    Install packages with pip

    Install packages individually or from a pip requirements file. Install packages globally or to a virtualenv.

pkgs
    comma separated list of packages to install

requirements
    path to requirements

bin_env
    path to pip bin or path to virtualenv. If doing a system install, and want to use a specific pip bin (pip-2.7, pip-2.6, etc..) just specify the pip bin you want. If installing into a virtualenv, just use the path to the virtualenv (/home/code/path/to/virtualenv/)

env depreicated, use bin_env now

log Log file where a complete (maximum verbosity) record will be kept

proxy
    Specify a proxy in the form user:passwd@proxy.server:port. Note that the user:password@ is optional and required only if you are behind an authenticated proxy. If you provide user@proxy.server:port then you will be prompted for a password.

timeout
    Set the socket timeout (default 15 seconds)

editable
    install something editable(ie git+https://github.com/worldcompany/djangoembed.git#egg=djangoembed)

find_links
    URL to look for packages at

index_url
    Base URL of Python Package Index

extra_index_url
    Extra URLs of package indexes to use in addition to index_url

no_index
    Ignore package index

mirrors
    Specific mirror URLs to query (automatically adds --use-mirrors)

build
    Unpack packages into build dir

target
    Install packages into target dir

download
    Download packages into download instead of installing them

download_cache
    Cache downloaded packages in download_cache dir

source
    Check out editable packages into source dir

upgrade
    Upgrade all packages to the newest available version

force_reinstall
    When upgrading, reinstall all packages even if they are already up-to-date.

ignore_installed
    Ignore the installed packages (reinstalling instead)

no_deps
    Ignore package dependencies

no_install
    Download and unpack all packages, but don't actually install them

no_download
    Don't download any packages, just install the ones already downloaded (completes an install run with --no-install)

install_options
    Extra arguments to be supplied to the setup.py install command (use like --install-option="--install- scripts=/usr/local/bin"). Use multiple --install- option options to pass multiple options to setup.py install. If you are using an option with a directory path, be sure to use absolute path.

runas
    User to run pip as

cwd Current working directory to run pip from

    CLI Example:

    salt '*' pip.install <package name>,<package2 name>
    salt '*' pip.install requirements=/path/to/requirements.txt
    salt '*' pip.install <package name> bin_env=/path/to/virtualenv
    salt '*' pip.install <package name> bin_env=/path/to/pip_bin

    Comlicated CLI example:

    salt '*' pip.install markdown,django editable=git+https://github.com/worldcompany/djangoembed.git#egg=djangoembed upgrade=True no_deps=True

salt.modules.pip.list(prefix='', bin_env=None, runas=None, cwd=None)
    Filter list of instaslled apps from freeze and check to see if prefix exists in the list of packages installed.

    CLI Example:

    salt '*' pip.list salt

salt.modules.pip.uninstall(pkgs=None, requirements=None, bin_env=None, log=None, proxy=None, timeout=None, runas=None, cwd=None)
    Uninstall packages with pip

    Uninstall packages individually or from a pip requirements file. Uninstall packages globally or from a virtualenv.

pkgs
    comma separated list of packages to install

requirements
    path to requirements

bin_env
    path to pip bin or path to virtualenv. If doing an uninstall from the system python and want to use a specific pip bin (pip-2.7, pip-2.6, etc..) just specify the pip bin you want. If uninstalling from a virtualenv, just use the path to the virtualenv (/home/code/path/to/virtualenv/)

log Log file where a complete (maximum verbosity) record will be kept

proxy
    Specify a proxy in the form user:passwd@proxy.server:port. Note that the user:password@ is optional and required only if you are behind an authenticated proxy. If you provide user@proxy.server:port then you will be prompted for a password.

timeout
    Set the socket timeout (default 15 seconds)

runas
    User to run pip as

cwd Current working directory to run pip from

    CLI Example:

    salt '*' pip.uninstall <package name>,<package2 name>
    salt '*' pip.uninstall requirements=/path/to/requirements.txt
    salt '*' pip.uninstall <package name> bin_env=/path/to/virtualenv
    salt '*' pip.uninstall <package name> bin_env=/path/to/pip_bin

  salt.modules.postgres

Module to provide Postgres compatibility to salt.

In order to connect to Postgres, certain configuration is required in /etc/salt/minion on the relevant minions. Some sample configs might look like:

postgres.host: 'localhost'
postgres.port: '5432'
postgres.user: 'postgres'
postgres.pass: ''
postgres.db: 'postgres'

salt.modules.postgres.db_create(name, user=None, host=None, port=None, tablespace=None, encoding=None, local=None, lc_collate=None, lc_ctype=None, owner=None, template=None)
    Adds a databases to the Postgres server.

    CLI Example:

    salt '*' postgres.db_create 'dbname'
    salt '*' postgres.db_create 'dbname' template=template_postgis

salt.modules.postgres.db_exists(name, user=None, host=None, port=None)
    Checks if a database exists on the Postgres server.

    CLI Example:

    salt '*' postgres.db_exists 'dbname'

salt.modules.postgres.db_list(user=None, host=None, port=None)
    Return a list of databases of a Postgres server using the output from the psql -l query.

    CLI Example:

    salt '*' postgres.db_list

salt.modules.postgres.db_remove(name, user=None, host=None, port=None)
    Removes a databases from the Postgres server.

    CLI Example:

    salt '*' postgres.db_remove 'dbname'

salt.modules.postgres.user_create(username, user=None, host=None, port=None, createdb=False, createuser=False, encrypted=False, password=None)
    Creates a Postgres user.

    CLI Examples:

    salt '*' postgres.user_create 'username' user='user' host='hostname' port='port' password='password'

salt.modules.postgres.version()
    Return the version of a Postgres server using the output from the psql --version cmd.

    CLI Example:

    salt '*' postgres.version

  salt.modules.ps

A salt interface to psutil, a system and process library. See http://code.google.com/p/psutil.

Required python modules: psutil

salt.modules.ps.boot_time()
    Return the boot time in number of seconds since the epoch began.

    CLI Example:

    salt '*' ps.boot_time

salt.modules.ps.cached_physical_memory()
    Return the amount cached memory.

    CLI Example:

    salt '*' ps.cached_physical_memory

salt.modules.ps.cpu_percent(interval=0.1, per_cpu=False)
    Return the percent of time the CPU is busy.

interval
    the number of seconds to sample CPU usage over

per_cpu
    if True return an array of CPU percent busy for each CPU, otherwise aggregate all percents into one number

    CLI Example:

    salt '*' ps.cpu_percent

salt.modules.ps.cpu_times(per_cpu=False)
    Return the percent of time the CPU spends in each state, e.g. user, system, idle, nice, iowait, irq, softirq.

per_cpu
    if True return an array of percents for each CPU, otherwise aggregate all percents into one number

    CLI Example:

    salt '*' ps.cpu_times

salt.modules.ps.disk_io_counters()
    Return disk I/O statisitics.

    CLI Example:

    salt '*' ps.disk_io_counters

salt.modules.ps.disk_partition_usage(all=False)
    Return a list of disk partitions plus the mount point, filesystem and usage statistics.

    CLI Example:

    salt '*' ps.disk_partition_usage

salt.modules.ps.disk_partitions(all=False)
    Return a list of disk partitions and their device, mount point, and filesystem type.

all if set to False, only return local, physical partitions (hard disk, USB, CD/DVD partitions). If True, return all filesystems.

    CLI Example:

    salt '*' ps.disk_partitions

salt.modules.ps.disk_usage(path)
    Given a path, return a dict listing the total available space as well as the free space, and used space.

    CLI Example:

    salt '*' ps.disk_usage /home

salt.modules.ps.get_pid_list()
    Return a list of process ids (PIDs) for all running processes.

    CLI Example:

    salt '*' ps.get_pid_list

salt.modules.ps.network_io_counters()
    Return network I/O statisitics.

    CLI Example:

    salt '*' ps.network_io_counters

salt.modules.ps.num_cpus()
    Return the number of CPUs.

    CLI Example:

    salt '*' ps.num_cpus

salt.modules.ps.physical_memory_buffers()
    Return the amount of physical memory buffers.

    CLI Example:

    salt '*' ps.physical_memory_buffers

salt.modules.ps.physical_memory_usage()
    Return a dict that describes free and available physical memory.

    CLI Examples:

    salt '*' ps.physical_memory_usage

salt.modules.ps.top(num_processes=5, interval=3)
    Return a list of top CPU consuming processes during the interval. num_processes = return the top N CPU consuming processes interval = the number of seconds to sample CPU usage over

    CLI Examples:

    salt '*' ps.top
    salt '*' ps.top 5 10

salt.modules.ps.total_physical_memory()
    Return the total number of bytes of physical memory.

    CLI Example:

    salt '*' ps.total_physical_memory

salt.modules.ps.virtual_memory_usage()
    Return a dict that describes free and available memory, both physical and virtual.

    CLI Example:

    salt '*' ps.virtual_memory_usage

  salt.modules.publish

Publish a command from a minion to a target

salt.modules.publish.full_data(tgt, fun, arg=None, expr_form='glob', returner='', timeout=5)
    Return the full data about the publication, this is invoked in the same way as the publish function

    CLI Example:

    salt system.example.com publish.full_data '*' cmd.run 'ls -la /tmp'

salt.modules.publish.publish(tgt, fun, arg=None, expr_form='glob', returner='', timeout=5)
    Publish a command from the minion out to other minions, publications need to be enabled on the Salt master and the minion needs to have permission to publish the command. The Salt master will also prevent a recursive publication loop, this means that a minion cannot command another minion to command another minion as that would create an infinite command loop.

    The arguments sent to the minion publish function are separated with commas. This means that for a minion executing a command with multiple args it will look like this:

    salt system.example.com publish.publish '*' user.add 'foo,1020,1020'

    CLI Example:

    salt system.example.com publish.publish '*' cmd.run 'ls -la /tmp'

salt.modules.publish.runner(fun, arg=None)
    Execute a runner on the master and return the data from the runner function

    CLI Example:

    salt publish.runner manage.down

  salt.modules.puppet

Execute puppet routines

salt.modules.puppet.fact(name)
    Run facter for a specific fact

    CLI Example:

    salt '*' puppet.fact kernel

salt.modules.puppet.facts()
    Run facter and return the results

    CLI Example:

    salt '*' puppet.facts

salt.modules.puppet.noop(tags=None)
    Execute a puppet noop run and return a dict with the stderr, stdout, return code, etc. If an argument is specified, it is treated as a comma separated list of tags passed to puppetd --test --noop --tags

    CLI Example:

    salt '*' puppet.noop
    salt '*' puppet.noop web::server,django::base

salt.modules.puppet.run(tags=None)
    Execute a puppet run and return a dict with the stderr, stdout, return code, etc. If an argument is specified, it is treated as a comma separated list of tags passed to puppetd --test --tags: http://projects.puppetlabs.com/projects/1/wiki/Using_Tags

    CLI Examples:

    salt '*' puppet.run
    salt '*' puppet.run basefiles::edit,apache::server

  salt.modules.pw_group

Manage groups on FreeBSD

salt.modules.pw_group.add(name, gid=None, system=False)
    Add the specified group

    CLI Example:

    salt '*' group.add foo 3456

salt.modules.pw_group.chgid(name, gid)
    Change the gid for a named group

    CLI Example:

    salt '*' group.chgid foo 4376

salt.modules.pw_group.delete(name)
    Remove the named group

    CLI Example:

    salt '*' group.delete foo

salt.modules.pw_group.getent()
    Return info on all groups

    CLI Example:

    salt '*' group.getent

salt.modules.pw_group.info(name)
    Return information about a group

    CLI Example:

    salt '*' group.info foo

  salt.modules.pw_user

Manage users with the useradd command

salt.modules.pw_user.add(name, uid=None, gid=None, groups=None, home=True, shell=None, system=False, **kwargs)
    Add a user to the minion

    CLI Example:

    salt '*' user.add name <uid> <gid> <groups> <home> <shell>

salt.modules.pw_user.chgid(name, gid)
    Change the default group of the user

    CLI Example:

    salt '*' user.chgid foo 4376

salt.modules.pw_user.chgroups(name, groups, append=False)
    Change the groups this user belongs to, add append to append the specified groups

    CLI Example:

    salt '*' user.chgroups foo wheel,root True

salt.modules.pw_user.chhome(name, home, persist=False)
    Change the home directory of the user, pass true for persist to copy files to the new home dir

    CLI Example:

    salt '*' user.chhome foo /home/users/foo True

salt.modules.pw_user.chshell(name, shell)
    Change the default shell of the user

    CLI Example:

    salt '*' user.chshell foo /bin/zsh

salt.modules.pw_user.chuid(name, uid)
    Change the uid for a named user

    CLI Example:

    salt '*' user.chuid foo 4376

salt.modules.pw_user.delete(name, remove=False, force=False)
    Remove a user from the minion

    CLI Example:

    salt '*' user.delete name True True

salt.modules.pw_user.getent()
    Return the list of all info for all users

    CLI Example:

    salt '*' user.getent

salt.modules.pw_user.info(name)
    Return user information

    CLI Example:

    salt '*' user.info root

salt.modules.pw_user.list_groups(name)
    Return a list of groups the named user belongs to

    CLI Example:

    salt '*' user.list_groups foo

  salt.modules.rabbitmq_server

Module to provide rabbitMQ compatibility to salt. Todo: Alot, need to add cluster support, logging, and minion configuration data.

salt.modules.rabbitmq_server.add_user(name, password)
    Add a rabbitMQ user via rabbitmqctl user_add <user> <password>

    CLI Example:

    salt '*' rabbitmq-server.add_user 'meow' 'mix'

salt.modules.rabbitmq_server.add_vhost(vhost)
    Adds a vhost via rabbitmqctl add_vhost.

    CLI Example:

    salt '*' rabbitmq-server add_vhost '<vhost_name>'

salt.modules.rabbitmq_server.delete_user(name)
    Deletes a user via rabbitmqctl delete_user.

    CLI Example:

    salt '*' rabbitmq-server.delete_user 'meow'

salt.modules.rabbitmq_server.delete_vhost(vhost)
    Deletes a vhost rabbitmqctl delete_vhost.

    CLI Example:

    salt '*' rabbitmq-server.delete_vhost '<vhost_name>'

salt.modules.rabbitmq_server.list_user_permissions(name)
    List permissions for a user via rabbitmqctl list_user_permissions

    Example:

    salt '*' rabbitmq-server.list_user_permissions 'user'.

salt.modules.rabbitmq_server.list_users()
    Return a list of users based off of rabbitmqctl user_list.

    CLI Example:

    salt '*' rabbitmq-server.list_users

salt.modules.rabbitmq_server.list_vhosts()
    Return a list of vhost based of of rabbitmqctl list_vhosts.

    CLI Example:

    salt '*' rabbitmq-server.list_vhosts

salt.modules.rabbitmq_server.set_permissions(vhost, user, conf='.*', write='.*', read='.*')
    Sets permissions for vhost via rabbitmqctl set_permissions

    CLI Example:

    salt '*' rabbitmq-server.set_permissions 'myvhost' 'myuser'

  salt.modules.reg

Manage the registry on Windows

Required python modules: _winreg

class salt.modules.reg.Registry
    Delay '_winreg' usage until this module is used

salt.modules.reg.create_key(hkey, path, key, value=None)
    Create a registry key

    CLI Example:

    salt '*' reg.create_key HKEY_CURRENT_USER 'SOFTWARE\Salt' 'version' '0.97'

salt.modules.reg.delete_key(hkey, path, key)
    Delete a registry key

    Note: This cannot delete a key with subkeys

    CLI Example:

    salt '*' reg.delete_key HKEY_CURRENT_USER 'SOFTWARE\Salt' 'version'

salt.modules.reg.read_key(hkey, path, key)
    Read registry key value

    CLI Example:

    salt '*' reg.read_key HKEY_LOCAL_MACHINE 'SOFTWARE\Salt' 'version'

salt.modules.reg.set_key(hkey, path, key, value)
    Set a registry key

    CLI Example:

    salt '*' reg.set_key HKEY_CURRENT_USER 'SOFTWARE\Salt' 'version' '0.97'

  salt.modules.rh_ip

The networking module for RHEL/Fedora based distros

salt.modules.rh_ip.build_bond(iface, settings)
    Create a bond script in /etc/modprobe.d with the passed settings

    CLI Example:

    salt '*' ip.build_bond br0 mode=balance-alb

salt.modules.rh_ip.build_interface(iface, type, settings)
    Build an interface script for a network interface.

    CLI Example:

    salt '*' ip.build_interface eth0 eth <settings>

salt.modules.rh_ip.down(iface)
    Shutdown a network interface

    CLI Example:

    salt '*' ip.down eth0

salt.modules.rh_ip.get_bond(iface)
    Return the content of a bond script

    CLI Example:

    salt '*' ip.get_bond br0

salt.modules.rh_ip.get_interface(iface)
    Return the contents of an interface script

    CLI Example:

    salt '*' ip.get_interface eth0

salt.modules.rh_ip.up(iface)
    Start up a network interface

    CLI Example:

    salt '*' ip.up eth0

  salt.modules.rh_service

Service support for classic Red Hat type systems. This interface uses the service command (so it is compatible with upstart systems) and the chkconfig command.

salt.modules.rh_service.disable(name)
    Disable the named service to start at boot

    CLI Example:

    salt '*' service.disable <service name>

salt.modules.rh_service.disabled(name)
    Check to see if the named service is disabled to start on boot

    CLI Example:

    salt '*' service.disabled <service name>

salt.modules.rh_service.enable(name)
    Enable the named service to start at boot

    CLI Example:

    salt '*' service.enable <service name>

salt.modules.rh_service.enabled(name)
    Check to see if the named service is enabled to start on boot

    CLI Example:

    salt '*' service.enabled <service name>

salt.modules.rh_service.get_all()
    Return all installed services

    CLI Example:

    salt '*' service.get_all

salt.modules.rh_service.get_disabled()
    Return the disabled services

    CLI Example:

    salt '*' service.get_disabled

salt.modules.rh_service.get_enabled()
    Return the enabled services

    CLI Example:

    salt '*' service.get_enabled

salt.modules.rh_service.restart(name)
    Restart the named service

    CLI Example:

    salt '*' service.restart <service name>

salt.modules.rh_service.start(name)
    Start the specified service

    CLI Example:

    salt '*' service.start <service name>

salt.modules.rh_service.status(name, sig=None)
    Return the status for a service, returns a bool whether the service is running.

    CLI Example:

    salt '*' service.status <service name>

salt.modules.rh_service.stop(name)
    Stop the specified service

    CLI Example:

    salt '*' service.stop <service name>

  salt.modules.rvm

Manage ruby installations and gemsets with RVM, the Ruby Version Manager.

salt.modules.rvm.do(ruby, command, runas=None)
    Execute a command in an RVM controlled environment.

ruby:
    The ruby to use.

command:
    The command to execute.

runas
    None The user to run rvm as.

salt.modules.rvm.gemset_copy(source, destination, runas=None)
    Copy all gems from one gemset to another.

source
    The name of the gemset to copy, complete with ruby version.

destination
    The destination gemset.

runas
    None The user to run rvm as.

salt.modules.rvm.gemset_create(ruby, gemset, runas=None)
    Creates a gemset.

ruby
    The ruby version to create the gemset for.

gemset
    The name of the gemset to create.

runas
    None The user to run rvm as.

salt.modules.rvm.gemset_delete(ruby, gemset, runas=None)
    Deletes a gemset.

ruby
    The ruby version the gemset belongs to.

gemset
    The gemset to delete.

runas
    None The user to run rvm as.

salt.modules.rvm.gemset_empty(ruby, gemset, runas=None)
    Remove all gems from a gemset.

ruby
    The ruby version the gemset belongs to.

gemset
    The gemset to empty.

runas
    None The user to run rvm as.

salt.modules.rvm.gemset_list(ruby='default', runas=None)
    List all gemsets for the given ruby.

ruby
    default The ruby version to list the gemsets for

runas
    None The user to run rvm as.

salt.modules.rvm.gemset_list_all(runas=None)
    List all gemsets for all installed rubies.

    Note that you must have set a default ruby before this can work.

runas
    None The user to run rvm as.

salt.modules.rvm.get(version='stable', runas=None)
    Update RVM.

version
    stable Which version of RVM to install, e.g. stable or head.

ruby
    The version of ruby to reinstall.

salt.modules.rvm.install()
    Install RVM system wide.

salt.modules.rvm.install_ruby(ruby, runas=None)
    Install a ruby implementation.

ruby
    The version of ruby to install.

runas
    None The user to run rvm as.

salt.modules.rvm.is_installed()
    Check if RVM is installed.

salt.modules.rvm.list(runas=None)
    List all rvm installed rubies.

runas
    None The user to run rvm as.

salt.modules.rvm.reinstall_ruby(ruby, runas=None)
    Reinstall a ruby implementation.

ruby
    The version of ruby to reinstall.

runas
    None The user to run rvm as.

salt.modules.rvm.rubygems(ruby, version, runas=None)
    Installs a specific rubygems version in the given ruby.

ruby
    The ruby to install rubygems for.

version
    The version of rubygems to install or 'remove' to use the version that ships with 1.9

runas
    None The user to run rvm as.

salt.modules.rvm.set_default(ruby, runas=None)
    Set the default ruby.

ruby
    The version of ruby to make the default.

runas
    None The user to run rvm as.

salt.modules.rvm.wrapper(ruby_string, wrapper_prefix, runas=None, *binaries)
    Install RVM wrapper scripts.

ruby_string
    Ruby/gemset to install wrappers for.

wrapper_prefix
    What to prepend to the name of the generated wrapper binaries.

runas
    None The user to run rvm as.

binaries
    None The names of the binaries to create wrappers for. When nothing is given, wrappers for ruby, gem, rake, irb, rdoc, ri and testrb are generated.

  salt.modules.saltutil

The Saltutil module is used to manage the state of the salt minion itself. It is used to manage minion modules as well as automate updates to the salt minion

salt.modules.saltutil.find_job(jid)
    Return the data for a specific job id

    CLI Example:

    salt '*' saltutil.find_job <job id>

salt.modules.saltutil.kill_job(jid)
    Sends a termination signal (SIGTERM 15) to the named salt job's process

    CLI Example:

    salt '*' saltutil.kill_job <job id>

salt.modules.saltutil.refresh_pillar()
    Queue the minion to refresh the pillar data.

    CLI Example:

    salt '*' saltutil.refresh_pillar

salt.modules.saltutil.running()
    Return the data on all running processes salt on the minion

    CLI Example:

    salt '*' saltutil.running

salt.modules.saltutil.signal_job(jid, sig)
    Sends a signal to the named salt job's process

    CLI Example:

    salt '*' saltutil.signal_job <job id> 15

salt.modules.saltutil.sync_all(env='base')
    Sync down all of the dynamic modules from the file server for a specific environment

    CLI Example:

    salt '*' saltutil.sync_all

salt.modules.saltutil.sync_grains(env='base')
    Sync the grains from the _grains directory on the salt master file server. This function is environment aware, pass the desired environment to grab the contents of the _grains directory, base is the default environment.

    CLI Example:

    salt '*' saltutil.sync_grains

salt.modules.saltutil.sync_modules(env='base')
    Sync the modules from the _modules directory on the salt master file server. This function is environment aware, pass the desired environment to grab the contents of the _modules directory, base is the default environment.

    CLI Example:

    salt '*' saltutil.sync_modules

salt.modules.saltutil.sync_renderers(env='base')
    Sync the renderers from the _renderers directory on the salt master file server. This function is environment aware, pass the desired environment to grab the contents of the _renderers directory, base is the default environment.

    CLI Example:

    salt '*' saltutil.sync_renderers

salt.modules.saltutil.sync_returners(env='base')
    Sync the returners from the _returners directory on the salt master file server. This function is environment aware, pass the desired environment to grab the contents of the _returners directory, base is the default environment.

    CLI Example:

    salt '*' saltutil.sync_returners

salt.modules.saltutil.sync_states(env='base')
    Sync the states from the _states directory on the salt master file server. This function is environment aware, pass the desired environment to grab the contents of the _states directory, base is the default environment.

    CLI Example:

    salt '*' saltutil.sync_states

salt.modules.saltutil.term_job(jid)
    Sends a termination signal (SIGTERM 15) to the named salt job's process

    CLI Example:

    salt '*' saltutil.term_job <job id>

  salt.modules.selinux

Execute calls on selinux

salt.modules.selinux.getenforce()
    Return the mode selinux is running in

    CLI Example:

    salt '*' selinux.getenforce

salt.modules.selinux.getsebool(boolean)
    Return the information on a specific selinux boolean

    CLI Example:

    salt '*' selinux.getsebool virt_use_usb

salt.modules.selinux.list_sebool()
    Return a structure listing all of the selinux booleans on the system and what state they are in

    CLI Example:

    salt '*' selinux.list_sebool

salt.modules.selinux.selinux_fs_path()
    Return the location of the SELinux VFS directory

    CLI Example:

    salt '*' selinux.selinux_fs_path

salt.modules.selinux.setenforce(mode)
    Set the SELinux enforcing mode

    CLI Example:

    salt '*' selinux.setenforce enforcing

salt.modules.selinux.setsebool(boolean, value, persist=False)
    Set the value for a boolean

    CLI Example:

    salt '*' selinux.setsebool virt_use_usb off

salt.modules.selinux.setsebools(pairs, persist=False)
    Set the value of multiple booleans

    CLI Example:

    salt '*' selinux.setsebools '{virt_use_usb: on, squid_use_tproxy: off}'

  salt.modules.service

The default service module, if not otherwise specified salt will fall back to this basic module

salt.modules.service.reload(name)
    Restart the named service

    CLI Example:

    salt '*' service.reload <service name>

salt.modules.service.restart(name)
    Restart the named service

    CLI Example:

    salt '*' service.restart <service name>

salt.modules.service.start(name)
    Start the specified service

    CLI Example:

    salt '*' service.start <service name>

salt.modules.service.status(name, sig=None)
    Return the status for a service, returns the PID or an empty string if the service is running or not, pass a signature to use to find the service via ps

    CLI Example:

    salt '*' service.status <service name> [service signature]

salt.modules.service.stop(name)
    Stop the specified service

    CLI Example:

    salt '*' service.stop <service name>

  salt.modules.shadow

Manage the shadow file

salt.modules.shadow.info(name)
    Return information for the specified user

    CLI Example:

    salt '*' shadow.info root

salt.modules.shadow.set_inactdays(name, inactdays)
    Set the number of days of inactivity after a password has expired before the account is locked. See man chage.

    CLI Example:

    salt '*' shadow.set_inactdays username 7

salt.modules.shadow.set_maxdays(name, maxdays)
    Set the maximum number of days during which a password is valid. See man chage.

    CLI Example:

    salt '*' shadow.set_maxdays username 90

salt.modules.shadow.set_mindays(name, mindays)
    Set the minimum number of days between password changes. See man chage.

    CLI Example:

    salt '*' shadow.set_mindays username 7

salt.modules.shadow.set_password(name, password)
    Set the password for a named user. The password must be a properly defined hash, the password hash can be generated with this command: openssl passwd -1 <plaintext password>

    CLI Example:

    salt '*' shadow.set_password root $1$UYCIxa628.9qXjpQCjM4a..

salt.modules.shadow.set_warndays(name, warndays)
    Set the number of days of warning before a password change is required. See man chage.

    CLI Example:

    salt '*' shadow.set_warndays username 7

  salt.modules.solr

  Apache Solr Salt Module

Author: Jed Glazner Version: 0.2.1 Modified: 12/09/2011

This module uses http requests to talk to the apache solr request handlers to gather information and report errors. Because of this the minion doesn't necessarily need to reside on the actual slave. However if you want to use the signal function the minion must reside on the physical solr host.

This module supports multi-core and standard setups. Certain methods are master/slave specific. Make sure you set the solr.type. If you have questions or want a feature request please ask.

  Coming Features in 0.3

1.  Add command for checking for replication failures on slaves

2.  Improve match_index_versions since it's pointless on busy solr masters

3.  Add additional local fs checks for backups to make sure they succeeded

  Override these in the minion config

solr.cores
    A list of core names eg ['core1','core2']. An empty list indicates non-multicore setup.

solr.baseurl
    The root level url to access solr via http

solr.request_timeout
    The number of seconds before timing out an http/https/ftp request. If nothing is specified then the python global timeout setting is used.

solr.type
    Possible values are 'master' or 'slave'

solr.backup_path
    The path to store your backups. If you are using cores and you can specify to append the core name to the path in the backup method.

solr.num_backups
    For versions of solr >= 3.5. Indicates the number of backups to keep. This option is ignored if your version is less.

solr.init_script
    The full path to your init script with start/stop options

solr.dih.options
    A list of options to pass to the dih.

  Required Options for DIH

clean
    False Clear the index before importing

commit
    True Commit the documents to the index upon completion

optimize
    True Optimize the index after commit is complete

verbose
    True Get verbose output

salt.modules.solr.abort_import(handler, host=None, core_name=None, verbose=False)
    MASTER ONLY Aborts an existing import command to the specified handler. This command can only be run if the minion is is configured with solr.type=master

handler
    str The name of the data import handler.

host
    str (None) The solr host to query. __opts__['host'] is default.

core
    str (None) The core the handler belongs to.

verbose
    boolean (False) Run the command with verbose output.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.abort_import dataimport None music {'clean':True}

salt.modules.solr.backup(host=None, core_name=None, append_core_to_path=False)
    Tell solr make a backup. This method can be mis-leading since it uses the backup api. If an error happens during the backup you are not notified. The status: 'OK' in the response simply means that solr received the request successfully.

host
    str (None) The solr host to query. __opts__['host'] is default.

core_name
    str (None) The name of the solr core if using cores. Leave this blank if you are not using cores or if you want to check all cores.

append_core_to_path
    boolean (False) If True add the name of the core to the backup path. Assumes that minion backup path is not None.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.backup music

salt.modules.solr.core_status(host=None, core_name=None)
    MULTI-CORE HOSTS ONLY Get the status for a given core or all cores if no core is specified

host
    str (None) The solr host to query. __opts__['host'] is default.

core_name
    str The name of the core to reload

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.core_status None music

salt.modules.solr.delta_import(handler, host=None, core_name=None, options=None, extra=None)
    Submits an import command to the specified handler using specified options. This command can only be run if the minion is is configured with solr.type=master

handler
    str The name of the data import handler.

host
    str (None) The solr host to query. __opts__['host'] is default.

core
    str (None) The core the handler belongs to.

options
    dict (__opts__) A list of options such as clean, optimize commit, verbose, and pause_replication. leave blank to use __opts__ defaults. options will be merged with __opts__

extra
    dict ([]) Extra name value pairs to pass to the handler. eg ["name=value"]

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.delta_import dataimport None music {'clean':True}

salt.modules.solr.full_import(handler, host=None, core_name=None, options=None, extra=None)
    MASTER ONLY Submits an import command to the specified handler using specified options. This command can only be run if the minion is is configured with solr.type=master

handler
    str The name of the data import handler.

host
    str (None) The solr host to query. __opts__['host'] is default.

core
    str (None) The core the handler belongs to.

options
    dict (__opts__) A list of options such as clean, optimize commit, verbose, and pause_replication. leave blank to use __opts__ defaults. options will be merged with __opts__

extra
    dict ([]) Extra name value pairs to pass to the handler. e.g. ["name=value"]

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.full_import dataimport None music {'clean':True}

salt.modules.solr.import_status(handler, host=None, core_name=None, verbose=False)
    Submits an import command to the specified handler using specified options. This command can only be run if the minion is is configured with solr.type: 'master'

handler
    str The name of the data import handler.

host
    str (None) The solr host to query. __opts__['host'] is default.

core
    str (None) The core the handler belongs to.

verbose
    boolean (False) Specifies verbose output

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.import_status dataimport None music False

salt.modules.solr.is_replication_enabled(host=None, core_name=None)
    SLAVE CALL Check for errors, and determine if a slave is replicating or not.

host
    str (None) The solr host to query. __opts__['host'] is default.

core_name
    str (None) The name of the solr core if using cores. Leave this blank if you are not using cores or if you want to check all cores.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.is_replication_enabled music

salt.modules.solr.lucene_version(core_name=None)
    Gets the lucene version that solr is using. If you are running a multi-core setup you should specify a core name since all the cores run under the same servlet container, they will all have the same version.

core_name
    str (None) The name of the solr core if using cores. Leave this blank if you are not using cores or if you want to check all cores.

    Return: dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.lucene_version

salt.modules.solr.match_index_versions(host=None, core_name=None)
    SLAVE CALL Verifies that the master and the slave versions are in sync by comparing the index version. If you are constantly pushing updates the index the master and slave versions will seldom match. A solution to this is pause indexing every so often to allow the slave to replicate and then call this method before allowing indexing to resume.

host
    str (None) The solr host to query. __opts__['host'] is default.

core_name
    str (None) The name of the solr core if using cores. Leave this blank if you are not using cores or if you want to check all cores.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.match_index_versions music

salt.modules.solr.optimize(host=None, core_name=None)
    Search queries fast, but it is a very expensive operation. The ideal process is to run this with a master/slave configuration. Then you can optimize the master, and push the optimized index to the slaves. If you are running a single solr instance, or if you are going to run this on a slave be aware than search performance will be horrible while this command is being run. Additionally it can take a LONG time to run and your http request may timeout. If that happens adjust your timeout settings.

host
    str (None) The solr host to query. __opts__['host'] is default.

core_name
    str (None) The name of the solr core if using cores. Leave this blank if you are not using cores or if you want to check all cores.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.optimize music

salt.modules.solr.ping(host=None, core_name=None)
    Does a health check on solr, makes sure solr can talk to the indexes.

host
    str (None) The solr host to query. __opts__['host'] is default.

core_name
    str (None) The name of the solr core if using cores. Leave this blank if you are not using cores or if you want to check all cores.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.ping music

salt.modules.solr.reload_core(host=None, core_name=None)
    MULTI-CORE HOSTS ONLY Load a new core from the same configuration as an existing registered core. While the "new" core is initializing, the "old" one will continue to accept requests. Once it has finished, all new request will go to the "new" core, and the "old" core will be unloaded.

host
    str (None) The solr host to query. __opts__['host'] is default.

core_name
    str The name of the core to reload

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.reload_core None music
    {'success':bool, 'data':dict, 'errors':list, 'warnings':list}

salt.modules.solr.reload_import_config(handler, host=None, core_name=None, verbose=False)
    MASTER ONLY re-loads the handler config XML file. This command can only be run if the minion is a 'master' type

handler
    str The name of the data import handler.

host
    str (None) The solr host to query. __opts__['host'] is default.

core
    str (None) The core the handler belongs to.

verbose
    boolean (False) Run the command with verbose output.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.reload_import_config dataimport None music {'clean':True}

salt.modules.solr.replication_details(host=None, core_name=None)
    Get the full replication details.

host
    str (None) The solr host to query. __opts__['host'] is default.

core_name
    str (None) The name of the solr core if using cores. Leave this blank if you are not using cores or if you want to check all cores.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.replication_details music

salt.modules.solr.set_is_polling(polling, host=None, core_name=None)
    SLAVE CALL Prevent the slaves from polling the master for updates.

polling
    boolean True will enable polling. False will disable it.

host
    str (None) The solr host to query. __opts__['host'] is default.

core_name
    str (None) The name of the solr core if using cores. Leave this blank if you are not using cores or if you want to check all cores.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.set_is_polling False

salt.modules.solr.set_replication_enabled(status, host=None, core_name=None)
    MASTER ONLY Sets the master to ignore poll requests from the slaves. Useful when you don't want the slaves replicating during indexing or when clearing the index.

status
    boolean Sets the replication status to the specified state.

host
    str (None) The solr host to query. __opts__['host'] is default.

core_name
    str (None) The name of the solr core if using cores. Leave this blank if you are not using cores or if you want to set the status on all cores.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.set_replication_enabled false, None, music

salt.modules.solr.signal(signal=None)
    Signals Apache Solr to start, stop, or restart. Obviously this is only going to work if the minion resides on the solr host. Additionally Solr doesn't ship with an init script so one must be created.

signal
    str (None) The command to pass to the apache solr init valid values are 'start', 'stop', and 'restart'

    CLI Example:

    salt '*' solr.signal restart

salt.modules.solr.version(core_name=None)
    Gets the solr version for the core specified. You should specify a core here as all the cores will run under the same servlet container and so will all have the same version.

core_name
    str (None) The name of the solr core if using cores. Leave this blank if you are not using cores or if you want to check all cores.

    Return : dict<str,obj>:

    {'success':boolean, 'data':dict, 'errors':list, 'warnings':list}

    CLI Example:

    salt '*' solr.version

  salt.modules.sqlite3

Support for SQLite3

salt.modules.sqlite3.fetch(db=None, sql=None)
    Retrieve data from an sqlite3 db (returns all rows, be careful!)

    CLI Example:

    salt '*' sqlite3.fetch /root/test.db 'SELECT * FROM test;'

salt.modules.sqlite3.indexes(db=None)
    Show all indices in the database, for people with poor spelling skills

    CLI Example:

    salt '*' sqlite3.indexes /root/test.db

salt.modules.sqlite3.indices(db=None)
    Show all indices in the database

    CLI Example:

    salt '*' sqlite3.indices /root/test.db

salt.modules.sqlite3.modify(db=None, sql=None)
    Issue an SQL query to sqlite3 (with no return data), usually used to modify the database in some way (insert, delete, create, etc)

    CLI Example:

    salt '*' sqlite3.modify /root/test.db 'CREATE TABLE test(id INT, testdata TEXT);'

salt.modules.sqlite3.sqlite_version()
    Return version of sqlite

    CLI Example:

    salt '*' sqlite3.sqlite_version

salt.modules.sqlite3.tables(db=None)
    Show all tables in the database

    CLI Example:

    salt '*' sqlite3.tables /root/test.db

salt.modules.sqlite3.version()
    Return version of pysqlite

    CLI Example:

    salt '*' sqlite3.version

  salt.modules.ssh

Manage client ssh components

salt.modules.ssh.auth_keys(user, config='.ssh/authorized_keys')
    Return the authorized keys for the specified user

    CLI Example:

    salt '*' ssh.auth_keys root

salt.modules.ssh.check_key(user, key, enc, comment, options, config='.ssh/authorized_keys')
    Check to see if a key needs updating, returns "update", "add" or "exists"

    CLI Example:

    salt '*' ssh.check_key <user> <key>

salt.modules.ssh.check_key_file(user, keysource, config='.ssh/authorized_keys', env='base')
    Check a keyfile from a source destination against the local keys and return the keys to change

salt.modules.ssh.check_known_host(user, hostname, key=None, fingerprint=None, config='.ssh/known_hosts')
    Check the record in known_hosts file, either by its value or by fingerprint (it's enough to set up either key or fingerprint, you don't need to set up both).

    If provided key or fingerprint doesn't match with stored value, return "update", if no value is found for a given host, return "add", otherwise return "exists".

    If neither key, nor fingerprint is defined, then additional validation is not performed.

    CLI Example:

    salt '*' ssh.check_known_host <user> <hostname> key='AAAA...FAaQ=='

salt.modules.ssh.get_known_host(user, hostname, config='.ssh/known_hosts')
    Return information about known host from the configfile, if any. If there is no such key, return None.

    CLI Example:

    salt '*' ssh.get_known_host <user> <hostname>

salt.modules.ssh.host_keys(keydir=None)
    Return the minion's host keys

    CLI Example:

    salt '*' ssh.host_keys

salt.modules.ssh.recv_known_host(user, hostname, enc=None, port=None, hash_hostname=False)
    Retreive information about host public key from remote server

    CLI Example:

    salt '*' ssh.recv_known_host <user> <hostname> enc=<enc> port=<port>

salt.modules.ssh.rm_auth_key(user, key, config='.ssh/authorized_keys')
    Remove an authorized key from the specified user's authorized key file

    CLI Example:

    salt '*' ssh.rm_auth_key <user> <key>

salt.modules.ssh.rm_known_host(user, hostname, config='.ssh/known_hosts')
    Remove all keys belonging to hostname from a known_hosts file.

    CLI Example:

    salt '*' ssh.rm_known_host <user> <hostname>

salt.modules.ssh.set_auth_key(user, key, enc='ssh-rsa', comment='', options=[], config='.ssh/authorized_keys')
    Add a key to the authorized_keys file

    CLI Example:

    salt '*' ssh.set_auth_key <user> key='<key>' enc='dsa'                comment='my key' options='[]' config='.ssh/authorized_keys'

salt.modules.ssh.set_auth_key_from_file(user, source, config='.ssh/authorized_keys', env='base')
    Add a key to the authorized_keys file, using a file as the source.

    CLI Example:

    salt '*' ssh.set_auth_key_from_file <user>                salt://ssh_keys/<user>.id_rsa.pub

salt.modules.ssh.set_known_host(user, hostname, fingerprint=None, port=None, enc=None, hash_hostname=True, config='.ssh/known_hosts')
    Download SSH public key from remote host "hostname", optionally validate its fingerprint against "fingerprint" variable and save the record in the known_hosts file.

    If such a record does already exists in there, do nothing.

    CLI Example:

    salt '*' ssh.set_known_host <user> fingerprint='xx:xx:..:xx' enc='ssh-rsa'                 config='.ssh/known_hosts'

  salt.modules.state

Control the state system on the minion

salt.modules.state.high(data)
    Execute the compound calls stored in a single set of high data This function is mostly intended for testing the state system

    CLI Example:

    salt '*' state.high '{"vim": {"pkg": ["installed"]}}'

salt.modules.state.highstate(test=None, **kwargs)
    Retrive the state data from the salt master for this minion and execute it

    CLI Example:

    salt '*' state.highstate

salt.modules.state.low(data)
    Execute a single low data call This function is mostly intended for testing the state system

    CLI Example:

    salt '*' state.low '{"state": "pkg", "fun": "installed", "name": "vi"}'

salt.modules.state.show_highstate()
    Retrieve the highstate data from the salt master and display it

    CLI Example:

    salt '*' state.show_highstate

salt.modules.state.show_lowstate()
    List out the low data that will be applied to this minion

    CLI Example:

    salt '*' state.show_lowstate

salt.modules.state.show_masterstate()
    Display the data gathered from the master compiled state

    CLI Example:

    salt '*' state.show_masterstate

salt.modules.state.show_sls(mods, env='base', test=None, **kwargs)
    Display the state data from a specific sls or list of sls files on the master

    CLI Example:

    salt '*' state.sls core,edit.vim dev

salt.modules.state.single(fun=None, test=None, **kwargs)
    Execute a single state function with the named kwargs, returns False if insufficient data is sent to the command

    CLI Example:

    salt '*' state.single pkg.installed name=vim

salt.modules.state.sls(mods, env='base', test=None, **kwargs)
    Execute a set list of state modules from an environment, default environment is base

    CLI Example:

    salt '*' state.sls core,edit.vim dev

salt.modules.state.template(tem)
    Execute the information stored in a template file on the minion

    CLI Example:

    salt '*' state.template '<Path to template on the minion>'

salt.modules.state.template_str(tem)
    Execute the information stored in a template file on the minion

    CLI Example:

    salt '*' state.template_str '<Template String>'

salt.modules.state.top(topfn)
    Execute a specific top file instead of the default

    CLI Example:

    salt '*' state.top reverse_top.sls

  salt.modules.status

Module for returning various status data about a minion. These data can be useful for compiling into stats later.

salt.modules.status.all_status()
    Return a composite of all status data and info for this minion. Warning: There is a LOT here!

    CLI Example:

    salt '*' status.all_status

salt.modules.status.cpuinfo()
    Return the CPU info for this minion

    CLI Example:

    salt '*' status.cpuinfo

salt.modules.status.cpustats()
    Return the CPU stats for this minon

    CLI Example:

    salt '*' status.cpustats

salt.modules.status.custom()
    Return a custom composite of status data and info for this minon, based on the minion config file. An example config like might be:

    status.cpustats.custom: [ 'cpu', 'ctxt', 'btime', 'processes' ]

    Where status refers to status.py, cpustats is the function where we get our data, and custom is this function It is followed by a list of keys that we want returned.

    This function is meant to replace all_status(), which returns anything and everything, which we probably don't want.

    By default, nothing is returned. Warning: Depending on what you include, there can be a LOT here!

    CLI Example:

    salt '*' status.custom

salt.modules.status.diskstats()
    Return the disk stats for this minion

    CLI Example:

    salt '*' status.diskstats

salt.modules.status.diskusage(*args)
    Return the disk usage for this minion

    Usage:

    salt '*' status.diskusage [paths and/or filesystem types]

    CLI Example:

    salt '*' status.diskusage         # usage for all filesystems
    salt '*' status.diskusage / /tmp  # usage for / and /tmp
    salt '*' status.diskusage ext?    # usage for ext[234] filesystems
    salt '*' status.diskusage / ext?  # usage for / and all ext filesystems

salt.modules.status.loadavg()
    Return the load averages for this minion

    CLI Example:

    salt '*' status.loadavg

salt.modules.status.meminfo()
    Return the CPU stats for this minion

    CLI Example:

    salt '*' status.meminfo

salt.modules.status.netdev()
    Return the network device stats for this minion

    CLI Example:

    salt '*' status.netdev

salt.modules.status.netstats()
    Return the network stats for this minion

    CLI Example:

    salt '*' status.netstats

salt.modules.status.procs()
    Return the process data

    CLI Example:

    salt '*' status.procs

salt.modules.status.uptime()
    Return the uptime for this minion

    CLI Example:

    salt '*' status.uptime

salt.modules.status.vmstats()
    Return the virtual memory stats for this minion

    CLI Example:

    salt '*' status.vmstats

salt.modules.status.w()
    Return a list of logged in users for this minion, using the w command

    CLI Example:

    salt '*' status.w

  salt.modules.systemd

Provide the service module for systemd

salt.modules.systemd.disable(name)
    Disable the named service to not start when the system boots

    CLI Example:

    salt '*' service.disable <service name>

salt.modules.systemd.disabled(name)
    Return if the named service is disabled to start on boot

    CLI Example:

    salt '*' service.disabled <service name>

salt.modules.systemd.enable(name)
    Enable the named service to start when the system boots

    CLI Example:

    salt '*' service.enable <service name>

salt.modules.systemd.enabled(name)
    Return if the named service is enabled to start on boot

    CLI Example:

    salt '*' service.enabled <service name>

salt.modules.systemd.get_all()
    Return a list of all available services

    CLI Example:

    salt '*' service.get_all

salt.modules.systemd.get_disabled()
    Return a list of all disabled services

    CLI Example:

    salt '*' service.get_disabled

salt.modules.systemd.get_enabled()
    Return a list of all enabled services

    CLI Example:

    salt '*' service.get_enabled

salt.modules.systemd.reload(name)
    Reload the specified service with systemd

    CLI Example:

    salt '*' service.reload <service name>

salt.modules.systemd.restart(name)
    Restart the specified service with systemd

    CLI Example:

    salt '*' service.restart <service name>

salt.modules.systemd.start(name)
    Start the specified service with systemd

    CLI Example:

    salt '*' service.start <service name>

salt.modules.systemd.status(name, sig=None)
    Return the status for a service via systemd, returns the PID if the service is running or an empty string if the service is not running

    CLI Example:

    salt '*' service.status <service name>

salt.modules.systemd.stop(name)
    Stop the specifed service with systemd

    CLI Example:

    salt '*' service.stop <service name>

  salt.modules.test

Module for running arbitrary tests

salt.modules.test.collatz(start)
    Execute the collatz conjecture from the passed starting number, returns the sequence and the time it took to compute. Used for performance tests.

    CLI Example:

    salt '*' test.collatz 3

salt.modules.test.conf_test()
    Return the value for test.foo in the minion configuration file, or return the default value

    CLI Example:

    salt '*' test.conf_test

salt.modules.test.cross_test(func, args=None)
    Execute a minion function via the __salt__ object in the test module, used to verify that the minion functions can be called via the __salt__ module.

    CLI Example:

    salt '*' test.cross_test file.gid_to_group 0

salt.modules.test.echo(text)
    Return a string - used for testing the connection

    CLI Example:

    salt '*' test.echo 'foo bar baz quo qux'

salt.modules.test.fib(num)
    Return a Fibonacci sequence up to the passed number, and the timeit took to compute in seconds. Used for performance tests

    CLI Example:

    salt '*' test.fib 3

salt.modules.test.get_opts()
    Return the configuration options passed to this minion

    CLI Example:

    salt '*' test.get_opts

salt.modules.test.kwarg(**kwargs)
    Print out the data passed into the function **kwargs, this is used to both test the publication data and cli kwarg passing, but also to display the information available within the publication data.

    CLI Example:

    salt '*' test.kwarg

salt.modules.test.outputter(data)
    Test the outputter, pass in data to return

    CLI Example:

    salt '*' test.outputter foobar

salt.modules.test.ping()
    Just used to make sure the minion is up and responding Return True

    CLI Example:

    salt '*' test.ping

salt.modules.test.version()
    Return the version of salt on the minion

    CLI Example:

    salt '*' test.version

  salt.modules.tomcat

Support for Tomcat

salt.modules.tomcat.fullversion()
    Return all server information from catalina.sh version

    CLI Example:

    salt '*' tomcat.fullversion

salt.modules.tomcat.signal(signal=None)
    Signals catalina to start, stop, securestart, forcestop.

    CLI Example:

    salt '*' tomcat.signal start

salt.modules.tomcat.version()
    Return server version from catalina.sh version

    CLI Example:

    salt '*' tomcat.version

  salt.modules.upstart

Module for the management of upstart systems. The Upstart system only supports service starting, stopping and restarting.

Currently (as of Ubuntu 12.04) there is no tool available to disable Upstart services (like update-rc.d). This[1] is the recommended way to disable an Upstart service. So we assume that all Upstart services that have not been disabled in this manner are enabled.

But this is broken because we do not check to see that the dependent services are enabled. Otherwise we would have to do something like parse the output of "initctl show-config" to determine if all service dependencies are enabled to start on boot. For example, see the "start on" condition for the lightdm service below[2]. And this would be too hard. So we wait until the upstart developers have solved this problem. :) This is to say that an Upstart service that is enabled may not really be enabled.

Also, when an Upstart service is enabled, should the dependent services be enabled too? Probably not. But there should be a notice about this, at least.

[1] http://upstart.ubuntu.com/cookbook/#disabling-a-job-from-automatically-starting

[2] lightdm
    emits login-session-start emits desktop-session-start emits desktop-shutdown start on ((((filesystem and runlevel [!06]) and started dbus) and (drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY=1 or stopped udev-fallback-graphics)) or runlevel PREVLEVEL=S) stop on runlevel [016]

    DO NOT use this module on red hat systems, as red hat systems should use the rh_service module, since red hat systems support chkconfig

salt.modules.upstart.disable(name)
    Disable the named service from starting on boot

    CLI Example:

    salt '*' service.disable <service name>

salt.modules.upstart.disabled(name)
    Check to see if the named service is disabled to start on boot

    CLI Example:

    salt '*' service.disabled <service name>

salt.modules.upstart.enable(name)
    Enable the named service to start at boot

    CLI Example:

    salt '*' service.enable <service name>

salt.modules.upstart.enabled(name)
    Check to see if the named service is enabled to start on boot

    CLI Example:

    salt '*' service.enabled <service name>

salt.modules.upstart.get_all()
    Return all installed services

    CLI Example:

    salt '*' service.get_all

salt.modules.upstart.get_disabled()
    Return the disabled services

    CLI Example:

    salt '*' service.get_disabled

salt.modules.upstart.get_enabled()
    Return the enabled services

    CLI Example:

    salt '*' service.get_enabled

salt.modules.upstart.restart(name)
    Restart the named service

    CLI Example:

    salt '*' service.restart <service name>

salt.modules.upstart.start(name)
    Start the specified service

    CLI Example:

    salt '*' service.start <service name>

salt.modules.upstart.status(name, sig=None)
    Return the status for a service, returns a bool whether the service is running.

    CLI Example:

    salt '*' service.status <service name>

salt.modules.upstart.stop(name)
    Stop the specified service

    CLI Example:

    salt '*' service.stop <service name>

  salt.modules.useradd

Manage users with the useradd command

salt.modules.useradd.add(name, uid=None, gid=None, groups=None, home=True, shell=None, fullname=None, roomnumber=None, workphone=None, homephone=None, other=None, unique=True, system=False)
    Add a user to the minion

    CLI Example:

    salt '*' user.add name <uid> <gid> <groups> <home> <shell>

salt.modules.useradd.chfullname(name, fullname)
    Change the users Full Name

    CLI Example:

    salt '*' user.chfullname foo "Foo Bar"

salt.modules.useradd.chgid(name, gid)
    Change the default group of the user

    CLI Example:

    salt '*' user.chgid foo 4376

salt.modules.useradd.chgroups(name, groups, append=False)
    Change the groups this user belongs to, add append to append the specified groups

    CLI Example:

    salt '*' user.chgroups foo wheel,root True

salt.modules.useradd.chhome(name, home, persist=False)
    Change the home directory of the user, pass true for persist to copy files to the new home dir

    CLI Example:

    salt '*' user.chhome foo /home/users/foo True

salt.modules.useradd.chhomephone(name, homephone)
    Change the user's Home Phone

    CLI Example:

    salt '*' user.chhomephone foo "7735551234"

salt.modules.useradd.chother(name, other)
    Change the user's "Other" GECOS field

    CLI Example:

    salt '*' user.chother foo "fax=7735555678"

salt.modules.useradd.chroomnumber(name, roomnumber)
    Change the user's Room Number

    CLI Example:

    salt '*' user.chroomnumber foo 123

salt.modules.useradd.chshell(name, shell)
    Change the default shell of the user

    CLI Example:

    salt '*' user.chshell foo /bin/zsh

salt.modules.useradd.chuid(name, uid)
    Change the uid for a named user

    CLI Example:

    salt '*' user.chuid foo 4376

salt.modules.useradd.chworkphone(name, workphone)
    Change the user's Work Phone

    CLI Example:

    salt '*' user.chworkphone foo "7735550123"

salt.modules.useradd.delete(name, remove=False, force=False)
    Remove a user from the minion

    CLI Example:

    salt '*' user.delete name True True

salt.modules.useradd.getent()
    Return the list of all info for all users

    CLI Example:

    salt '*' user.getent

salt.modules.useradd.info(name)
    Return user information

    CLI Example:

    salt '*' user.info root

salt.modules.useradd.list_groups(name)
    Return a list of groups the named user belongs to

    CLI Example:

    salt '*' user.list_groups foo

  salt.modules.virt

Work with virtual machines managed by libvirt

Required python modules: libvirt

salt.modules.virt.create(vm_)
    Start a defined domain

    CLI Example:

    salt '*' virt.create <vm name>

salt.modules.virt.create_xml_path(path)
    Start a defined domain

    CLI Example:

    salt '*' virt.create_xml_path <path to xml file on the node>

salt.modules.virt.create_xml_str(xml)
    Start a domain based on the xml passed to the function

    CLI Example:

    salt '*' virt.create_xml_str <xml in string format>

salt.modules.virt.destroy(vm_)
    Hard power down the virtual machine, this is equivalent to pulling the power

    CLI Example:

    salt '*' virt.destroy <vm name>

salt.modules.virt.freecpu()
    Return an int representing the number of unallocated cpus on this hypervisor

    CLI Example:

    salt '*' virt.freecpu

salt.modules.virt.freemem()
    Return an int representing the amount of memory that has not been given to virtual machines on this node

    CLI Example:

    salt '*' virt.freemem

salt.modules.virt.full_info()
    Return the node_info, vm_info and freemem

    CLI Example:

    salt '*' virt.full_info

salt.modules.virt.get_disks(vm_)
    Return the disks of a named vm

    CLI Example:

    salt '*' virt.get_disks <vm name>

salt.modules.virt.get_graphics(vm_)
    Returns the information on vnc for a given vm

    CLI Example:

    salt '*' virt.get_graphics <vm name>

salt.modules.virt.get_macs(vm_)
    Return a list off MAC addresses from the named vm

    CLI Example:

    salt '*' virt.get_macs <vm name>

salt.modules.virt.get_nics(vm_)
    Return info about the network interfaces of a named vm

    CLI Example:

    salt '*' virt.get_nics <vm name>

salt.modules.virt.get_xml(vm_)
    Returns the xml for a given vm

    CLI Example:

    salt '*' virt.get_xml <vm name>

salt.modules.virt.is_hyper()
    Returns a bool whether or not this nos is a hypervisor of any kind

    CLI Example:

    salt '*' virt.is_hyper

salt.modules.virt.is_kvm_hyper()
    Returns a bool whether or not this node is a KVM hypervisor

    CLI Example:

    salt '*' virt.is_kvm_hyper

salt.modules.virt.is_xen_hyper()
    Returns a bool whether or not this node is a XEN hypervisor

    CLI Example:

    salt '*' virt.is_xen_hyper

salt.modules.virt.list_active_vms()
    Return a list of names for active virtual machine on the minion

    CLI Example:

    salt '*' virt.list_active_vms

salt.modules.virt.list_inactive_vms()
    Return a list of names for inactive virtual machine on the minion

    CLI Example:

    salt '*' virt.list_inactive_vms

salt.modules.virt.list_vms()
    Return a list of virtual machine names on the minion

    CLI Example:

    salt '*' virt.list_vms

salt.modules.virt.migrate(vm_, target)
    Shared storage migration

    CLI Example:

    salt '*' virt.migrate <vm name> <target hypervisor>

salt.modules.virt.migrate_non_shared(vm_, target)
    Attempt to execute non-shared storage "all" migration

    CLI Example:

    salt '*' virt.migrate_non_shared <vm name> <target hypervisor>

salt.modules.virt.migrate_non_shared_inc(vm_, target)
    Attempt to execute non-shared storage "all" migration

    CLI Example:

    salt '*' virt.migrate_non_shared_inc <vm name> <target hypervisor>

salt.modules.virt.node_info()
    Return a dict with information about this node

    CLI Example:

    salt '*' virt.node_info

salt.modules.virt.pause(vm_)
    Pause the named vm

    CLI Example:

    salt '*' virt.pause <vm name>

salt.modules.virt.purge(vm_, dirs=False)
    Recursively destroy and delete a virtual machine, pass True for dir's to also delete the directories containing the virtual machine disk images - USE WITH EXTREME CAUTION!

    CLI Example:

    salt '*' virt.purge <vm name>

salt.modules.virt.resume(vm_)
    Resume the named vm

    CLI Example:

    salt '*' virt.resume <vm name>

salt.modules.virt.seed_non_shared_migrate(disks, force=False)
    Non shared migration requires that the disks be present on the migration destination, pass the disks information via this function, to the migration destination before executing the migration.

    CLI Example:

    salt '*' virt.seed_non_shared_migrate <disks>

salt.modules.virt.set_autostart(vm_, state='on')
    Set the autostart flag on a VM so that the VM will start with the host system on reboot.

    CLI Example:

    salt "*" virt.set_autostart <vm name> <on | off>

salt.modules.virt.shutdown(vm_)
    Send a soft shutdown signal to the named vm

    CLI Example:

    salt '*' virt.shutdown <vm name>

salt.modules.virt.start(vm_)
    Alias for the obscurely named 'create' function

    CLI Example:

    salt '*' virt.start <vm name>

salt.modules.virt.undefine(vm_)
    Remove a defined vm, this does not purge the virtual machine image, and this only works if the vm is powered down

    CLI Example:

    salt '*' virt.undefine <vm name>

salt.modules.virt.virt_type()
    Returns the virtual machine type as a string

    CLI Example:

    salt '*' virt.virt_type

salt.modules.virt.vm_info(vm_=None)
    Return detailed information about the vms on this hyper in a list of dicts:

    [
        'your-vm': {
            'cpu': <int>,
            'maxMem': <int>,
            'mem': <int>,
            'state': '<state>',
            'cputime' <int>
            },
        ...
        ]

    If you pass a VM name in as an argument then it will return info for just the named VM, otherwise it will return all VMs.

    CLI Example:

    salt '*' virt.vm_info

salt.modules.virt.vm_state(vm_)
    Return the status of the named VM.

    CLI Example:

    salt '*' virt.vm_state <vm name>

  salt.modules.virtualenv

Create virtualenv environments

salt.modules.virtualenv.create(path, venv_bin='virtualenv', no_site_packages=False, system_site_packages=False, distribute=False, clear=False, python='', extra_search_dir='', never_download=False, prompt='', runas=None)
    Create a virtualenv

path
    The path to create the virtualenv

venv_bin
    'virtualenv' The name (and optionally path) of the virtualenv command. This can also be set globally in the minion config file as virtualenv.venv_bin.

no_site_packages
    False Passthrough argument given to virtualenv

system_site_packages
    False Passthrough argument given to virtualenv

distribute
    False Passthrough argument given to virtualenv

clear
    False Passthrough argument given to virtualenv

python
    (default) Passthrough argument given to virtualenv

extra_search_dir
    (default) Passthrough argument given to virtualenv

never_download
    (default) Passthrough argument given to virtualenv

prompt
    (default) Passthrough argument given to virtualenv

runas
    None Set ownership for the virtualenv

    CLI Example:

    salt '*' virtualenv.create /path/to/new/virtualenv

  salt.modules.win_disk

Module for gathering disk information on Windows

salt.modules.win_disk.usage()
    Return usage information for volumes mounted on this minion

    CLI Example:

    salt '*' disk.usage

  salt.modules.win_file

Manage information about files on the minion, set/read user, group data

Required python modules: win32api, win32con, win32security, ntsecuritycon

salt.modules.win_file.append(path, *args)
    Append text to the end of a file

    CLI Example:

    salt '*' file.append /etc/motd \
            "With all thine offerings thou shalt offer salt."\
            "Salt is what makes things taste bad when it isn't in them."

    New in version 0.9.5.

salt.modules.win_file.chgrp(path, group)
    Change the group of a file

    CLI Example:

    salt '*' file.chgrp c:\temp\test.txt administrators

salt.modules.win_file.chown(path, user, group)
    Chown a file, pass the file the desired user and group

    CLI Example:

    salt '*' file.chown c:\temp\test.txt myusername administrators

salt.modules.win_file.comment(path, regex, char='#', backup='.bak')
    Comment out specified lines in a file

path
    The full path to the file to be edited

regex
    A regular expression used to find the lines that are to be commented; this pattern will be wrapped in parenthesis and will move any preceding/trailing ^ or $ characters outside the parenthesis (e.g., the pattern ^foo$ will be rewritten as ^(foo)$)

char
    # The character to be inserted at the beginning of a line in order to comment it out

backup
    .bak The file will be backed up before edit with this file extension

Warning
    This backup will be overwritten each time sed / comment / uncomment is called. Meaning the backup will only be useful after the first invocation.

CLI Example:

salt '*' file.comment /etc/modules pcspkr

New in version 0.9.5.

salt.modules.win_file.contains(path, text, limit='')
    Return True if the file at path contains text

    CLI Example:

    salt '*' file.contains /etc/crontab 'mymaintenance.sh'

    New in version 0.9.5.

salt.modules.win_file.find(path, **kwargs)
    Approximate the Unix find(1) command and return a list of paths that meet the specified critera.

    The options include match criteria:

    name    = path-glob                 # case sensitive
    iname   = path-glob                 # case insensitive
    regex   = path-regex                # case sensitive
    iregex  = path-regex                # case insensitive
    type    = file-types                # match any listed type
    user    = users                     # match any listed user
    group   = groups                    # match any listed group
    size    = [+-]number[size-unit]     # default unit = byte
    mtime   = interval                  # modified since date
    grep    = regex                     # search file contents

    and/or actions:

    delete [= file-types]               # default type = 'f'
    exec    = command [arg ...]         # where {} is replaced by pathname
    print  [= print-opts]

    The default action is 'print=path'.

    file-glob:

    *                = match zero or more chars
    ?                = match any char
    [abc]            = match a, b, or c
    [!abc] or [^abc] = match anything except a, b, and c
    [x-y]            = match chars x through y
    [!x-y] or [^x-y] = match anything except chars x through y
    {a,b,c}          = match a or b or c

    path-regex: a Python re (regular expression) pattern to match pathnames

    file-types: a string of one or more of the following:

    a: all file types
    b: block device
    c: character device
    d: directory
    p: FIFO (named pipe)
    f: plain file
    l: symlink
    s: socket

    users: a space and/or comma separated list of user names and/or uids

    groups: a space and/or comma separated list of group names and/or gids

    size-unit:

    b: bytes
    k: kilobytes
    m: megabytes
    g: gigabytes
    t: terabytes

    interval:

    [<num>w] [<num>[d]] [<num>h] [<num>m] [<num>s]
    where:
        w: week
        d: day
        h: hour
        m: minute
        s: second

    print-opts: a comma and/or space separated list of one or more of the following:

    group: group name
    md5:   MD5 digest of file contents
    mode:  file permissions (as integer)
    mtime: last modification time (as time_t)
    name:  file basename
    path:  file absolute path
    size:  file size in bytes
    type:  file type
    user:  user name

    CLI Examples:

    salt '*' file.find / type=f name=\*.bak size=+10m
    salt '*' file.find /var mtime=+30d size=+10m print=path,size,mtime
    salt '*' file.find /var/log name=\*.[0-9] mtime=+30d size=+10m delete

salt.modules.win_file.get_gid(path)
    Return the id of the group that owns a given file

    CLI Example:

    salt '*' file.get_gid c:\temp\test.txt

salt.modules.win_file.get_group(path)
    Return the group that owns a given file

    CLI Example:

    salt '*' file.get_group c:\temp\test.txt

salt.modules.win_file.get_mode(path)
    Return the mode of a file

    Right now we're just returning 777 because Windows' doesn't have a mode like Linux

    CLI Example:

    salt '*' file.get_mode /etc/passwd

salt.modules.win_file.get_sum(path, form='md5')
    Return the sum for the given file, default is md5, sha1, sha224, sha256, sha384, sha512 are supported

    CLI Example:

    salt '*' file.get_sum /etc/passwd sha512

salt.modules.win_file.get_uid(path)
    Return the id of the user that owns a given file

    CLI Example:

    salt '*' file.get_uid c:\temp\test.txt

salt.modules.win_file.get_user(path)
    Return the user that owns a given file

    CLI Example:

    salt '*' file.get_user c:\temp\test.txt

salt.modules.win_file.gid_to_group(gid)
    Convert the group id to the group name on this system

    CLI Example:

    salt '*' file.gid_to_group S-1-5-21-626487655-2533044672-482107328-1010

salt.modules.win_file.group_to_gid(group)
    Convert the group to the gid on this system

    CLI Example:

    salt '*' file.group_to_gid administrators

salt.modules.win_file.sed(path, before, after, limit='', backup='.bak', options='-r -e', flags='g')
    Make a simple edit to a file

    Equivalent to:

    sed <backup> <options> "/<limit>/ s/<before>/<after>/<flags> <file>"

path
    The full path to the file to be edited

before
    A pattern to find in order to replace with after

after
    Text that will replace before

limit
    '' An initial pattern to search for before searching for before

backup
    .bak The file will be backed up before edit with this file extension; WARNING: each time sed/comment/uncomment is called will overwrite this backup

options
    -r -e Options to pass to sed

flags
    g Flags to modify the sed search; e.g., i for case-insensitve pattern matching

    Forward slashes and single quotes will be escaped automatically in the before and after patterns.

    CLI Example:

    salt '*' file.sed /etc/httpd/httpd.conf 'LogLevel warn' 'LogLevel info'

    New in version 0.9.5.

salt.modules.win_file.touch(name, atime=None, mtime=None)
    Just like 'nix's "touch" command, create a file if it doesn't exist or simply update the atime and mtime if it already does.

atime:
    Access time in Unix epoch time

mtime:
    Last modification in Unix epoch time

    CLI Example:

    salt '*' file.touch /var/log/emptyfile

    New in version 0.9.5.

salt.modules.win_file.uid_to_user(uid)
    Convert a uid to a user name

    CLI Example:

    salt '*' file.uid_to_user S-1-5-21-626487655-2533044672-482107328-1010

salt.modules.win_file.uncomment(path, regex, char='#', backup='.bak')
    Uncomment specified commented lines in a file

path
    The full path to the file to be edited

regex
    A regular expression used to find the lines that are to be uncommented. This regex should not include the comment character. A leading ^ character will be stripped for convenience (for easily switching between comment() and uncomment()).

char
    # The character to remove in order to uncomment a line; if a single whitespace character follows the comment it will also be removed

backup
    .bak The file will be backed up before edit with this file extension; WARNING: each time sed/comment/uncomment is called will overwrite this backup

    CLI Example:

    salt '*' file.uncomment /etc/hosts.deny 'ALL: PARANOID'

    New in version 0.9.5.

salt.modules.win_file.user_to_uid(user)
    Convert user name to a uid

    CLI Example:

    salt '*' file.user_to_uid myusername

  salt.modules.win_groupadd

Manage groups on Windows

salt.modules.win_groupadd.add(name, gid=None, system=False)
    Add the specified group

    CLI Example:

    salt '*' group.add foo

salt.modules.win_groupadd.delete(name)
    Remove the named group

    CLI Example:

    salt '*' group.delete foo

salt.modules.win_groupadd.getent()
    Return info on all groups

    CLI Example:

    salt '*' group.getent

salt.modules.win_groupadd.info(name)
    Return information about a group

    CLI Example:

    salt '*' group.info foo

  salt.modules.win_network

Module for gathering and managing network information

salt.modules.win_network.dig(host)
    Performs a DNS lookup with dig

    Note: dig must be installed on the Windows minion

    CLI Example:

    salt '*' network.dig archlinux.org

salt.modules.win_network.hwaddr(interface)
    Returns the hwaddr for a given interface

    CLI Example:

    salt '*' network.hwaddr 'Wireless LAN adapter Wireless Network Connection'

salt.modules.win_network.interfaces()
    Returns a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr)

    CLI Example:

    salt '*' network.interfaces

salt.modules.win_network.ipaddr(interface)
    Returns the IP address for a given interface

    CLI Example:

    salt '*' network.ipaddr 'Wireless LAN adapter Wireless Network Connection'

salt.modules.win_network.isportopen(host, port)
    Return status of a port

    CLI Example:

    salt '*' network.isportopen 127.0.0.1 22

salt.modules.win_network.netmask(interface)
    Returns the netmask for a given interface

    CLI Example:

    salt '*' network.netmask 'Wireless LAN adapter Wireless Network Connection'

salt.modules.win_network.netstat()
    Return information on open ports and states

    CLI Example:

    salt '*' network.netstat

salt.modules.win_network.nslookup(host)
    Query DNS for information about a domain or ip address

    CLI Example:

    salt '*' network.nslookup archlinux.org

salt.modules.win_network.ping(host)
    Performs a ping to a host

    CLI Example:

    salt '*' network.ping archlinux.org

salt.modules.win_network.traceroute(host)
    Performs a traceroute to a 3rd party host

    CLI Example:

    salt '*' network.traceroute archlinux.org

salt.modules.win_network.up(interface)
    Returns True if interface is up, otherwise returns False

    CLI Example:

    salt '*' network.up 'Wireless LAN adapter Wireless Network Connection'

  salt.modules.win_pkg

A module to manage software on Windows

salt.modules.win_pkg.available_version(name)
    The available version of the package in the repository

    CLI Example:

    salt '*' pkg.available_version <package name>

salt.modules.win_pkg.install(name, refresh=False, **kwargs)
    Install the passed package

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.install <package name>

salt.modules.win_pkg.list_pkgs(*args)
    List the packages currently installed in a dict:

    {'<package_name>': '<version>'}

    CLI Example:

    salt '*' pkg.list_pkgs

salt.modules.win_pkg.list_upgrades()
    List all available package upgrades on this system

    CLI Example:

    salt '*' pkg.list_upgrades

salt.modules.win_pkg.purge(name)
    Recursively remove a package and all dependencies which were installed with it

    Return a list containing the removed packages.

    CLI Example:

    salt '*' pkg.purge <package name>

salt.modules.win_pkg.refresh_db()
    Just recheck the repository and return a dict:

    {'<database name>': Bool}

    CLI Example:

    salt '*' pkg.refresh_db

salt.modules.win_pkg.remove(name)
    Remove a single package

    Return a list containing the removed packages.

    CLI Example:

    salt '*' pkg.remove <package name>

salt.modules.win_pkg.upgrade()
    Run a full system upgrade

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.upgrade

salt.modules.win_pkg.upgrade_available(name)
    Check whether or not an upgrade is available for a given package

    CLI Example:

    salt '*' pkg.upgrade_available <package name>

salt.modules.win_pkg.version(name)
    Returns a version if the package is installed, else returns an empty string

    CLI Example:

    salt '*' pkg.version <package name>

  salt.modules.win_service

Windows Service module.

salt.modules.win_service.disable(name)
    Disable the named service to start at boot

    CLI Example:

    salt '*' service.disable <service name>

salt.modules.win_service.disabled(name)
    Check to see if the named service is disabled to start on boot

    CLI Example:

    salt '*' service.disabled <service name>

salt.modules.win_service.enable(name)
    Enable the named service to start at boot

    CLI Example:

    salt '*' service.enable <service name>

salt.modules.win_service.enabled(name)
    Check to see if the named service is enabled to start on boot

    CLI Example:

    salt '*' service.enabled <service name>

salt.modules.win_service.get_all()
    Return all installed services

    CLI Example:

    salt '*' service.get_all

salt.modules.win_service.get_disabled()
    Return the disabled services

    CLI Example:

    salt '*' service.get_disabled

salt.modules.win_service.get_enabled()
    Return the enabled services

    CLI Example:

    salt '*' service.get_enabled

salt.modules.win_service.getsid(name)
    Return the sid for this windows service

    CLI Example:

    salt '*' service.getsid <service name>

salt.modules.win_service.restart(name)
    Restart the named service

    CLI Example:

    salt '*' service.restart <service name>

salt.modules.win_service.start(name)
    Start the specified service

    CLI Example:

    salt '*' service.start <service name>

salt.modules.win_service.status(name, sig=None)
    Return the status for a service, returns the PID or an empty string if the service is running or not, pass a signature to use to find the service via ps

    CLI Example:

    salt '*' service.status <service name> [service signature]

salt.modules.win_service.stop(name)
    Stop the specified service

    CLI Example:

    salt '*' service.stop <service name>

  salt.modules.win_shadow

Manage the shadow file

salt.modules.win_shadow.info(name)
    Return information for the specified user This is just returns dummy data so that salt states can work.

    CLI Example:

    salt '*' shadow.info root

salt.modules.win_shadow.set_password(name, password)
    Set the password for a named user.

    CLI Example:

    salt '*' shadow.set_password root mysecretpassword

  salt.modules.win_useradd

Manage Windows users with the net user command

NOTE: This currently only works with local user accounts, not domain accounts

salt.modules.win_useradd.add(name, uid=None, gid=None, groups=None, home=False, shell=None, system=False)
    Add a user to the minion

    CLI Example:

    salt '*' user.add name password

salt.modules.win_useradd.addgroup(name, group)
    Add user to a group

    CLI Example:

    salt '*' user.addgroup username groupname

salt.modules.win_useradd.chgroups(name, groups, append=False)
    Change the groups this user belongs to, add append to append the specified groups

    CLI Example:

    salt '*' user.chgroups foo wheel,root True

salt.modules.win_useradd.chhome(name, home)
    Change the home directory of the user

    CLI Example:

    salt '*' user.chhome foo \\fileserver\home\foo

salt.modules.win_useradd.chprofile(name, profile)
    Change the profile directory of the user

    CLI Example:

    salt '*' user.chprofile foo \\fileserver\profiles\foo

salt.modules.win_useradd.delete(name)
    Remove a user from the minion

    CLI Example:

    salt '*' user.delete name

salt.modules.win_useradd.getent()
    Return the list of all info for all users

    CLI Example:

    salt '*' user.getent

salt.modules.win_useradd.info(name)
    Return user information

    CLI Example:

    salt '*' user.info root

salt.modules.win_useradd.list_groups(name)
    Return a list of groups the named user belongs to

    CLI Example:

    salt '*' user.list_groups foo

salt.modules.win_useradd.removegroup(name, group)
    Remove user from a group

    CLI Example:

    salt '*' user.removegroup username groupname

salt.modules.win_useradd.setpassword(name, password)
    Set a user's password

    CLI Example:

    salt '*' user.setpassword name password

  salt.modules.yumpkg

New in version 0.9.4: This module replaces the "yum" module in previous releases. It is backward compatibile and uses the native yum Python interface instead of the CLI interface.

Support for YUM

Required python modules: yum, rpm, rpmUtils

salt.modules.yumpkg.available_version(name)
    The available version of the package in the repository

    CLI Example:

    salt '*' pkg.available_version <package name>

salt.modules.yumpkg.clean_metadata()
    Cleans local yum metadata.

    CLI Example:

    salt '*' pkg.clean_metadata

salt.modules.yumpkg.install(pkgs, refresh=False, repo='', skip_verify=False, **kwargs)
    Install the passed package(s)

pkg The name of the package to be installed

refresh
    False Clean out the yum database before executing

repo
    (default) Specify a package repository to install from (e.g., yum --enablerepo=somerepo)

skip_verify
    False Skip the GPG verification check (e.g., --nogpgcheck)

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.install 'package package package'

salt.modules.yumpkg.list_pkgs(*args)
    List the packages currently installed in a dict:

    {'<package_name>': '<version>'}

    CLI Example:

    salt '*' pkg.list_pkgs

salt.modules.yumpkg.list_upgrades(*args)
    Check whether or not an upgrade is available for all packages

    CLI Example:

    salt '*' pkg.list_upgrades

salt.modules.yumpkg.purge(pkgs)
    Yum does not have a purge, this function calls remove

    Return a list containing the removed packages:

    CLI Example:

    salt '*' pkg.purge <package name>

salt.modules.yumpkg.refresh_db()
    Since yum refreshes the database automatically, this runs a yum clean, so that the next yum operation will have a clean database

    CLI Example:

    salt '*' pkg.refresh_db

salt.modules.yumpkg.remove(pkgs)
    Removes packages with yum remove

    Return a list containing the removed packages:

    CLI Example:

    salt '*' pkg.remove <package,package,package>

salt.modules.yumpkg.upgrade()
    Run a full system upgrade, a yum upgrade

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.upgrade

salt.modules.yumpkg.upgrade_available(name)
    Check whether or not an upgrade is available for a given package

    CLI Example:

    salt '*' pkg.upgrade_available <package name>

salt.modules.yumpkg.version(name)
    Returns a version if the package is installed, else returns an empty string

    CLI Example:

    salt '*' pkg.version <package name>

  salt.modules.yumpkg5

Support for YUM

salt.modules.yumpkg5.available_version(name)
    The available version of the package in the repository

    CLI Example:

    salt '*' pkg.available_version <package name>

salt.modules.yumpkg5.install(pkg, refresh=False, repo='', skip_verify=False, **kwargs)
    Install the passed package

pkg The name of the package to be installed

refresh
    False Clean out the yum database before executing

repo
    (default) Specify a package repository to install from (e.g., yum --enablerepo=somerepo)

skip_verify
    False Skip the GPG verification check (e.g., --nogpgcheck)

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.install <package name>

salt.modules.yumpkg5.list_pkgs()
    List the packages currently installed in a dict:

    {'<package_name>': '<version>'}

    CLI Example:

    salt '*' pkg.list_pkgs

salt.modules.yumpkg5.list_upgrades()
    Check whether or not an upgrade is available for all packages

    CLI Example:

    salt '*' pkg.list_upgrades

salt.modules.yumpkg5.purge(pkg)
    Yum does not have a purge, this function calls remove

    Return a list containing the removed packages:

    CLI Example:

    salt '*' pkg.purge <package name>

salt.modules.yumpkg5.refresh_db()
    Since yum refreshes the database automatically, this runs a yum clean, so that the next yum operation will have a clean database

    CLI Example:

    salt '*' pkg.refresh_db

salt.modules.yumpkg5.remove(pkg)
    Remove a single package with yum remove

    Return a list containing the removed packages:

    CLI Example:

    salt '*' pkg.remove <package name>

salt.modules.yumpkg5.upgrade()
    Run a full system upgrade, a yum upgrade

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.upgrade

salt.modules.yumpkg5.upgrade_available(name)
    Check whether or not an upgrade is available for a given package

    CLI Example:

    salt '*' pkg.upgrade_available <package name>

salt.modules.yumpkg5.version(name)
    Returns a version if the package is installed, else returns an empty string

    CLI Example:

    salt '*' pkg.version <package name>

  salt.modules.zypper

Package support for openSUSE via the zypper package manager

salt.modules.zypper.available_version(name)
    Return the available version of a given package

    CLI Example:

    salt '*' pkg.available_version <package name>

salt.modules.zypper.install(name, refresh=False, **kwargs)
    Install the passed package, add refresh=True to install with an -Sy

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.install <package name>

salt.modules.zypper.list_pkgs()
    List the packages currently installed as a dict:

    {'<package_name>': '<version>'}

    CLI Example:

    salt '*' pkg.list_pkgs

salt.modules.zypper.purge(name)
    Recursively remove a package and all dependencies which were installed with it, this will call a zypper remove -u

    Return a list containing the removed packages.

    CLI Example:

    salt '*' pkg.purge <package name>

salt.modules.zypper.refresh_db()
    Just run a zypper refresh, return a dict:

    {'<database name>': Bool}

    CLI Example:

    salt '*' pkg.refresh_db

salt.modules.zypper.remove(name)
    Remove a single package with zypper remove

    Return a list containing the removed packages.

    CLI Example:

    salt '*' pkg.remove <package name>

salt.modules.zypper.upgrade()
    Run a full system upgrade, a zypper upgrade

    Return a dict containing the new package names and versions:

    {'<package>': {'old': '<old-version>',
               'new': '<new-version>']}

    CLI Example:

    salt '*' pkg.upgrade

salt.modules.zypper.version(name)
    Returns a version if the package is installed, else returns an empty string

    CLI Example:

    salt '*' pkg.version <package name>

RETURNERS

By default the return values of the commands sent to the Salt minions are returned to the salt-master. But since the commands executed on the Salt minions are detached from the call on the Salt master, there is no need for the minion to return the data to the Salt master.

This is where the returner interface comes in. Returners are modules called in place of returning the data to the Salt master.

The returner interface allows the return data to be sent to any system that can receive data. This means that return data can be sent to a Redis server, a MongoDB server, a MySQL server, or any system!

See also

    Full list of builtin returners

  Using Returners

All commands will return the command data back to the master. Adding more returners will ensure that the data is also sent to the specified returner interfaces.

Specifying what returners to use is done when the command is invoked:

salt '*' test.ping --return redis_return

This command will ensure that the redis_return returner is used.

It is also possible to specify multiple returners:

salt '*' test.ping --return mongo_return,redis_return,cassandra_return

In this scenario all three returners will be called and the data from the test.ping command will be sent out to the three named returners.

  Writing a Returner

A returner is a module which contains a returner function, the returner function must accept a single argument. this argument is the return data from the called minion function. So if the minion function test.ping is called the value of the argument will be True.

A simple returner is implemented here:

import redis
import json
def returner(ret):
    '''
    Return information to a redis server
    '''
    # Get a redis commection
    serv = redis.Redis(
                host='redis-serv.example.com',
                port=6379,
                db='0')
    serv.sadd("%(id)s:jobs" % ret, ret['jid'])
    serv.set("%(jid)s:%(id)s" % ret, json.dumps(ret['return']))
    serv.sadd('jobs', ret['jid'])
    serv.sadd(ret['jid'], ret['id'])

This simple example of a returner set to send the data to a redis server serializes the data as json and sets it in redis.

  Examples

The collection of built-in Salt returners can be found here: https://github.com/saltstack/salt/blob/v0.10.0/salt/returners

FULL LIST OF BUILTIN RETURNERS
local | The local returner is used to test the returner interface, it just prints the
cassandra_return | Return data to a Cassandra ColumnFamily
mongo_return | Return data to a mongodb server
redis_return | Return data to a redis server

  salt.returners.local

The local returner is used to test the returner interface, it just prints the return data to the console to verify that it is being passed properly

salt.returners.local.returner(ret)
    Print the return data to the terminal to verify functionality

  salt.returners.cassandra_return

Return data to a Cassandra ColumnFamily

Here's an example Keyspace / ColumnFamily setup that works with this returner:

create keyspace salt;
use salt;
create column family returns
  with key_validation_class='UTF8Type'
  and comparator='UTF8Type'
  and default_validation_class='UTF8Type';

Required python modules: pycassa

salt.returners.cassandra_return.returner(ret)
    Return data to a Cassandra ColumnFamily

  salt.returners.mongo_return

Return data to a mongodb server

Required python modules: pymongo

salt.returners.mongo_return.returner(ret)
    Return data to a mongodb server

  salt.returners.redis_return

Return data to a redis server This is a VERY simple example for pushing data to a redis server and is not necessarily intended as a usable interface.

Required python modules: redis

salt.returners.redis_return.returner(ret)
    Return data to a redis data store

EXTENDING EXTERNAL SLS DATA

Sometimes a state defined in one SLS file will need to be modified from a separate SLS file. A good example of this is when an argument needs to be overwritten or when a service needs to watch an additional state.

  The Extend Declaration

The standard way to extend is via the extend declaration. The extend declaration is a top level declaration like include and encapsulates ID declaration data included from other SLS files. A standard extend looks like this:

include:
  - http
  - ssh
extend:
  apache:
    file:
      - name: /etc/httpd/conf/httpd.conf
      - source: salt://http/httpd2.conf
  ssh-server:
    service:
      - watch:
        - file: /etc/ssh/banner
/etc/ssh/banner:
  file:
    - managed
    - source: salt://ssh/banner

A few critical things happened here, first off the SLS files that are going to be extended are included, then the extend dec is defined. Under the extend dec 2 IDs are extended, the apache ID's file state is overwritten with a new name and source. Than the ssh server is extended to watch the banner file in addition to anything it is already watching.

  Extend is a Top Level Declaration

This means that extend can only be called once in an sls, if if is used twice then only one of the extend blocks will be read. So this is WRONG:

include:
  - http
  - ssh
extend:
  apache:
    file:
      - name: /etc/httpd/conf/httpd.conf
      - source: salt://http/httpd2.conf
# Second extend will overwrite the first!! Only make one
extend:
  ssh-server:
    service:
      - watch:
        - file: /etc/ssh/banner

  The Requisite in Statement

Since one of the most common things to do when extending another SLS is to add states for a service to watch, or anything for a watcher to watch, the requisite in statement was added to 0.9.8 to make extending the watch and require lists easier. The ssh-server extend statement above could be more cleanly defined like so:

include:
  - ssh
/etc/ssh/banner:
  file:
    - managed
    - source: salt://ssh/banner
    - watch_in:
      - service: ssh-server

  Rules to Extend By

There are a few rules to remember when extending states:

1.  Always include the SLS being extended with an include declaration

2.  Requisites (watch and require) are appended to, everything else is overwritten

3.  extend is a top level declaration, like an ID declaration, cannot be declared twice in a single SLS

4.  Many IDs can be extended under the extend declaration

FAILHARD GLOBAL OPTION

Normally, when a state fails Salt continues to execute the remainder of the defined states and will only refuse to execute states that require the failed state.

But the situation may exist, where you would want all state execution to stop if a single state execution fails. The capability to do this is called failing hard.

  State Level Failhard

A single state can have a failhard set, this means that if this individual state fails that all state execution will immediately stop. This is a great thing to do if there is a state that sets up a critical config file and setting a require for each state that reads the config would be cumbersome. A good example of this would be setting up a package manager early on:

/etc/yum.repos.d/company.repo:
  file:
    - managed
    - source: salt://company/yumrepo.conf
    - user: root
    - group: root
    - mode: 644
    - order: 1
    - failhard: True

In this situation, the yum repo is going to be configured before other states, and if it fails to lay down the config file, than no other states will be executed.

  Global Failhard

It may be desired to have failhard be applied to every state that is executed, if this is the case, then failhard can be set in the master configuration file. Setting failhard in the master configuration file will result in failing hard when any minion gathering states from the master have a state fail.

This is NOT the default behavior, normally Salt will only fail states that require a failed state.

Using the global failhard is generally not recommended, since it can result in states not being executed or even checked. It can also be confusing to see states failhard if an admin is not actively aware that the failhard has been set.

To use the global failhard set failhard: True in the master configuration file.

HIGHSTATE DATA STRUCTURE DEFINITIONS

  The Salt State Tree

Top file
    The main state file that instructs minions what environment and modules to use during state execution.

    Configurable via state_top.

See also

    A detailed description of the top file

State tree
    A collection of SLS files that live under the directory specified in file_roots. A state tree can be organized into SLS modules.

  Include declaration

Include declaration
    Defines a list of module reference strings to include in this SLS.

    Occurs only in the top level of the highstate structure.

    Example:

    include:
      - edit.vim
      - http.server

  Module reference

Module reference
    The name of a SLS module defined by a separate SLS file and residing on the Salt Master. A module named edit.vim is a reference to the SLS file salt://edit/vim.sls.

  ID declaration

ID declaration
    Defines an individual highstate component. Always references a value of a dictionary containing keys referencing state declarations and requisite declarations. Can be overridden by a name declaration or a names declaration.

    Occurs on the top level or under the extend declaration.

Note
    Naming gotchas

    Must not contain a dot, otherwise highstate summary output will be unpredictable. (This has been fixed in versions 0.9.7 and above)

    Must be unique across entire state tree. If the same ID declaration is used twice, only the first one matched will be used. All subsequent ID declarations with the same name will be ignored.

  Extend declaration

Extend declaration
    Extends a name declaration from an included SLS module. The keys of the extend declaration always define existing ID declarations which have been defined in included SLS modules.

    Occurs only in the top level and defines a dictionary.

    Extend declarations are useful for adding-to or overriding parts of a state declaration that is defined in another SLS file. In the following contrived example, the shown mywebsite.sls file is include -ing and extend -ing the apache.sls module in order to add a watch declaration that will restart Apache whenever the Apache configuration file, mywebsite changes.

    include:
      - apache
    extend:
      apache:
        service:
          - watch:
            - file: mywebsite
    mywebsite:
      file:
        - managed

  State declaration

State declaration
    A list which contains one string defining the function declaration and any number of function arg declaration dictionaries.

    Can, optionally, contain a number of additional components like the name override components — name and names. Can also contain requisite declarations.

    Occurs under an ID declaration.

  Requisite declaration

Requisite declaration
    A list containing requisite references.

    Used to build the action dependency tree. While Salt states are made to execute in a deterministic order, this order is managed by requiring and watching other Salt states.

    Occurs as a list component under a state declaration or as a key under an ID declaration.

  Requisite reference

Requisite reference
    A single key dictionary. The key is the name of the referenced state declaration and the value is the ID of the referenced ID declaration.

    Occurs as a single index in a requisite declaration list.

  Function declaration

Function declaration
    The name of the function to call within the state. A state declaration can contain only a single function declaration.

    For example, the following state declaration calls the installed function in the pkg state module:

    httpd:
      pkg:
        - installed

    Occurs as the only index in the state declaration list.

  Function arg declaration

Function arg declaration
    A single key dictionary referencing a Python type which is to be passed to the named function declaration as a parameter. The type must be the data type expected by the function.

    Occurs under a function declaration.

    For example in the following state declaration user, group, and mode are passed as arguments to the managed function in the file state module:

    /etc/http/conf/http.conf:
      file:
        - managed
        - user: root
        - group: root
        - mode: 644

  Name declaration

Name declaration
    Overrides the name argument of a state declaration. If name is not specified the ID declaration satisfies the name argument.

    The name is always a single key dictionary referencing a string.

    Overriding name is useful for a variety of scenarios.

    For example, avoiding clashing ID declarations. The following two state declarations cannot both have /etc/motd as the ID declaration:

    motd_perms:
      file:
        - managed
        - name: /etc/motd
        - mode: 644
    motd_quote:
      file:
        - append
        - name: /etc/motd
        - text: "Of all smells, bread; of all tastes, salt."

    Another common reason to override name is if the ID declaration is long and needs to be referenced in multiple places. In the example below it is much easier to specify mywebsite than to specify /etc/apache2/sites-available/mywebsite.com multiple times:

    mywebsite:
      file:
        - managed
        - name: /etc/apache2/sites-available/mywebsite.com
        - source: salt://mywebsite.com
    a2ensite mywebsite.com:
      cmd:
        - wait
        - unless: test -L /etc/apache2/sites-enabled/mywebsite.com
        - watch:
          - file: mywebsite
    apache2:
      service:
        - running
        - watch:
          - file: mywebsite

  Names declaration

Names declaration
    Expands the contents of the containing state declaration into multiple state declarations, each with its own name.

    For example, given the following state declaration:

    python-pkgs:
      pkg:
        - installed
        - names:
          - python-django
          - python-crypto
          - python-yaml

    Once converted into the lowstate data structure the above state declaration will be expanded into the following three state declarations:

    python-django:
      pkg:
        - installed
    python-crypto:
      pkg:
        - installed
    python-yaml:
      pkg:
        - installed

  Large example

Here is the layout in yaml using the names of the highdata structure components.

<Include Declaration>:
  - <Module Reference>
  - <Module Reference>
<Extend Declaration>:
  <ID Declaration>:
    [<overrides>]
<ID Declaration>:
  <State Declaration>:
    - <Function>
    - <Function Arg>
    - <Function Arg>
    - <Function Arg>
    - <Name>: <name>
    - <Requisite Declaration>:
      - <Requisite Reference>
      - <Requisite Reference>
<ID Declaration>:
  <State Declaration>:
    - <Function>
    - <Function Arg>
    - <Function Arg>
    - <Function Arg>
    - <Names>:
      - <name>
      - <name>
      - <name>
    - <Requisite Declaration>:
      - <Requisite Reference>
      - <Requisite Reference>

STATE ENFORCEMENT

Salt offers an optional interface to manage the configuration or "state" of the Salt minions. This interface is a fully capable mechanism used to enforce the state of systems from a central manager.

The Salt state system is made to be accurate, simple, and fast. And like the rest of the Salt system, Salt states are highly modular.

  State management

State management, also frequently called software configuration management (SCM), is a program that puts and keeps a system into a predetermined state. It installs software packages, starts or restarts services, or puts configuration files in place and watches them for changes.

Having a state management system in place allows you to easily and reliably configure and manage a few servers or a few thousand servers. It allows you to keep that configuration under version control.

Salt States is an extension of the Salt Modules that we discussed in the previous remote execution tutorial. Instead of calling one-off executions the state of a system can be easily defined and then enforced.

  Understanding the Salt State System Components

The Salt state system is comprised of a number of components. As a user, an understanding of the SLS and renderer systems are needed. But as a developer, an understanding of Salt states and how to write the states is needed as well.

  Salt SLS System

SLS The primary system used by the Salt state system is the SLS system. SLS stands for SaLt State.

    The Salt States are files which contain the information about how to configure Salt minions. The states are laid out in a directory tree and can be written in many different formats.

    The contents of the files and they way they are laid out is intended to be as simple as possible while allowing for maximum flexibility. The files are laid out in states and contains information about how the minion needs to be configured.

  SLS File Layout

SLS files are laid out in the Salt file server. A simple layout can look like this:

top.sls
ssh.sls
sshd_config
users/init.sls
users/admin.sls
salt/init.sls
salt/master.sls

This example shows the core concepts of file layout. The top file is a key component and is used with Salt matchers to match SLS states with minions. The .sls files are states. The rest of the files are seen by the Salt master as just files that can be downloaded.

The states are translated into dot notation, so the ssh.sls file is seen as the ssh state, the users/admin.sls file is seen as the users.admin states.

The init.sls files are translated to be the state name of the parent directory, so the salt/init.sls file translates to the Salt state.

The plain files are visible to the minions, as well as the state files. In Salt, everything is a file; there is no "magic translation" of files and file types. This means that a state file can be distributed to minions just like a plain text or binary file.

  SLS Files

The Salt state files are simple sets of data. Since the SLS files are just data they can be represented in a number of different ways. The default format is yaml generated from a jinja template. This allows for the states files to have all the language constructs of Python and the simplicity of yaml. State files can then be complicated jinja templates that translate down to yaml, or just plain and simple yaml files!

The State files are constructed data structures in a simple format. The format allows for many real activates to be expressed in very little text, while maintaining the utmost in readability and usability.

Here is an example of a Salt State:

vim:
  pkg:
    - installed
salt:
  pkg:
    - latest
  service:
    - running
    - require:
      - file: /etc/salt/minion
      - pkg: salt
    - names:
      - salt-master
      - salt-minion
    - watch:
      - file: /etc/salt/minion
/etc/salt/minion:
  file:
    - managed
    - source: salt://salt/minion
    - user: root
    - group: root
    - mode: 644
    - require:
      - pkg: salt

This short stanza will ensure that vim is installed, Salt is installed and up to date, the salt-master and salt-minion daemons are running and the Salt minion configuration file is in place. It will also ensure everything is deployed in the right order and that the Salt services are restarted when the watched file updated.

  The Top File

The top file is the mapping for the state system. The top file specifies which minions should have which modules applied and which environments they should draw the states from.

The top file works by specifying the environment, containing matchers with lists of Salt states sent to the matching minions:

base:
  '*':
    - salt
    - users
    - users.admin
  'saltmaster.*':
    - match: pcre
    - salt.master

This simple example uses the base environment, which is built into the default Salt setup, and then all minions will have the modules salt, users and users.admin since '*' will match all minions. Then the regular expression matcher will match all minions' with an id matching saltmaster.* and add the salt.master state.

  Renderer System

The Renderer system is a key component to the state system. SLS files are representations of Salt "high data" structures. All Salt cares about when reading an SLS file is the data structure that is produced from the file.

This allows Salt states to be represented by multiple types of files. The Renderer system can be used to allow different formats to be used for SLS files.

The available renderers can be found in the renderers directory in the Salt source code:

https://github.com/saltstack/salt/blob/v0.10.0/salt/renderers

By default SLS files are rendered using jinja as a templating engine, and yaml as the serialization format. Since the rendering system can be extended simply by adding a new renderer to the renderers directory, it is possible that any structured file could be used to represent the SLS files.

In the future xml and raw Python will be added, as well as many other formats.

ORDERING STATES

When creating Salt SLS files, it is often important to ensure that they run in a specific order. While states will always execute in the same order, that order is not necessarily defined the way you want it.

A few tools exist in Salt to set up the correct state ordering. These tools consist of requisite declarations and order options.

Note
    Salt does not execute state declarations in the order they appear in the source.

  Requisite Statements

Note
    This document represents behavior exhibited by Salt requisites as of version 0.9.7 of Salt.

Often when setting up states any single action will require or depend on another action. Salt allows you to build relationships between states with requisite statements. A requisite statement ensure that the named state is evaluated before the state requiring it. There are two types of requisite statements in Salt, require and watch.

These requisite statements are applied to a specific state declaration:

httpd:
  pkg:
    - installed
  file:
    - managed
    - name: /etc/httpd/conf/httpd.conf
    - source: salt://httpd/httpd.conf
    - require:
      - pkg: httpd

In this example we use the require requisite to declare that the file /etc/httpd/conf/httpd.conf should only be set up if the pkg state executes successfully.

The requisite system works by finding the states that are required and executing them before the state that requires them. Then the required states can be evaluated to see if they have executed correctly.

  Multiple Requisites

The requisite statement is passed as a list, allowing for the easy addition of more requisites. Both requisite types can also be separately declared:

httpd:
  pkg:
    - installed
  service:
    - running
    - enable: True
    - watch:
      - file: /etc/httpd/conf/httpd.conf
    - require:
      - pkg: httpd
      - user: httpd
      - group: httpd
  file:
    - managed
    - name: /etc/httpd/conf/httpd.conf
    - source: salt://httpd/httpd.conf
    - require:
      - pkg: httpd
  user:
    - present
  group:
    - present

In this example the httpd service is only going to be started if the package, user, group and file are executed successfully.

  The Require Requisite

The foundation of the requisite system is the require requisite. The require requisite ensures that the required state(s) are executed before the requiring state. So, if a state is declared that sets down a vimrc, then it would be pertinent to make sure that the vimrc file would only be set down if the vim package has been installed:

vim:
  pkg:
    - installed
  file:
    - managed
    - source: salt://vim/vimrc
    - require:
      - pkg: vim

In this case, the vimrc file will only be applied by Salt if and after the vim package is installed.

  The Watch Requisite

The watch requisite is more advanced than the require requisite. The watch requisite executes the same logic as require (therefore if something is watched it does not need to also be required) with the addition of executing logic if the required states have changed in some way.

The watch requisite checks to see if the watched states have returned any changes. If the watched state returns changes, and the watched states execute successfully, then the watching state will execute a function that reacts to the changes in the watched states.

Perhaps an example can better explain the behavior:

redis:
  pkg:
    - latest
  file:
    - managed
    - source: salt://redis/redis.conf
    - name: /etc/redis.conf
    - require:
      - pkg: redis
  service:
    - running
    - enable: True
    - watch:
      - file: /etc/redis.conf
      - pkg: redis

In this example the redis service will only be started if the file /etc/redis.conf is applied, and the file is only applied if the package is installed. This is normal require behavior, but if the watched file changes, or the watched package is installed or upgraded, then the redis service is restarted.

  Watch and the Watcher Function

The watch requisite is based on the watcher function, state Python modules can include a function called watcher, this function is then called if the watch call is invoked. In the case of the service module the underlying service is restarted. In the case of the cmd state the command is executed.

The watcher function for the service state looks like this:

def watcher(name, sig=None):
    '''
    The service watcher, called to invoke the watch command.
    name
        The name of the init or rc script used to manage the service
    sig
        The string to search for when looking for the service process with ps
    '''
    if __salt__['service.status'](name, sig):
        changes = {name: __salt__['service.restart'](name)}
        return {'name': name,
                'changes': changes,
                'result': True,
                'comment': 'Service restarted'}
    return {'name': name,
            'changes': {},
            'result': True,
            'comment': 'Service {0} started'.format(name)}

The watch requisite only works if the state that is watching has a watcher function written. If watch is set on a state that does not have a watcher function (like pkg), then the listed states will behave only as if they were under a require statement.

  The Order Option

Before using the order option, remember that the majority of state ordering should be done with a requisite declaration, and that a requisite declaration will override an order option.

The order option is used by adding an order number to a state declaration with the option order:

vim:
  pkg:
    - installed
    - order: 1

By adding the order option to 1 this ensures that the vim package will be installed in tandem with any other state declaration set to the order 1.

Any state declared without an order option will be executed after all states with order options are executed.

But this construct can only handle ordering states from the beginning. Sometimes you may want to send a state to the end of the line. To do this, set the order to last:

vim:
  pkg:
    - installed
    - order: last

STATE PROVIDERS

New in version 0.9.8.

Salt predetermines what modules should be mapped to what uses based on the properties of a system. These determinations are generally made for modules that provide things like package and service management.

Sometimes in states it may be needed for an alternative module to be used to provide the functionality needed. For instance, an Arch Linux system may have been set up with systemd support, so instead of using the default service module detected for Arch Linux, the systemd module can be used:

httpd:
  service:
    - running
    - enable: True
    - provider: systemd

In this instance the systemd module will replace the service virtual module which is used by default on Arch Linux, and the httpd service will be set up using systemd.

  Arbitrary Module Redirects

The provider statement can also be used for more powerful means, instead of overwriting or extending the module used for the named service an arbitrary module can be used to provide certain functionality.

emacs:
  pkg:
    - installed
    - provider:
      - pkg: yumpkg5
      - cmd: customcmd

In this example the default pkg module is being redirected to use the yumpkg5 module (yum via shelling out instead of via the yum API), but is also using a custom module to invoke commands. This could be used to dramatically change the behavior of a given state.

REQUISITES

The Salt requisite system is used to create relationships between states. The core idea being, that when one state it dependant somehow on another that interdependancy can be easily defined.

Requisites come in two types. Direct requisites, and requisite_ins. The relationships are directional, so a requisite statement makes the requireing state declaration depend on the required state declaration:

vim:
  pkg.installed
/etc/vimrc:
  file.managed:
    - source: salt://edit/vimrc
    - require:
      - pkg: vim

So in this example, the file /etc/vimrc depends on the vim package.

Requisite_in statements are the opposite, instead of saying "I depend on something", requisite_ins say "Someone depends on me":

vim:
  pkg.installed:
    - require_in:
      - file: /etc/vimrc
/etc/vimrc:
  file.managed:
    - source: salt://edit/vimrc

So here, with a requisite_in, the same thing is accomplished, but just from the other way around. The vim package is saying "/etc/vimrc depands on me".

In the end a single dependancy map is created and everything is executed in a finite and predictable order.

  Requisite and Requisite in types

There are three requisite statements that can be used in Salt. the require, watch and use requisites. Each requisite also has a corresponding requisite_in: require_in, watch_in and use_in. All of the requisites define specific relationships and always work with the dependancy logic defined above.

  Require

The most basic requisite statement is require. The behavior of require is simple. Make sure that the dependant state is executed before the depending state, and it the dependant state fails, don't run the depending state. So in the above examples the file /etc/vimrc will only be applied after the vim package is installed and only if the vim package is installed sucsessfully.

  Watch

The watch statement does everything the require statement does, but with a little more. The watch statement looks into the state modules for a function called mod_watch. If this function is not available in the corresponding state module, then watch does the same thing as require. If the mod_watch function is in the state module, then the watched state is checked to see if it made any chnges to the system, if it has, then mod_watch is called.

Prhaps the best example of using watch is with a service, when a service watches other states, then when the other states make changes on the system the service is reloaded or restarted.

  Use

# This needs to be filled in

THE TOP FILE

The top file is used to map what SLS modules get loaded onto what minions via the state system. The top file creates a few general abstractions. First it maps what nodes should pull from which environments, next it defines which matches systems should draw from.

  Environments

The environments in the top file corresponds with the environments defined in the file_roots variable. In a simple, single environment setup you only have the base environment, and therefore only one state tree. Here is a simple example of file_roots in the master configuration:

file_roots:
  base:
    - /srv/salt

This means that the top file will only have one environment to pull from, here is a simple, single environment top file:

base:
  '*':
    - core
    - edit

This also means that /srv/salt has a state tree. But if you want to use multiple environments, or partition the file server to serve more than just the state tree, then the file_roots option can be expanded:

file_roots:
  base:
    - /srv/salt/base
  dev:
    - /srv/salt/dev
  qa:
    - /srv/salt/qa
  prod:
    - /srv/salt/prod

Then our top file could reference the environments:

dev:
  'webserver*dev*':
    - webserver
  'db*dev*':
    - db
qa:
  'webserver*qa*':
    - webserver
  'db*qa*':
    - db
prod:
  'webserver*prod*':
    - webserver
  'db*prod*':
    - db

In this setup we have state trees in 3 of the 4 environments, and no state tree in the base environment. Notice that the targets for the minions specify environment data. In Salt the master determines who is in what environment, and many environments can be crossed together. For instance, a separate global state tree could be added to the base environment if it suits your deployment:

base:
  '*':
    - global
dev:
  'webserver*dev*':
    - webserver
  'db*dev*':
    - db
qa:
  'webserver*qa*':
    - webserver
  'db*qa*':
    - db
prod:
  'webserver*prod*':
    - webserver
  'db*prod*':
    - db

In this setup all systems will pull the global SLS from the base environment, as well as pull from their respective environments.

Remember, that since everything is a file in Salt, the environments are primarily file server environments, this means that environments that have nothing to do with states can be defined and used to distribute other files.

A clean and recommended setup for multiple environments would look like this:

# Master file_roots configuration:
file_roots:
  base:
    - /srv/salt/base
  dev:
    - /srv/salt/dev
  qa:
    - /srv/salt/qa
  prod:
    - /srv/salt/prod

Then only place state trees in the dev, qa and prod environments, leaving the base environment open for generic file transfers. Then the top.sls file would look something like this:

dev:
  'webserver*dev*':
    - webserver
  'db*dev*':
    - db
qa:
  'webserver*qa*':
    - webserver
  'db*qa*':
    - db
prod:
  'webserver*prod*':
    - webserver
  'db*prod*':
    - db

  Other Ways of Targeting Minions

In addition to globs, minions can be specified in top files a few other ways. Some common ones are compound matches and node groups.

Here is a slightly more complex top file example, showing the different types of matches you can perform:

base:
    '*':
        - ldap-client
        - networking
        - salt.minion
    'salt-master*':
        - salt.master
    '^(memcache|web).(qa|prod).loc$':
        - match: pcre
        - nagios.mon.web
        - apache.server
    'os:Ubuntu':
        - match: grain
        - repos.ubuntu
    'os:(RedHat|CentOS)'
        - match: grain_pcre
        - repos.epel
    'foo,bar,baz':
        - match: list
        - database
    'somekey:abc'
        - match: pillar
        - xyz
    'nag1* or G@role:monitoring':
        - match: compound
        - nagios.server

In this example top.sls, all minions get the ldap-client, networking and salt.minion states. Any minion with an id matching the salt-master* glob will get the salt.master state. Any minion with ids matching the regular expression ^(memcache|web).(qa|prod).loc$ will get the nagios.mon.web and apache.server states. All Ubuntu minions will receive the repos.ubuntu state, while all RHEL and CentOS minions will receive the repos.epel state. The minions foo, bar, and baz will receive the database state. Any minion with a pillar named somekey, having a value of abc will receive the xyz state. Finally, minions with ids matching the nag1* glob or with a grain named role equal to monitoring will receive the nagios.server state.

STATE MODULES

State Modules are the components that map to actual enforcement and management of Salt states.

  States are - Easy to Write!

State Modules should be easy to write and straightforward. The information passed to the SLS data structures will map directly to the states modules.

Mapping the information from the SLS data is simple, this example should illustrate:

/etc/salt/master: # maps to "name"
  file: # maps to State module filename eg https://github.com/saltstack/salt/blob/develop/salt/states/file.py
    - managed # maps to the managed function in the file State module
    - user: root # one of many options passed to the manage function
    - group: root
    - mode: 644
    - source: salt://salt/master

Therefore this SLS data can be directly linked to a module, function and arguments passed to that function.

This does issue the burden, that function names, state names and function arguments should be very human readable inside state modules, since they directly define the user interface.

  Using Custom State Modules

Place your custom state modules inside a _states directory within the file_roots specified by the master config file. These custom state modules can then be distributed in a number of ways. Custom state modules are distributed when state.highstate is run, or via the saltutil.sync_states function.

  Cross Calling Modules

As with Execution Modules, State Modules can also make use of the __salt__ and __grains__ data.

It is important to note that the real work of state management should not be done in the state module unless it is needed. A good example is the pkg state module. This module does not do any package management work, it just calls the pkg execution module. This makes the pkg state module completely generic, which is why there is only one pkg state module and many backend pkg execution modules.

On the other hand some modules will require that the logic be placed in the state module, a good example of this is the file module. But in the vast majority of cases this is not the best approach, and writing specific execution modules to do the backend work will be the optimal solution.

  Return Data

A State Module must return a dict containing the following keys/values:

•   name: The same value passed to the state as "name".

•   changes: A dict describing the changes made. Each thing changed should be a key, with its value being another dict with keys called "old" and "new" containing the old/new values. For example, the pkg state's changes dict has one key for each package changed, with the "old" and "new" keys in its sub-dict containing the old and new versions of the package.

•   result: A boolean value. True if the action was successful, otherwise False.

•   comment: A string containing a summary of the result.

  Watcher Function

If the state being written should support the watch requisite then a watcher function needs to be declared. The watcher function is called whenever the watch requisite is invoked and should be generic to the behavior of the state itself.

The watcher function should accept all of the options that the normal state functions accept (as they will be passed into the watcher function).

A watcher function typically is used to execute state specific reactive behavior, for instance, the watcher for the service module restarts the named service and makes it useful for the watcher to make the service react to changes in the environment.

The watcher function also needs to return the same data that a normal state function returns.

  Mod_init Interface

Some states need to execute something only once to ensure that an environment has been set up, or certain conditions global to the state behavior can be predefined. This is the realm of the mod_init interface.

A state module can have a function called mod_init which executes when the first state of this type is called. This interface was created primarily to improve the pkg state. When packages are installed the package metadata needs to be refreshed, but refreshing the package metadata every time a package is installed is wasteful. The mod_init function for the pkg state sets a flag down so that the first, and only the first, package installation attempt will refresh the package database (the package database can of course be manually called to refresh via the refresh option in the pkg state).

The mod_init function must accept the Low State Data for the given executing state as an argument. The low state data is a dict and can be seen by executing the state.show_lowstate function. Then the mod_init function must return a bool. If the return value is True, then the mod_init function will not be executed again, meaning that the needed behavior has been set up. Otherwise, if the mod_init function returns False, then the function will be called the next time.

A good example of the mod_init function is found in the pkg state module:

def mod_init(low):
    '''
    Refresh the package database here so that it only needs to happen once
    '''
    if low['fun'] == 'installed' or low['fun'] == 'latest':
        rtag = __gen_rtag()
        if not os.path.exists(rtag):
            open(rtag, 'w+').write('')
        return True
    else:
        return False

The mod_init function in the pkg state accepts the low state data as low and then checks to see if the function being called is going to install packages, if the function is not going to install packages then there is no need to refresh the package database. Therefore if the package database is prepared to refresh, then return True and the mod_init will not be called the next time a pkg state is evaluated, otherwise return False and the mod_init will be called next time a pkg state is evaluated.

FULL LIST OF BUILTIN STATES
alias | Configuration of email aliases.
cmd | Execution of arbitrary commands.
cron | Management of cron, the Unix command scheduler.
file | Operations on files, directories and symlinks.
gem | Installation of Ruby modules packaged as gems.
git | Interaction with Git repositories.
group | Management of user groups.
host | Management of addresses and names in hosts file.
kmod | Loading and unloading of kernel modules.
mount | Mounting of filesystems.
mysql_database | Management of MySQL databases (schemas).
mysql_grants | Management of MySQL grants (user permissions).
mysql_user | Management of MySQL users.
network | Configuration of network interfaces.
pip | Installation of Python packages using pip.
pkg | Installation of packages using OS package managers such as yum or apt-get.
postgres_database | Management of PostgreSQL databases (schemas).
rvm | Management of Ruby installations and gemsets with RVM, the Ruby Version Manager.
selinux | Management of SELinux rules.
service | Starting or restarting of services and daemons.
ssh_auth | Control of entries in SSH authorized_key files.
ssh_known_hosts | Control of SSH known_hosts entries.
sysctl | Configuration of the Linux kernel using sysctrl.
user | Management of user accounts.
virtualenv | Setup of Python virtualenv sandboxes.

  salt.states.alias

  Configuration of email aliases.

The mail aliases file can be managed to contain definitions for specific email aliases:

username:
  alias:
    - present
    - target: user@example.com

salt.states.alias.absent(name)
    Ensure that the named alias is absent

name
    The alias to remove

salt.states.alias.present(name, target)
    Ensures that the named alias is present with the given target

name
    The local user/address to assign an alias to

target
    The forwarding address

  salt.states.cmd

  Execution of arbitrary commands.

The cmd state module manages the enforcement of executed commands, this state can tell a command to run under certain circumstances.

  Available Functions

The cmd state only has a single function, the run function

run Execute a command given certain conditions

    A simple example:

    date > /tmp/salt-run:
    cmd:
        - run

    Only run if another execution returns successfully, in this case truncate syslog if there is no disk space:

    > /var/log/messages:
      cmd:
        - run
        - unless: echo 'foo' > /tmp/.test

salt.states.cmd.mod_watch(name, onlyif=None, unless=None, cwd='/root', user=None, group=None, shell=None, env=())
    Run a command if certain circumstances are met

name
    The command to execute, remember that the command will execute with the path and permissions of the salt-minion.

onlyif
    A command to run as a check, run the named command only if the command passed to the onlyif option returns true

unless
    A command to run as a check, only run the named command if the command passed to the unless option returns false

cwd The current working directory to execute the command in, defaults to /root

user
    The user name to run the command as

group
    The group context to run the command as

shell
    The shell to use for execution, defaults to the shell grain

salt.states.cmd.run(name, onlyif=None, unless=None, cwd='/root', user=None, group=None, shell=None, env=())
    Run a command if certain circumstances are met

name
    The command to execute, remember that the command will execute with the path and permissions of the salt-minion.

onlyif
    A command to run as a check, run the named command only if the command passed to the onlyif option returns true

unless
    A command to run as a check, only run the named command if the command passed to the unless option returns false

cwd The current working directory to execute the command in, defaults to /root

user
    The user name to run the command as

group
    The group context to run the command as

shell
    The shell to use for execution, defaults to the shell grain

salt.states.cmd.wait(name, onlyif=None, unless=None, cwd='/root', user=None, group=None, shell=None)
    Run the given command only if the watch statement calls it

name
    The command to execute, remember that the command will execute with the path and permissions of the salt-minion.

onlyif
    A command to run as a check, run the named command only if the command passed to the onlyif option returns true

unless
    A command to run as a check, only run the named command if the command passed to the unless option returns false

cwd The current working directory to execute the command in, defaults to /root

user
    The user name to run the command as

group
    The group context to run the command as

shell
    The shell to use for execution, defaults to /bin/sh

  salt.states.cron

  Management of cron, the Unix command scheduler.

The cron state module allows for user crontabs to be cleanly managed.

Cron declarations require a number of parameters. The timing parameters, need to be declared, minute, hour, daymonth, month and dayweek. The user who's crontab is to be edited also needs to be defined.

By default the timing arguments are all * and the user is root. When making changes to an existing cron job the name declaration is the unique factor, so if and existing cron that looks like this:

date > /tmp/crontest:
  cron:
    - present
    - user: root
    - minute: 5

Is changed to this:

date > /tmp/crontest:
  cron:
    - present
    - user: root
    - minute: 7
    - hour: 2

Then the existing cron will be updated, but if the cron command is changed, then a new cron job will be added to the user's crontab.

salt.states.cron.absent(name, user='root', minute='*', hour='*', daymonth='*', month='*', dayweek='*')
    Verifies that the specified cron job is absent for the specified user, only the name is matched when removing a cron job.

name
    The command that should be absent in the user crontab.

user
    The name of the user who's crontab needs to be modified, defaults to the root user

minute
    The information to be set into the minute section, this can be any string supported by your cron system's the minute field. Default is *

hour
    The information to be set in the hour section. Default is *

daymonth
    The information to be set in the day of month section. Default is *

month
    The information to be set in the month section. Default is *

dayweek
    The information to be set in the day of day of week section. Default is *

salt.states.cron.present(name, user='root', minute='*', hour='*', daymonth='*', month='*', dayweek='*')
    Verifies that the specified cron job is present for the specified user. For more advanced information about what exactly can be set in the cron timing parameters check your cron system's documentation. Most Unix-like systems' cron documentation can be found via the crontab man page: man 5 crontab.

name
    The command that should be executed by the cron job.

user
    The name of the user who's crontab needs to be modified, defaults to the root user

minute
    The information to be set into the minute section, this can be any string supported by your cron system's the minute field. Default is *

hour
    The information to be set in the hour section. Default is *

daymonth
    The information to be set in the day of month section. Default is *

month
    The information to be set in the month section. Default is *

dayweek
    The information to be set in the day of day of week section. Default is *

  salt.states.file

  Operations on files, directories and symlinks.

Salt States can aggressively manipulate files on a system. There are a number of ways in which files can be managed.

Regular files can be enforced with the managed function. This function downloads files from the salt master and places them on the target system. The downloaded files can be rendered as a jinja or mako template adding a dynamic component to file management. An example of file.managed which makes use of the jinja templating system would look like this:

/etc/http/conf/http.conf:
  file.managed:
    - source: salt://apache/http.conf
    - user: root
    - group: root
    - mode: 644
    - template: jinja
    - context:
        custom_var: "override"
    - defaults:
        custom_var: "default value"
        other_var: 123

Directories can be managed via the directory function. This function can create and enforce the permissions on a directory. A directory statement will look like this:

/srv/stuff/substuf:
  file.directory:
    - user: fred
    - group: users
    - mode: 755
    - makedirs: True

If you need to enforce user and/or group ownership recursively on the directory's contents, you can do so by adding a recurse directive:

/srv/stuff/substuf:
  file.directory:
    - user: fred
    - group: users
    - mode: 755
    - makedirs: True
    - recurse:
      - user
      - group

Symlinks can be easily created, the symlink function is very simple and only takes a few arguments:

/etc/grub.conf:
  file.symlink:
    - target: /boot/grub/grub.conf

Recursive directory management can also be set via the recurse function. Recursive directory management allows for a directory on the salt master to be recursively copied down to the minion. This is a great tool for deploying large code and configuration systems. A recuse state would look something like this:

/opt/code/flask:
  file.recurse:
    - source: salt://code/flask

salt.states.file.absent(name)
    Verify that the named file or directory is absent, this will work to reverse any of the functions in the file state module.

name
    The path which should be deleted

salt.states.file.append(name, text)
    Ensure that some text appears at the end of a file

    The text will not be appended again if it already exists in the file. You may specify a single line of text or a list of lines to append.

    Multi-line example:

    /etc/motd:
      file.append:
        - text: |
            Thou hadst better eat salt with the Philosophers of Greece,
            than sugar with the Courtiers of Italy.
            - Benjamin Franklin

    Multiple lines of text:

    /etc/motd:
      file.append:
        - text:
          - Trust no one unless you have eaten much salt with him.
          - Salt is born of the purest of parents: the sun and the sea.

    New in version 0.9.5.

salt.states.file.comment(name, regex, char='#', backup='.bak')
    Usage:

    /etc/fstab:
      file.comment:
        - regex: ^bind 127.0.0.1

    New in version 0.9.5.

salt.states.file.directory(name, user=None, group=None, recurse=[], mode=None, makedirs=False, clean=False, require=None)
    Ensure that a named directory is present and has the right perms

name
    The location to create or manage a directory

user
    The user to own the directory, this defaults to the user salt is running as on the minion

group
    The group ownership set for the directory, this defaults to the group salt is running as on the minion

recurse
    Enforce user/group ownership of directory recursively

mode
    The permissions to set on this directory, aka 755

makedirs
    If the directory is located in a path without a parent directory, then the state will fail. If makedirs is set to True, then the parent directories will be created to facilitate the creation of the named file.

clean
    Make sure that only files that are set up by salt and required by this function are kept. If this option is set then everything in this directory will be deleted unless it is required.

require
    Require other resources such as packages or files

salt.states.file.managed(name, source=None, source_hash='', user=None, group=None, mode=None, template=None, makedirs=False, context=None, replace=True, defaults=None, env=None, **kwargs)
    Manage a given file, this function allows for a file to be downloaded from the salt master and potentially run through a templating system.

name
    The location of the file to manage

source
    The source file to download to the minion, this source file can be hosted on either the salt master server, or on an http or ftp server. For files hosted on the salt file server, if the file is located on the master in the directory named spam, and is called eggs, the source string is salt://spam/eggs. If source is left blank or None, the file will be created as an empty file and the content will not be managed

    If the file is hosted on a http or ftp server then the source_hash argument is also required

source_hash:
    This can be either a file which contains a source hash string for the source, or a source hash string. The source hash string is the hash algorithm followed by the hash of the file: md5=e138491e9d5b97023cea823fe17bac22

user
    The user to own the file, this defaults to the user salt is running as on the minion

group
    The group ownership set for the file, this defaults to the group salt is running as on the minion

mode
    The permissions to set on this file, aka 644, 0775, 4664

template
    If this setting is applied then the named templating engine will be used to render the downloaded file, currently jinja and mako are supported

makedirs
    If the file is located in a path without a parent directory, then the state will fail. If makedirs is set to True, then the parent directories will be created to facilitate the creation of the named file.

replace
    If this file should be replaced, if false then this command will be ignored if the file exists already. Default is true.

context
    Overrides default context variables passed to the template.

defaults
    Default context passed to the template.

salt.states.file.recurse(name, source, clean=False, require=None, user=None, group=None, dir_mode=None, file_mode=None, env=None, include_empty=False, **kwargs)
    Recurse through a subdirectory on the master and copy said subdirecory over to the specified path.

name
    The directory to set the recursion in

source
    The source directory, this directory is located on the salt master file server and is specified with the salt:// protocol. If the directory is located on the master in the directory named spam, and is called eggs, the source string is salt://spam/eggs

clean
    Make sure that only files that are set up by salt and required by this function are kept. If this option is set then everything in this directory will be deleted unless it is required.

require
    Require other resources such as packages or files

user
    The user to own the directory, this defaults to the user salt is running as on the minion

group
    The group ownership set for the directory, this defaults to the group salt is running as on the minion

dir_mode
    The permissions mode to set any directories created

file_mode
    The permissions mode to set any files created

include_empty
    Set this to True if empty directories should also be created (default is False)

salt.states.file.sed(name, before, after, limit='', backup='.bak', options='-r -e', flags='g')
    Maintain a simple edit to a file

    The file will be searched for the before pattern before making the edit and then searched for the after pattern to verify the edit was successful using salt.modules.file.contains. In general the limit pattern should be as specific as possible and before and after should contain the minimal text to be changed.

    Usage:

    # Disable the epel repo by default
    /etc/yum.repos.d/epel.repo:
      file.sed:
        - before: 1
        - after: 0
        - limit: ^enabled=
    # Remove ldap from nsswitch
    /etc/nsswitch.conf:
      file.sed:
        - before: 'ldap'
        - after: ''
        - limit: '^passwd:'

    New in version 0.9.5.

salt.states.file.symlink(name, target, force=False, makedirs=False)
    Create a symlink

name
    The location of the symlink to create

target
    The location that the symlink points to

force
    If the location of the symlink exists and is not a symlink then the state will fail, set force to True and any file or directory in the way of the symlink file will be deleted to make room for the symlink

makedirs
    If the location of the symlink does not already have a parent directory then the state will fail, setting makedirs to True will allow Salt to create the parent directory

salt.states.file.touch(name, atime=None, mtime=None, makedirs=False)
    Replicate the 'nix "touch" command to create a new empty file or update the atime and mtime of an existing file.

    Usage:

    /var/log/httpd/logrotate.empty:
      file.touch

    New in version 0.9.5.

salt.states.file.uncomment(name, regex, char='#', backup='.bak')
    Usage:

    /etc/adduser.conf:
      file.uncomment:
        - regex: EXTRA_GROUPS

    New in version 0.9.5.

  salt.states.gem

  Installation of Ruby modules packaged as gems.

A state module to manage rubygems. Gems can be set up to be installed or removed. This module will use RVM if it is installed. In that case you can specify what ruby version and gemset to target.

addressable:
  gem:
    - installed
    - runas: rvm
    - ruby: jruby@jgemset

salt.states.gem.installed(name, ruby=None, runas=None)
    Make sure that a gem is installed.

name
    The name of the gem to install

ruby
    None For RVM installations: the ruby version and gemset to target.

runas
    None The user to run gem as.

salt.states.gem.removed(name, ruby=None, runas=None)
    Make sure that a gem is not installed.

name
    The name of the gem to uninstall

ruby
    None For RVM installations: the ruby version and gemset to target.

runas
    None The user to run gem as.

  salt.states.git

  Interaction with Git repositories.

NOTE: This modules is under heavy development and the API is subject to change. It may be replaced with a generic VCS module if this proves viable.

https://github.com/saltstack/salt.git:
  git:
    - latest
    - rev: develop
    - target: /tmp/salt

salt.states.git.latest(name, rev=None, target=None, runas=None, force=None)
    Make sure the repository is cloned to the given directory and is up to date

name
    Address of the remote repository as passed to "git clone"

rev The remote branch or revision to checkout after clone / before update

target
    Name of the target directory where repository is about to be cloned

runas
    Name of the user performing repository management operations

force
    Force git to clone into pre-existing directories (deletes contnents)

  salt.states.group

  Management of user groups.

The group module is used to create and manage unix group settings, groups can be either present or absent:

cheese:
  group:
    - present
    - gid: 7648
    - system: True

salt.states.group.absent(name)
    Ensure that the named group is absent

name
    The name of the group to remove

salt.states.group.present(name, gid=None, system=False)
    Ensure that a group is present

name
    The name of the group to manage

gid The group id to assign to the named group, if left empty then the next available group id will be assigned

  salt.states.host

  Management of addresses and names in hosts file.

The hosts file can be managed to contain definitions for specific hosts:

salt-master:
  host:
    - present
    - ip: 192.168.0.42

salt.states.host.absent(name, ip)
    Ensure that the named host is absent

name
    The host to remove

ip  The ip addr of the host to remove

salt.states.host.present(name, ip)
    Ensures that the named host is present with the given ip

name
    The host to assign an ip to

ip  The ip addr to apply to the host

  salt.states.kmod

  Loading and unloading of kernel modules.

The Kernel modules on a system can be managed cleanly with the kmod state module:

kvm_amd:
  kmod:
    - present
pcspkr:
  kmod:
    - absent

salt.states.kmod.absent(name)
    Verify that the named kernel module is not loaded

name
    The name of the kernel module to verify is not loaded

salt.states.kmod.present(name)
    Ensure that the specified kernel module is loaded

name
    The name of the kernel module to verify is loaded

  salt.states.mount

  Mounting of filesystems.

Mount any type of mountable filesystem with the mounted function:

/mnt/sdb:
  mount:
    - mounted
    - device: /dev/sdb1
    - fstype: ext4
    - mkmnt: True
    - opts:
      - defaults

salt.states.mount.mounted(name, device, fstype, mkmnt=False, opts=['defaults'], dump=0, pass_num=0, config='/etc/fstab', persist=True)
    Verify that a device is mounted

name
    The path to the location where the device is to be mounted

device
    The device name, typically the device node, such as /dev/sdb1

fstype
    The filesystem type, this will be xfs, ext2/3/4 in the case of classic filesystems, and fuse in the case of fuse mounts

mkmnt
    If the mount point is not present then the state will fail, set mkmnt to True to create the mount point if it is otherwise not present

opts
    A list object of options or a comma delimited list

dump
    The dump value to be passed into the fstab, default to 0

pass_num
    The pass value to be passed into the fstab, default to 0

config
    Set an alternative location for the fstab, default to /etc/fstab

remount
    Set if the file system can be remounted with the remount option, default to True

persist
    Set if the mount should be saved in the fstab, default to True

  salt.states.mysql_database

  Management of MySQL databases (schemas).

The mysql_database module is used to create and manage MySQL databases. Databases can be set as either absent or present

frank:
  mysql_database:
    - present

salt.states.mysql_database.absent(name)
    Ensure that the named database is absent

name
    The name of the database to remove

salt.states.mysql_database.present(name)
    Ensure that the named database is present with the specified properties

name
    The name of the database to manage

  salt.states.mysql_grants

  Management of MySQL grants (user permissions).

The mysql_grants module is used to grant and revoke MySQL permissions.

The name you pass in purely symbolic and does not have anything to do with the grant itself.

The database parameter needs to specify a 'priv_level' in the same specification as defined in the MySQL documentation:

•   *

•   *.*

•   db_name.*

•   db_name.tbl_name

•   etc...

    frank_exampledb:
       mysql_grants:
        - present
        - grant: select,insert,update
        - database: exampledb.*
        - user: frank
        - host: localhost
    frank_otherdb:
      mysql_grants:
        - present
        - grant: all privileges
        - database: otherdb.*
        - user: frank
    restricted_singletable:
      mysql_grants:
        - present
        - grant: select
        - database: somedb.sometable
        - user: joe

salt.states.mysql_grants.absent(name, grant=None, database=None, user=None, host='localhost', grant_option=False, escape=True)
    Ensure that the grant is absent

name
    The name (key) of the grant to add

grant
    The grant priv_type (ie. select,insert,update OR all privileges)

database
    The database priv_level (ie. db.tbl OR db.*)

user
    The user to apply the grant to

host
    The MySQL server

salt.states.mysql_grants.present(name, grant=None, database=None, user=None, host='localhost', grant_option=False, escape=True)
    Ensure that the grant is present with the specified properties

name
    The name (key) of the grant to add

grant
    The grant priv_type (ie. select,insert,update OR all privileges)

database
    The database priv_level (ie. db.tbl OR db.*)

user
    The user to apply the grant to

host
    The MySQL server

grant_option
    Adds the WITH GRANT OPTION to the defined grant. default: False

excape
    Defines if the database value gets escaped or not. default: True

  salt.states.mysql_user

  Management of MySQL users.

The mysql_user module is used manage MySQL users.

frank:
  mysql_user:
    - present
    - host: localhost
    - password: bobcat

salt.states.mysql_user.absent(name, host='localhost')
    Ensure that the named user is absent

name
    The name of the user to remove

salt.states.mysql_user.present(name, host='localhost', password=None, password_hash=None)
    Ensure that the named user is present with the specified properties

name
    The name of the user to manage

password
    The password

password_hash
    The password in hashed form

  salt.states.network

  Configuration of network interfaces.

The network module is used to create and manage network settings, interfaces can be set as either managed or ignored. By default all interfaces are ignored unless specified.

eth0:
  network:
    - managed
    - enabled: True
    - type: eth
    - proto: none
    - ipaddr: 10.1.0.1
    - netmask: 255.255.255.0
    - dns:
      - 8.8.8.8
      - 8.8.4.4
eth2:
  network:
    - managed
    - type: slave
    - master: bond0
eth3:
  network:
    - managed
    - type: slave
    - master: bond0
bond0:
  network:
    - managed
    - type: bond
    - ipaddr: 10.1.0.1
    - netmask: 255.255.255.0
    - dns:
      - 8.8.8.8
      - 8.8.4.4
    - ipv6:
    - enabled: False
    - use_in:
      - network: eth2
      - network: eth3
    - require:
      - network: eth2
      - network: eth3
    - mode: 802.3ad
    - miimon: 100
    - arp_interval: 250
    - downdelay: 200
    - lacp_rate: fast
    - max_bonds: 1
    - updelay: 0
    - use_carrier: on
    - xmit_hash_policy: layer2
    - mtu: 9000
    - autoneg: on
    - speed: 1000
    - duplex: full
    - rx: on
    - tx: off
    - sg: on
    - tso: off
    - ufo: off
    - gso: off
    - gro: off
    - lro: off
bond0.2:
  network:
    - managed
    - type: vlan
    - ipaddr: 10.1.0.2
    - use:
      - network: bond0
    - require:
      - network: bond0
bond0.3:
  network:
    - managed
    - type: vlan
    - ipaddr: 10.1.0.3
    - use:
      - network: bond0
    - require:
      - network: bond0
bond0.10:
  network:
    - managed
    - type: vlan
    - ipaddr: 10.1.0.4
    - use:
      - network: bond0
    - require:
      - network: bond0
bond0.12:
  network:
    - managed
    - type: vlan
    - ipaddr: 10.1.0.5
    - use:
      - network: bond0
    - require:
      - network: bond0

salt.states.network.managed(name, type, enabled=True, **kwargs)
    Ensure that the named interface is configured properly.

name
    The name of the interface to manage

type
    Type of interface and configuration.

enabled
    Designates the state of this interface.

kwargs
    The IP parameters for this interface.

  salt.states.pip

  Installation of Python packages using pip.

A state module to manage system installed python packages

virtualenvwrapper:
  pip:
    - installed
    - version: 3.0.1

salt.states.pip.installed(name, pip_bin=None, requirements=None, env=None, bin_env=None, log=None, proxy=None, timeout=None, editable=None, find_links=None, index_url=None, extra_index_url=None, no_index=False, mirrors=None, build=None, target=None, download=None, download_cache=None, source=None, upgrade=False, force_reinstall=False, ignore_installed=False, no_deps=False, no_install=False, no_download=False, install_options=None, user=None, cwd=None)
    Make sure the package is installed

name
    The name of the python package to install

pip_bin
    None Deprecated, use bin_env

env None Deprecated, use bin_env

bin_env
    None the pip executable or virtualenv to use

salt.states.pip.removed(name, packages=None, requirements=None, bin_env=None, log=None, proxy=None, timeout=None, user=None, cwd=None)
    Make sure that a package is not installed.

name
    The name of the package to uninstall

bin_env
    None the pip executable or virtualenenv to use

  salt.states.pkg

  Installation of packages using OS package managers such as yum or apt-get.

Salt can manage software packages via the pkg state module, packages can be set up to be installed, latest, removed and purged. Package management declarations are typically rather simple:

vim:
  pkg:
    - installed

salt.states.pkg.installed(name, version=None, refresh=False, repo='', skip_verify=False, **kwargs)
    Verify that the package is installed, and only that it is installed. This state will not upgrade an existing package and only verify that it is installed

name
    The name of the package to install

repo
    Specify a non-default repository to install from

skip_verify
    False Skip the GPG verification check for the package to be installed

version
    None Install a specific version of a package

    Usage:

    httpd:
      pkg:
        - installed
        - repo: mycustomrepo
        - skip_verify: True
        - version: 2.0.6~ubuntu3

salt.states.pkg.latest(name, refresh=False, repo='', skip_verify=False, **kwargs)
    Verify that the named package is installed and the latest available package. If the package can be updated this state function will update the package. Generally it is better for the installed function to be used, as latest will update the package whenever a new package is available.

name
    The name of the package to maintain at the latest available version

repo
    (default) Specify a non-default repository to install from

skip_verify
    False Skip the GPG verification check for the package to be installed

salt.states.pkg.purged(name)
    Verify that the package is purged, this will call the purge function in the salt pkg module for the platform.

name
    The name of the package to be purged

salt.states.pkg.removed(name)
    Verify that the package is removed, this will remove the package via the remove function in the salt pkg module for the platform.

name
    The name of the package to be removed

  salt.states.postgres_database

  Management of PostgreSQL databases (schemas).

The postgres_database module is used to create and manage Postgres databases. Databases can be set as either absent or present

frank:
  postgres_database:
    - present

salt.states.postgres_database.absent(name)
    Ensure that the named database is absent

name
    The name of the database to remove

salt.states.postgres_database.present(name)
    Ensure that the named database is present with the specified properties

name
    The name of the database to manage

  salt.states.rvm

  Management of Ruby installations and gemsets with RVM, the Ruby Version Manager.

This module is used to install and manage ruby installations and gemsets with RVM, the Ruby Version Manager. Different versions of ruby can be installed and gemsets created. RVM itself will be installed automatically if it's not present. This module will not automatically install packages that RVM depends on or ones that are needed to build ruby. If you want to run RVM as an unprivileged user (recommended) you will have to create this user yourself. This is how a state configuration could look like:

rvm:
  group:
    - present
  user:
    - present
    - gid: rvm
    - home: /home/rvm
    - require:
      - group: rvm
rvm-deps:
  pkg:
    - installed
    - names:
      - bash
      - coreutils
      - gzip
      - bzip2
      - gawk
      - sed
      - curl
      - git-core
      - subversion
      - sudo
mri-deps:
  pkg:
    - installed
    - names:
      - build-essential
      - openssl
      - libreadline6
      - libreadline6-dev
      - curl
      - git-core
      - zlib1g
      - zlib1g-dev
      - libssl-dev
      - libyaml-dev
      - libsqlite3-0
      - libsqlite3-dev
      - sqlite3
      - libxml2-dev
      - libxslt1-dev
      - autoconf
      - libc6-dev
      - libncurses5-dev
      - automake
      - libtool
      - bison
      - subversion
      - ruby
jruby-deps:
  pkg:
    - installed
    - names:
      - curl
      - g++
      - openjdk-6-jre-headless
ruby-1.9.2:
  rvm:
    - installed
    - default: True
    - runas: rvm
    - require:
      - pkg: rvm-deps
      - pkg: mri-deps
      - user: rvm
jruby:
  rvm:
    - installed
    - runas: rvm
    - require:
      - pkg: rvm-deps
      - pkg: jruby-deps
      - user: rvm
jgemset:
  rvm:
    - gemset_present
    - ruby: jruby
    - runas: rvm
    - require:
      - rvm: jruby
mygemset:
  rvm:
    - gemset_present
    - ruby: ruby-1.9.2
    - runas: rvm
    - require:
      - rvm: ruby-1.9.2

salt.states.rvm.gemset_present(name, ruby='default', runas=None)
    Verify that the gemset is present.

name
    The name of the gemset.

ruby
    default The ruby version this gemset belongs to.

runas
    None The use user to run rvm as.

salt.states.rvm.installed(name, default=False, runas=None)
    Verify that the specified ruby is installed with RVM. RVM is installed when necessary.

name
    The version of ruby to install

default
    False Whether to make this ruby the default.

runas
    None The user to run rvm as.

  salt.states.selinux

  Management of SELinux rules.

If SELinux is available for the running system, the mode can be managed and booleans can be set.

enforcing:
    selinux.mode
samba_create_home_dirs:
    selinx.boolean:
      - value: True
      - persist: True

salt.states.selinux.boolean(name, value, persist=False)
    Set up an SELinux boolean

name
    The name of the boolean to set

value
    The value to set on the boolean

persist
    Defaults to False, set persist to true to make the boolean apply on a reboot

salt.states.selinux.mode(name)
    Verifies the mode SELinux is running in, can be set to enforcing or permissive

name
    The mode to run SELinux in, permissive or enforcing

  salt.states.service

  Starting or restarting of services and daemons.

Services are defined as system daemons typically started with system init or rc scripts, services can be defined as running or dead.

httpd:
  service:
    - running

salt.states.service.dead(name, enable=None, sig=None)
    Ensure that the named service is dead

name
    The name of the init or rc script used to manage the service

enable
    Set the service to be enabled at boot time, True sets the service to be enabled, False sets the named service to be disabled. The default is None, which does not enable or disable anything.

sig The string to search for when looking for the service process with ps

salt.states.service.disabled(name)
    Verify that the service is disabled on boot, only use this state if you don't want to manage the running process, remember that if you want to disable a service to use the enable: False option for the running or dead function.

name
    The name of the init or rc script used to manage the service

salt.states.service.enabled(name)
    Verify that the service is enabled on boot, only use this state if you don't want to manage the running process, remember that if you want to enable a running service to use the enable: True option for the running or dead function.

name
    The name of the init or rc script used to manage the service

salt.states.service.mod_watch(name, sig=None, reload=False)
    The service watcher, called to invoke the watch command.

name
    The name of the init or rc script used to manage the service

sig The string to search for when looking for the service process with ps

salt.states.service.running(name, enable=None, sig=None)
    Verify that the service is running

name
    The name of the init or rc script used to manage the service

enable
    Set the service to be enabled at boot time, True sets the service to be enabled, False sets the named service to be disabled. The default is None, which does not enable or disable anything.

sig The string to search for when looking for the service process with ps

  salt.states.ssh_auth

  Control of entries in SSH authorized_key files.

The information stored in a user's ssh authorized key file can be easily controlled via the ssh_auth state. Defaults can be set by the enc, options, and comment keys. These defaults can be overridden by including them in the name.

AAAAB3NzaC1kc3MAAACBAL0sQ9fJ5bYTEyY==:
  ssh_auth:
    - present
    - user: root
    - enc: ssh-dss
thatch:
  ssh_auth:
    - present
    - user: root
    - source: salt://ssh_keys/thatch.id_rsa.pub
sshkeys:
  ssh_auth:
    - present
    - user: root
    - enc: ssh-rsa
    - options:
      - option1="value1"
      - option2="value2 flag2"
    - comment: myuser
    - names:
      - AAAAB3NzaC1kc3MAAACBAL0sQ9fJ5bYTEyY==
      - ssh-dss AAAAB3NzaCL0sQ9fJ5bYTEyY== user@domain
      - option3="value3" ssh-dss AAAAB3NzaC1kcQ9fJ5bYTEyY== other@testdomain
      - AAAAB3NzaC1kcQ9fJFF435bYTEyY== newcomment

salt.states.ssh_auth.absent(name, user, config='.ssh/authorized_keys')
    Verifies that the specified ssh key is absent

name
    The ssh key to manage

user
    The user who owns the ssh authorized keys file to modify

config
    The location of the authorized keys file relative to the user's home directory, defaults to ".ssh/authorized_keys"

salt.states.ssh_auth.present(name, user, enc='ssh-rsa', comment='', source='', options=[], config='.ssh/authorized_keys', **kwargs)
    Verifies that the specified ssh key is present for the specified user

name
    The ssh key to manage

user
    The user who owns the ssh authorized keys file to modify

enc Defines what type of key is being used, can be ssh-rsa or ssh-dss

comment
    The comment to be placed with the ssh public key

source
    The source file for the key(s). Can contain any number of public keys, in standard "authorized_keys" format. If this is set, comment, enc, and options will be ignored.

options
    The options passed to the key, pass a list object

config
    The location of the authorized keys file relative to the user's home directory, defaults to ".ssh/authorized_keys"

  salt.states.ssh_known_hosts

  Control of SSH known_hosts entries.

Manage the information stored in the known_hosts files

github.com:
  ssh_known_hosts:
    - present
    - user: root
    - fingerprint: 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
example.com:
  ssh_known_hosts:
    - absent
    - user: root

salt.states.ssh_known_hosts.absent(name, user, config='.ssh/known_hosts')
    Verifies that the specified host is not known by the given user

name
    The host name

user
    The user who owns the ssh authorized keys file to modify

config
    The location of the authorized keys file relative to the user's home directory, defaults to ".ssh/known_hosts"

salt.states.ssh_known_hosts.present(name, user, fingerprint=None, port=None, enc=None, config='.ssh/known_hosts')
    Verifies that the specified host is known by the specified user

name
    The name of the remote host (i.e. "github.com")

user
    The user who owns the ssh authorized keys file to modify

enc Defines what type of key is being used, can be ssh-rsa or ssh-dss

fingerprint
    The fingerprint of the key which must be presented in the known_hosts file

port
    optional parameter, denoting the port of the remote host, which will be used in case, if the public key will be requested from it. By default the port 22 is used.

config
    The location of the authorized keys file relative to the user's home directory, defaults to ".ssh/known_hosts"

  salt.states.sysctl

  Configuration of the Linux kernel using sysctrl.

Control the kernel sysctl system

vm.swappines:
  sysctl:
    - present
    - value: 20

salt.states.sysctl.present(name, value, config='/etc/sysctl.conf')
    Ensure that the named sysctl value is set

name
    The name of the sysctl value to edit

value
    The sysctl value to apply

config
    The location of the sysctl configuration file

  salt.states.user

  Management of user accounts.

The user module is used to create and manage user settings, users can be set as either absent or present

fred:
  user:
    - present
    - fullname: Fred Jones
    - shell: /bin/zsh
    - home: /home/fred
    - uid: 4000
    - gid: 4000
    - groups:
      - wheel
      - storage
      - games

salt.states.user.absent(name, purge=False, force=False)
    Ensure that the named user is absent

name
    The name of the user to remove

purge
    Set purge to delete all of the user's file as well as the user

force
    If the user is logged in the absent state will fail, set the force option to True to remove the user even if they are logged in

salt.states.user.present(name, uid=None, gid=None, groups=None, home=True, password=None, enforce_password=True, shell=None, fullname=None, roomnumber=None, workphone=None, homephone=None, other=None, unique=True, system=False)
    Ensure that the named user is present with the specified properties

name
    The name of the user to manage

uid The user id to assign, if left empty then the next available user id will be assigned

gid The default group id

groups
    A list of groups to assign the user to, pass a list object

home
    The location of the home directory to manage

password
    A password hash to set for the user

enforce_password
    Set to False to keep the password from being changed if it has already been set and the password hash differs from what is specified in the "password" field. This option will be ignored if "password" is not specified.

shell
    The login shell, defaults to the system default shell

    User comment field (GECOS) support (currently Linux-only):

    The below values should be specified as strings to avoid ambiguities when the values are loaded. (Especially the phone and room number fields which are likely to contain numeric data)

fullname
    The user's full name.

roomnumber
    The user's room number

workphone
    The user's work phone number

homephone
    The user's home phone number

other
    The user's "other" GECOS field

unique
    Require a unique UID, True by default

system
    Choose UID in the range of FIRST_SYSTEM_UID and LAST_SYSTEM_UID.

  salt.states.virtualenv

  Setup of Python virtualenv sandboxes.

salt.states.virtualenv.managed(name, venv_bin='virtualenv', requirements='', no_site_packages=False, system_site_packages=False, distribute=False, clear=False, python='', extra_search_dir='', never_download=False, prompt='', __env__='base', runas=None, cwd=None)
    Create a virtualenv and optionally manage it with pip

name
    Path to the virtualenv

requirements
    Path to a pip requirements file. If the path begins with salt:// the file will be transfered from the master file server.

cwd Path to the working directory where "pip install" is executed.

    Also accepts any kwargs that the virtualenv module will.

RENDERERS

The Salt state system operates by gathering information from simple data structures. The state system was designed in this way to make interacting with it generic and simple. This also means that state files (SLS files) can be one of many formats.

By default SLS files are rendered as Jinja templates and then parsed as YAML documents. But since the only thing the state system cares about is raw data, the SLS files can be any structured format that can be dreamed up.

Currently there is support for Jinja + YAML, Mako + YAML, Jinja + json and Mako + json. But renderers can be written to support anything. This means that the Salt states could be managed by xml files, html files, puppet files, or any format that can be translated into the data structure used by the state system.

  Multiple Renderers

When deploying a state tree a default renderer is selected in the master configuration file with the renderer option. But multiple renderers can be used inside the same state tree.

When rendering SLS files Salt checks for the presence of a Salt specific shebang line. The shebang line syntax was chosen because it is familiar to the target audience, the systems admin and systems engineer.

The shebang line directly calls the name of the renderer as it is specified within Salt. One of the most common reasons to use multiple renderers in to use the Python or py renderer:

#!py
def run():
    '''
    Install the python-mako package
    '''
    return {'include': ['python'],
            'python-mako': {'pkg': ['installed']}}

The first line is a shebang that references the py renderer.

  Writing Renderers

Writing a renderer is easy, all that is required is that a Python module is placed in the rendered directory and that the module implements the render function. The render function will be passed the path of the SLS file. In the render function, parse the passed file and return the data structure derived from the file.

  Examples

The best place to find examples of renderers is in the Salt source code. The renderers included with Salt can be found here:

https://github.com/saltstack/salt/blob/v0.10.0/salt/renderers

Here is a simple Jinja + YAML example:

# Import Python libs
import os
# Import Third Party libs
import yaml
from jinja2 import Template
def render(template):
    '''
    Render the data passing the functions and grains into the rendering system
    '''
    if not os.path.isfile(template):
        return {}
    passthrough = {}
    passthrough.update(__salt__)
    passthrough.update(__grains__)
    template = Template(open(template, 'r').read())
    yaml_data = template.render(**passthrough)
    return yaml.load(yaml_data)

FULL LIST OF BUILTIN RENDERERS
json_jinja | Process json with the jinja2 templating engine
json_mako | Process json with the Mako templating engine
yaml_jinja | The default rendering engine, process yaml with the jinja2 templating engine
yaml_mako | Process yaml with the Mako templating engine
py | Pure python state renderer

  salt.renderers.json_jinja

Process json with the jinja2 templating engine

This renderer will take a json file with the jinja template and render it to a high data format for salt states.

salt.renderers.json_jinja.render(template_file, env='', sls='')
    Render the data passing the functions and grains into the rendering system

  salt.renderers.json_mako

Process json with the Mako templating engine

This renderer will take a json file with the Mako template and render it to a high data format for salt states.

salt.renderers.json_mako.render(template_file, env='', sls='')
    Render the data passing the functions and grains into the rendering system

  salt.renderers.yaml_jinja

The default rendering engine, process yaml with the jinja2 templating engine

This renderer will take a yaml file with the jinja2 template and render it to a high data format for salt states.

salt.renderers.yaml_jinja.render(template_file, env='', sls='')
    Render the data passing the functions and grains into the rendering system

  salt.renderers.yaml_mako

Process yaml with the Mako templating engine

This renderer will take a yaml file within a mako template and render it to a high data format for salt states.

salt.renderers.yaml_mako.render(template_file, env='', sls='')
    Render the data passing the functions and grains into the rendering system

  salt.renderers.py

Pure python state renderer

The sls file should contain a function called sls which returns high state data

salt.renderers.py.render(template, env='', sls='')
    Render the python module's components

SALT RUNNERS

Salt runners are convenience applications executed with the salt-run command.

A Salt runner can be a simple client call, or a complex application.

The use for a Salt runner is to build a frontend hook for running sets of commands via Salt or creating special formatted output.

  Writing Salt Runners

Salt runners can be easily written, the work in a similar way to Salt modules except they run on the server side.

A runner is a Python module that contains functions, each public function is a runner that can be executed via the salt-run command.

If a Python module named test.py is created in the runners directory and contains a function called foo then the function could be called with:

# salt '*' test.foo

  Examples

The best examples of runners can be found in the Salt source:

https://github.com/saltstack/salt/blob/v0.10.0/salt/runners

A simple runner that returns a well-formatted list of the minions that are responding to Salt calls would look like this:

# Import salt modules
import salt.client
def up():
    '''
    Print a list of all of the minions that are up
    '''
    client = salt.client.LocalClient(__opts__['config'])
    minions = client.cmd('*', 'test.ping', timeout=1)
    for minion in sorted(minions):
        print minion

PEER COMMUNICATION

Salt 0.9.0 introduced the capability for Salt minions to publish commands. The intent of this feature is not for Salt minions to act as independent brokers one with another, but to allow Salt minions to pass commands to each other.

In Salt 1.0 the ability to execute runners from the master was added. This allows for the master to return collective data from runners back to the minions via the peer interface.

The peer interface is configured through two options in the master configuration file. For minions to send commands from the master the peer configuration is used. To allow for minions to execute runners from the master the peer_run configuration is used.

Since this presents a viable security risk by allowing minions access to the master publisher the capability is turned off by default. The minions can be allowed access to the master publisher on a per minion basis based on regular expressions. Minions with specific ids can be allowed access to certain Salt modules and functions.

  Peer Configuration

The configuration is done under the peer setting in the Salt master configuration file, here are a number of configuration possibilities.

The simplest approach is to enable all communication for all minions, this is only recommended for very secure environments.

peer:
  .*:
    - .*

This configuration will allow minions with IDs ending in example.com access to the test, ps, and pkg module functions.

peer:
  .*example.com:
    - test.*
    - ps.*
    - pkg.*

The configuration logic is simple, a regular expression is passed for matching minion ids, and then a list of expressions matching minion functions is associated with the named minion. For instance, this configuration will also allow minions ending with foo.org access to the publisher.

peer:
  .*example.com:
    - test.*
    - ps.*
    - pkg.*
  .*foo.org:
    - test.*
    - ps.*
    - pkg.*

  Peer Runner Communication

Configuration to allow minions to execute runners from the master is done via the peer_run option on the master. The peer_run configuration follows the same logic as the peer option. The only difference is that access is granted to runner modules.

To open up access to all minions to all runners:

peer_run:
  .*:
    - .*

This configuration will allow minions with IDs ending in example.com access to the manage and jobs runner functions.

peer_run:
  .*example.com:
    - manage.*
    - jobs.*

  Using Peer Communiction

The publish module was created to manage peer communication. The publish module comes with a number of functions to execute peer communication in different ways. Currently there are three functions in the publish module. These examples will show how to test the peer system via the salt-call command.

To execute test.ping on all minions:

# salt-call publish.publish \* test.ping

To execute the manage.up runner:

# salt-call publish.runner manage.up

SALT SYNDIC

The Salt Syndic interface is a powerful tool which allows for the construction of Salt command topologies. A basic Salt setup has a Salt Master commanding a group of Salt Minions. The Syndic interface is a special passthrough minion, it is run on a master and connects to another master, then the master that the Syndic minion is listening to can control the minions attached to the master running the syndic.

The intent for supporting many layouts is not presented with the intent of supposing the use of any single topology, but to allow a more flexible method of controlling many systems.

  Configuring the Syndic

Since the Syndic only needs to be attached to a higher level master the configuration is very simple. On a master that is running a syndic to connect to a higher level master the syndic_master option needs to be set in the master config file. The syndic_master option contains the hostname or ip address of the master server that can control the master that the syndic is running on.

The master that the syndic connects to sees the syndic as an ordinary minion, and treats it as such. the higher level master will need to accept the syndic's minion key like any other minion. This master will also need to set the order_masters value in the configuration to True. The order_masters option in the config on the higher level master is very important, to control a syndic extra information needs to be sent with the publications, the order_masters option makes sure that the extra data is sent out.

  Running the Syndic

The Syndic is a separate daemon that needs to be started on the master that is controlled by a higher master. Starting the Syndic daemon is the same as starting the other Salt daemons.

# salt-syndic

PYTHON CLIENT API

Salt is written to be completely API centric, Salt minions and master can be built directly into third party applications as a communication layer. The Salt client API is very straightforward.

A number of client command methods are available depending on the exact behaviour desired.

  Using the LocalClient API

Sending information through the client is simple:

# Import the Salt client library
import salt.client
# create a local client object
client = salt.client.LocalClient()
# make calls with the cmd method
ret = client.cmd('*', 'cmd.run', ['ls -l'])

The LocalClient object only works running as root on the salt-master, it is the same interface used by the salt command line tool.

LocalClient.cmd(tgt, fun, arg=[], timeout=5, expr_form='glob', ret='')
    The cmd method will execute and wait for the timeout period for all minions to reply, then it will return all minion data at once.

tgt The tgt option is the target specification, by default a target is passed in as a bash shell glob. The expr_form option allows the tgt to be passed as either a pcre regular expression or as a Python list.

fun The name of the function to call on the specified minions. The documentation for these functions can be seen by running on the salt-master: salt '*' sys.doc

arg The optional arg parameter is used to pass a list of options on to the remote function

timeout
    The number of seconds to wait after the last minion returns but before all minions return.

expr_form
    The type of tgt that is passed in, the allowed values are:

•   'glob' - Bash glob completion - Default

•   'pcre' - Perl style regular expression

•   'list' - Python list of hosts

•   'grain' - Match based on a grain comparison

•   'grain_pcre' - Grain comparison with a regex

•   'pillar' - Pillar data comparison

•   'nodegroup' - Match on nodegroup

•   'range' - Use a Range server for matching

•   'compound' - Pass a compound match string

ret Specify the returner to use. The value passed can be single returner, or a comma delimited list of returners to call in order on the minions

LocalClient.cmd_cli(tgt, fun, arg=[], timeout=5, verbose=False, expr_form='glob', ret='')
    The cmd_cli method is used by the salt command, it is a generator. This method returns minion returns as the come back and attempts to block until all minions return.

tgt The tgt option is the target specification, by default a target is passed in as a bash shell glob. The expr_form option allows the tgt to be passed as either a pcre regular expression or as a Python list.

fun The name of the function to call on the specified minions. The documentation for these functions can be seen by running on the salt-master: salt '*' sys.doc

arg The optional arg parameter is used to pass a list of options on to the remote function

timeout
    The number of seconds to wait after the last minion returns but before all minions return.

expr_form
    The type of tgt that is passed in, the allowed values are:

•   'glob' - Bash glob completion - Default

•   'pcre' - Perl style regular expression

•   'list' - Python list of hosts

•   'grain' - Match based on a grain comparison

•   'grain_pcre' - Grain comparison with a regex

•   'pillar' - Pillar data comparison

•   'nodegroup' - Match on nodegroup

•   'range' - Use a Range server for matching

•   'compound' - Pass a compound match string

ret Specify the returner to use. The value passed can be single returner, or a comma delimited list of returners to call in order on the minions

verbose
    Print extra information about the running command to the terminal

LocalClient.cmd_iter(tgt, fun, arg=[], timeout=5, expr_form='glob', ret='')
    The cmd_iter method is a generator which yields the individual minion returns as the come in.

tgt The tgt option is the target specification, by default a target is passed in as a bash shell glob. The expr_form option allows the tgt to be passed as either a pcre regular expression or as a Python list.

fun The name of the function to call on the specified minions. The documentation for these functions can be seen by running on the salt-master: salt '*' sys.doc

arg The optional arg parameter is used to pass a list of options on to the remote function

timeout
    The number of seconds to wait after the last minion returns but before all minions return.

expr_form
    The type of tgt that is passed in, the allowed values are:

•   'glob' - Bash glob completion - Default

•   'pcre' - Perl style regular expression

•   'list' - Python list of hosts

•   'grain' - Match based on a grain comparison

•   'grain_pcre' - Grain comparison with a regex

•   'pillar' - Pillar data comparison

•   'nodegroup' - Match on nodegroup

•   'range' - Use a Range server for matching

•   'compound' - Pass a compound match string

ret Specify the returner to use. The value passed can be single returner, or a comma delimited list of returners to call in order on the minions

LocalClient.cmd_iter_no_block(tgt, fun, arg=[], timeout=5, expr_form='glob', ret='')
    The cmd_iter method will block waiting for individual minions to return, the cmd_iter_no_block method will return None until the next minion returns. This allows for actions to be injected in between minion returns

tgt The tgt option is the target specification, by default a target is passed in as a bash shell glob. The expr_form option allows the tgt to be passed as either a pcre regular expression or as a Python list.

fun The name of the function to call on the specified minions. The documentation for these functions can be seen by running on the salt-master: salt '*' sys.doc

arg The optional arg parameter is used to pass a list of options on to the remote function

timeout
    The number of seconds to wait after the last minion returns but before all minions return.

expr_form
    The type of tgt that is passed in, the allowed values are:

•   'glob' - Bash glob completion - Default

•   'pcre' - Perl style regular expression

•   'list' - Python list of hosts

•   'grain' - Match based on a grain comparison

•   'grain_pcre' - Grain comparison with a regex

•   'pillar' - Pillar data comparison

•   'nodegroup' - Match on nodegroup

•   'range' - Use a Range server for matching

•   'compound' - Pass a compound match string

ret Specify the returner to use. The value passed can be single returner, or a comma delimited list of returners to call in order on the minions

  Compound Command Execution With the Salt API

The Salt client API can also send what is called a compound command. Often a collection of commands need to be executed on the targeted minions, rather than send the commands one after another, they can be sent in a single publish containing a series of commands. This can dramatically lower overhead and speed up the application communicating with Salt.

When commands are executed with compound execution the minion functions called are executed in serial on the minion and the return value is sent back in a different fashion. The return value is a dict, with the function names as keys to the function returns as values.

Using the compound command execution system via the API requires that the fun value and the arg value are lists matching by index. This ensures that the order of the executions can be controlled. Any function that has no arguments MUST have an empty array in the corresponding arg index.

All client command methods can execute compound commands.

# Import the Salt client library
import salt.client
# create a local client object
client = salt.client.LocalClient()
# make compound execution calls with the cmd method
ret = client.cmd('*', ['cmd.run', 'test.ping', 'test.echo'], [['ls -l'], [], ['foo']])

This will execute cmd.run ls -l then test.ping and finally test.echo foo. The return data from the minion will look like this:

{'cmd.run': '<output from ls -l>',
 'test.ping': True,
 'test.echo': 'foo'}

SALT FILE SERVER

Salt comes with a simple file server suitable for distributing files to the Salt minions. The file server is a stateless ZeroMQ server that is built into the Salt master.

The main intent of the Salt file server is to present files for use in the Salt state system. With this said, the Salt file server can be used for any general file transfer from the master to the minions.

  The cp Module

The cp module is the home of minion side file server operations. The cp module is used by the Salt state system, salt-cp and can be used to distribute files presented by the Salt file server.

  Environments

Since the file server is made to work with the Salt state system, it supports environments. The environments are defined in the master config file and when referencing an environment the file specified will be based on the root directory of the environment.

  get_file

The cp.get_file function can be used on the minion to download a file from the master, the syntax looks like this:

# salt '*' cp.get_file salt://vimrc /etc/vimrc

This will instruct all Salt minions to download the vimrc file and copy it to /etc/vimrc

  File Server Client API

A client API is available which allows for modules and applications to be written which make use of the Salt file server.

The file server uses the same authentication and encryption used by the rest of the Salt system for network communication.

  FileClient Class

The FileClient class is used to set up the communication from the minion to the master. When creating a FileClient object the minion configuration needs to be passed in. When using the FileClient from within a minion module the built in __opts__ data can be passed:

import salt.minion
def get_file(path, dest, env='base'):
    '''
    Used to get a single file from the Salt master
    CLI Example:
    salt '*' cp.get_file salt://vimrc /etc/vimrc
    '''
    # Create the FileClient object
    client = salt.minion.FileClient(__opts__)
    # Call get_file
    return client.get_file(path, dest, False, env)

Using the FileClient class outside of a minion module where the __opts__ data is not available, it needs to be generated:

import salt.minion
import salt.config
def get_file(path, dest, env='base'):
    '''
    Used to get a single file from the Salt master
    '''
    # Get the configuration data
    opts = salt.config.minion_config('/etc/salt/minion')
    # Create the FileClient object
    client = salt.minion.FileClient(opts)
    # Call get_file
    return client.get_file(path, dest, False, env)

FILE SERVER CONFIGURATION

The Salt file server is a high performance file server written in ZeroMQ. It manages large files quickly and with little overhead, and has been optimized to handle small files in an extremely efficient manner.

The Salt file server is an environment aware file server. This means that files can be allocated within many root directories and accessed by specifying both the file path and the environment to search. The individual environments can span across multiple directory roots to crate overlays and to allow for files to be organized in many flexible ways.

  Environments

The Salt file server defaults to the mandatory base environment. This environment MUST be defined and is used to download files when no environment is specified.

Environments allow for files and sls data to be logically separated, but environments are not isolated from each other. This allows for logical isolation of environments by the engineer using Salt, but also allows for information to be used in multiple environments.

  Directory Overlay

The environment setting is a list of directories to publish files from. These directories are searched in order to find the specified file and the first file found is returned.

This means that directory data is prioritized based on the order in which they are listed. In the case of this file_roots configuration:

file_roots:
  base:
    - /srv/salt/base
    - /srv/salt/failover

If a file's URI is salt://httpd/httpd.conf, it will first search for the file at /srv/salt/base/httpd/httpd.conf. If the file is found there it will be returned. If the file is not found there, then /srv/salt/failover/httpd/httpd.conf will be used for the source.

This allows for directories to be overlaid and prioritized based on the order they are defined in the configuration.

  Local File Server

New in version 0.9.8.

The file server can be rerouted to run from the minion. This is primarily to enable running Salt states without a Salt master. To use the local file server interface, copy the file server data to the minion and set the file_roots option on the minion to point to the directories copied from the master. Once the minion file_roots option has been set, change the file_client option to local to make sure that the local file server interface is used.

DYNAMIC MODULE DISTRIBUTION

New in version 0.9.5.

Salt Python modules can be distributed automatically via the Salt file server. Under the root of any environment defined via the file_roots option on the master server directories corresponding to the type of module can be used.

The directories are prepended with an underscore:

1.  _modules

2.  _grains

3.  _renderers

4.  _returners

5.  _states

    The contents of these directories need to be synced over to the minions after Python modules have been created in them. There are a number of ways to sync the modules.

  Sync Via States

The minion configuration contains an option autoload_dynamic_modules which defaults to True. This option makes the state system refresh all dynamic modules when states are run. To disable this behavior set autoload_dynamic_modules to False in the minion config.

When dynamic modules are autoloaded via states, modules only pertinent to the environments matched in the master's top file are downloaded.

This is important to remember, because modules can be manually loaded from any specific environment that environment specific modules will be loaded when a state run is executed.

  Sync Via the saltutil Module

The saltutil module has a number of functions that can be used to sync all or specific dynamic modules. The saltutil module function saltutil.sync_all will sync all module types over to a minion. For more information see: salt.modules.saltutil

CONFIGURATION FILE EXAMPLES

•   Example master configuration file

•   Example minion configuration file

  Example master configuration file

# DO NOT MODIFY THIS FILE.  Copy it to: /etc/salt/master
##### Primary configuration settings #####
##########################################
# The address of the interface to bind to
#interface: 0.0.0.0
# The port used by the publisher
#publish_port: 4505
# The user to run salt
#user: root
# The number of worker threads to start, these threads are used to manage
# return calls made from minions to the master, if the master seems to be
# running slowly, increase the number of threads
#worker_threads: 5
# The port used by the communication interface
#ret_port: 4506
# The root directory prepended to these options: pki_dir, cachedir,
# sock_dir, log_file.
#root_dir: /
# Directory used to store public key data
#pki_dir: /etc/salt/pki
# Directory to store job and cache data
#cachedir: /var/cache/salt
# Set the number of hours to keep old job information
#keep_jobs: 24
# Set the default timeout for the salt command and api, the default is 5
# seconds
#timeout: 5
# Set the directory used to hold unix sockets
#sock_dir: /tmp/salt-unix
# The master maintains a job cache, while this is a great addition it can be
# a burden on the master for larger deployments (over 5000 minions).
# Disabling the job cache will make previously executed jobs unavailable to
# the jobs system and is not generally recommended.
#
#job_cache: True
# Set the acceptance level for serialization of messages. This should only be
# set if the master is newer than 0.9.5 and the minion are older. This option
# allows a 0.9.5 and newer master to communicate with minions 0.9.4 and
# earlier. It is not recommended to keep this setting on if the minions are
# all 0.9.5 or higher, as leaving pickle as the serialization medium is slow
# and opens up security risks
#
#serial: msgpack
#####        Security settings       #####
##########################################
# Enable "open mode", this mode still maintains encryption, but turns off
# authentication, this is only intended for highly secure environments or for
# the situation where your keys end up in a bad state. If you run in open mode
# you do so at your own risk!
#open_mode: False
# Enable auto_accept, this setting will automatically accept all incoming
# public keys from the minions. Note that this is insecure.
#auto_accept: False
#####    Master Module Management    #####
##########################################
# Manage how master side modules are loaded
#
# Add any additional locations to look for master runners
#runner_dirs: []
#
#Enable Cython for master side modules
#cython_enable: False
#####      State System settings     #####
##########################################
# The state system uses a "top" file to tell the minions what environment to
# use and what modules to use. The state_top file is defined relative to the
# root of the base environment as defined in "File Server settings" below.
#state_top: top.sls
#
# The external_nodes option allows Salt to gather data that would normally be
# placed in a top file. The external_nodes option is the executable that will
# return the ENC data. Remember that Salt will look for external nodes AND top
# files and combine the results if both are enabled!
#external_nodes: None
#
# The renderer to use on the minions to render the state data
#renderer: yaml_jinja
#
# The failhard option tells the minions to stop immediately after the first
# failure detected in the state execution, defaults to False
#failhard: False
#####      File Server settings      #####
##########################################
# Salt runs a lightweight file server written in zeromq to deliver files to
# minions. This file server is built into the master daemon and does not
# require a dedicated port.
# The file server works on environments passed to the master, each environment
# can have multiple root directories, the subdirectories in the multiple file
# roots cannot match, otherwise the downloaded files will not be able to be
# reliably ensured. A base environment is required to house the top file.
# Example:
# file_roots:
#   base:
#     - /srv/salt/
#   dev:
#     - /srv/salt/dev/services
#     - /srv/salt/dev/states
#   prod:
#     - /srv/salt/prod/services
#     - /srv/salt/prod/states
#
# Default:
#file_roots:
#  base:
#    - /srv/salt
# The hash_type is the hash to use when discovering the hash of a file on
# the master server, the default is md5, but sha1, sha224, sha256, sha384
# and sha512 are also supported.
#hash_type: md5
# The buffer size in the file server can be adjusted here:
#file_buffer_size: 1048576
# Pillar Configurations:
# The Salt Pillar, is a system that allows for the building of global data
# that is refined based on minion. Basically, the pillar creates data that
# can be generated to be specific based on the grains of the minion. Pillar
# is laid out in the same fashion as the file server, with environments, a top
# file and sls files. The difference is that the data does not need to be
# in the highstate format, and is generally just key/value pairs.
#
#pillar_roots:
#  base:
#    - /srv/pillar
#
#ext_pillar:
#  - hiera: /etc/hiera.yaml
#  - cmd: cat /etc/salt/yaml
#
#####          Syndic settings       #####
##########################################
# The Salt syndic is used to pass commands through a master from a higher
# master. Using the syndic is simple, if this is a master that will have
# syndic servers(s) below it set the "order_masters" setting to True, if this
# is a master that will be running a syndic daemon for passthrough the
# "syndic_master" setting needs to be set to the location of the master server
# to receive commands from.
#
# Set the order_masters setting to True if this master will command lower
# masters' syndic interfaces.
#order_masters: False
#
# If this master will be running a salt syndic daemon, syndic_master tells
# this master where to receive commands from.
#syndic_master: masterofmaster
#####      Peer Publish settings     #####
##########################################
# Salt minions can send commands to other minions, but only if the minion is
# allowed to. By default "Peer Publication" is disabled, and when enabled it
# is enabled for specific minions and specific commands. This allows secure
# compartmentalization of commands based on individual minions.
#
# The configuration uses regular expressions to match minions and then a list
# of regular expressions to match functions. The following will allow the
# minion authenticated as foo.example.com to execute functions from the test
# and pkg modules.
# peer:
#   foo.example.com:
#       - test.*
#       - pkg.*
#
# This will allow all minions to execute all commands:
# peer:
#   .*:
#       - .*
# This is not recommended, since it would allow anyone who gets root on any
# single minion to instantly have root on all of the minions!
#
# Minions can also be allowed to execute runners from the salt master.
# Since executing a runner from the minion could be considered a security risk,
# it needs to be enabled. This setting functions just like the peer setting
# except that it opens up runners instead of module functions.
#
# All peer runner support is turned off by default and must be enabled before
# using. This will enable all peer runners for all minions:
#
# peer_run:
#   .*:
#     - .*
#
# To enable just the manage.up runner for the minion foo.example.com:
#
# peer_run:
#   foo.example.com:
#     - manage.up
#
#####         Cluster settings       #####
##########################################
# Salt supports automatic clustering, salt creates a single ip address which
# is shared among the individual salt components using ucarp. The private key
# and all of the minion keys are maintained across the defined cluster masters.
# The failover service is automatically managed via these settings
# List the identifiers for the other cluster masters in this manner:
# [saltmaster-01.foo.com,saltmaster-02.foo.com,saltmaster-03.foo.com]
# The members of this master array must be running as salt minions to
# facilitate the distribution of cluster information
#cluster_masters: []
# The cluster modes are "paranoid" and "full"
# paranoid will only distribute the accepted minion public keys.
# full will also distribute the master private key.
#cluster_mode: paranoid
#####         Logging settings       #####
##########################################
# The location of the master log file
#log_file: /var/log/salt/master
#
# The level of messages to send to the log file.
# One of 'info', 'quiet', 'critical', 'error', 'debug', 'warning'.
# Default: 'warning'
#log_level: warning
#
# Logger levels can be used to tweak specific loggers logging levels.
# For example, if you want to have the salt library at the 'warning' level,
# but you still wish to have 'salt.modules' at the 'debug' level:
#   log_granular_levels:
#     'salt': 'warning',
#     'salt.modules': 'debug'
#
#log_granular_levels: {}
#####         Node Groups           #####
##########################################
# Node groups allow for logical groupings of minion nodes.
# A group consists of a group name and a compound target.
#
# nodegroups:
#   group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com'
#   group2: 'G@os:Debian and foo.domain.com'
#####     Range Cluster settings     #####
##########################################
# The range server (and optional port) that
# serves your cluster information
#range_server: range:80

  Example minion configuration file

# DO NOT MODIFY THIS FILE.  Copy it to: /etc/salt/minion
##### Primary configuration settings #####
##########################################
# Set the location of the salt master server, if the master server cannot be
# resolved, then the minion will fail to start.
#master: salt
# Set the port used by the master reply and authentication server
#master_port: 4506
# The user to run salt
#user: root
# The root directory prepended to these options: pki_dir, cachedir, log_file.
#root_dir: /
# The directory to store the pki information in
#pki_dir: /etc/salt/pki
# Explicitly declare the id for this minion to use, if left commented the id
# will be the hostname as returned by the python call: socket.getfqdn()
# Since salt uses detached ids it is possible to run multiple minions on the
# same machine but with different ids, this can be useful for salt compute
# clusters.
#id:
# Append a domain to a hostname in the event that it does not exist.  This is
# useful for systems where socket.getfqdn() does not actually result in a
# FQDN (for instance, Solaris).
#append_domain:
# If the connection to the server is interrupted, the minion will
# attempt to reconnect. sub_timeout allows you to control the rate
# of reconnection attempts (in seconds). To disable reconnects, set
# this value to 0.
#sub_timeout: 60
# Where cache data goes
#cachedir: /var/cache/salt
# The minion can locally cache the return data from jobs sent to it, this
# can be a good way to keep track of jobs the minion has executed
# (on the minion side). By default this feature is disabled, to enable
# set cache_jobs to True
#cache_jobs: False
# When waiting for a master to accept the minion's public key, salt will
# continuously attempt to reconnect until successful. This is the time, in
# seconds, between those reconnection attempts.
#acceptance_wait_time = 10
# When healing a dns_check is run, this is to make sure that the originally
# resolved dns has not changed, if this is something that does not happen in
# your environment then set this value to False.
#dns_check: True
#####   Minion module management     #####
##########################################
# Disable specific modules. This allows the admin to limit the level of
# access the master has to the minion
#disable_modules: [cmd,test]
#disable_returners: []
#
# Modules can be loaded from arbitrary paths. This enables the easy deployment
# of third party modules. Modules for returners and minions can be loaded.
# Specify a list of extra directories to search for minion modules and
# returners. These paths must be fully qualified!
#module_dirs: []
#returner_dirs: []
#states_dirs: []
#render_dirs: []
#
# A module provider can be statically overwritten or extended for the minion
# via the providers option, in this case the default module will be
# overwritten by the specified module. In this example the pkg module will
# be provided by the yumpkg5 module instead of the system default.
#
# providers:
#   pkg: yumpkg5
#
# Enable Cython modules searching and loading. (Default: False)
#cython_enable: False
#####    State Management Settings    #####
###########################################
# The state management system executes all of the state templates on the minion
# to enable more granular control of system state management. The type of
# template and serialization used for state management needs to be configured
# on the minion, the default renderer is yaml_jinja. This is a yaml file
# rendered from a jinja template, the available options are:
# yaml_jinja
# yaml_mako
# json_jinja
# json_mako
#
#renderer: yaml_jinja
#
# state_verbose allows for the data returned from the minion to be more
# verbose. Normally only states that fail or states that have changes are
# returned, but setting state_verbose to True will return all states that
# were checked
#state_verbose: False
#
# autoload_dynamic_modules Turns on automatic loading of modules found in the
# environments on the master. This is turned on by default, to turn of
# autoloading modules when states run set this value to False
#autoload_dynamic_modules: True
#
# clean_dynamic_modules keeps the dynamic modules on the minion in sync with
# the dynamic modules on the master, this means that if a dynamic module is
# not on the master it will be deleted from the minion. By default this is
# enabled and can be disabled by changing this value to False
#clean_dynamic_modules: True
#
# Normally the minion is not isolated to any single environment on the master
# when running states, but the environment can be isolated on the minion side
# by statically setting it. Remember that the recommended way to manage
# environments is to isolate via the top file.
#environment: None
#
# If using the local file directory, then the state top file name needs to be
# defined, by default this is top.sls.
#state_top: top.sls
#####     File Directory Settings    #####
##########################################
# The Salt Minion can redirect all file server operations to a local directory,
# this allows for the same state tree that is on the master to be used if
# copied completely onto the minion. This is a literal copy of the settings on
# the master but used to reference a local directory on the minion.
# Set the file client, the client defaults to looking on the master server for
# files, but can be directed to look at the local file directory setting
# defined below by setting it to local.
#file_client: remote
# The file directory works on environments passed to the minion, each environment
# can have multiple root directories, the subdirectories in the multiple file
# roots cannot match, otherwise the downloaded files will not be able to be
# reliably ensured. A base environment is required to house the top file.
# Example:
# file_roots:
#   base:
#     - /srv/salt/
#   dev:
#     - /srv/salt/dev/services
#     - /srv/salt/dev/states
#   prod:
#     - /srv/salt/prod/services
#     - /srv/salt/prod/states
#
# Default:
#file_roots:
#  base:
#    - /srv/salt
# The hash_type is the hash to use when discovering the hash of a file in
# the minion directory, the default is md5, but sha1, sha224, sha256, sha384
# and sha512 are also supported.
#hash_type: md5
# The Salt pillar is searched for locally if file_client is set to local. If
# this is the case, and pillar data is defined, then the pillar_roots need to
# also be configured on the minion:
#pillar_roots:
#  base:
#    - /srv/pillar
######        Security settings       #####
###########################################
# Enable "open mode", this mode still maintains encryption, but turns off
# authentication, this is only intended for highly secure environments or for
# the situation where your keys end up in a bad state. If you run in open mode
# you do so at your own risk!
#open_mode: False
######         Thread settings        #####
###########################################
# Disable multiprocessing support, by default when a minion receives a
# publication a new process is spawned and the command is executed therein.
#multiprocessing: True
######         Logging settings       #####
###########################################
# The location of the minion log file
#log_file: /var/log/salt/minion
#
# The level of messages to send to the log file.
# One of 'info', 'quiet', 'critical', 'error', 'debug', 'warning'.
# Default: 'warning'
#log_level: warning
#
# Logger levels can be used to tweak specific loggers logging levels.
# For example, if you want to have the salt library at the 'warning' level,
# but you still wish to have 'salt.modules' at the 'debug' level:
#   log_granular_levels: {
#     'salt': 'warning',
#     'salt.modules': 'debug'
#   }
#
#log_granular_levels: {}
######      Module configuration      #####
###########################################
# Salt allows for modules to be passed arbitrary configuration data, any data
# passed here in valid yaml format will be passed on to the salt minion modules
# for use. It is STRONGLY recommended that a naming convention be used in which
# the module name is followed by a . and then the value. Also, all top level
# data must be applied via the yaml dict construct, some examples:
#
# A simple value for the test module:
#test.foo: foo
#
# A list for the test module:
#test.bar: [baz,quo]
#
# A dict for the test module:
#test.baz: {spam: sausage, cheese: bread}

CONFIGURING THE SALT MASTER

The Salt system is amazingly simple and easy to configure, the two components of the Salt system each have a respective configuration file. The salt-master is configured via the master configuration file, and the salt-minion is configured via the minion configuration file.

See also

    example master configuration file

The configuration file for the salt-master is located at /etc/salt/master. The available options are as follows:

  Primary Master Configuration

  interface

Default: 0.0.0.0 (all interfaces)

The local interface to bind to.

interface: 192.168.0.1

  publish_port

Default: 4505

The network port to set up the publication interface

publish_port: 4505

  user

Default: root

The user to run the Salt processes

user: root

  worker_threads

Default: 5

The number of threads to start for receiving commands and replies from minions. If minions are stalling on replies because you have many minions, raise the worker_threads value.

worker_threads: 5

  ret_port

Default: 4506

The port used by the return server, this is the server used by Salt to receive execution returns and command executions.

ret_port: 4506

  root_dir

Default: /

The system root directory to operate from, change this to make Salt run from an alternative root

root_dir: /

  pki_dir

Default: /etc/salt/pki

The directory to store the pki authentication keys.

pki_dir: /etc/salt/pki

  cachedir

Default: /var/cache/salt

The location used to store cache information, particularly the job information for executed salt commands.

cachedir: /var/cache/salt

  keep_jobs

Default: 24

Set the number of hours to keep old job information

  job_cache

Default: True

The master maintains a job cache, while this is a great addition it can be a burden on the master for larger deployments (over 5000 minions). Disabling the job cache will make previously executed jobs unavailable to the jobs system and is not generally recommended. Normally it is wise to make sure the master has access to a faster IO system or a tmpfs is mounted to the jobs dir

  sock_dir

Default:: /tmp/salt-unix

Set the location to use for creating Unix sockets for master process communication

  Master Security Settings

  open_mode

Default: False

Open mode is a dangerous security feature. One problem encountered with pki authentication systems is that keys can become "mixed up" and authentication begins to fail. Open mode turns off authentication and tells the master to accept all authentication. This will clean up the pki keys received from the minions. Open mode should not be turned on for general use. Open mode should only be used for a short period of time to clean up pki keys. To turn on open mode set this value to True.

open_mode: False

  auto_accept

Default: False

Enable auto_accept. This setting will automatically accept all incoming public keys from the minions

auto_accept: False

  Master Module Management

  runner_dirs

Default: []

Set additional directories to search for runner modules

  cython_enable

Default: False

Set to true to enable cython modules (.pyx files) to be compiled on the fly on the Salt master

cython_enable: False

  Master State System Settings

  state_top

Default: top.sls

The state system uses a "top" file to tell the minions what environment to use and what modules to use. The state_top file is defined relative to the root of the base environment

state_top: top.sls

  external_nodes

Default: None

The external_nodes option allows Salt to gather data that would normally be placed in a top file from and external node controller. The external_nodes option is the executable that will return the ENC data. Remember that Salt will look for external nodes AND top files and combine the results if both are enabled and available!

external_nodes: cobbler-ext-nodes

  renderer

Default: yaml_jinja

The renderer to use on the minions to render the state data

renderer: yaml_jinja

  failhard

Default:: False

Set the global failhard flag, this informs all states to stop running states at the moment a single state fails

failhard: False

  test

Default:: False

Set all state calls to only test if they are going to acctually make changes or just post what changes are going to be made

test: False

  Master File Server Settings

  file_roots

Default: base: [/srv/salt]

Salt runs a lightweight file server written in zeromq to deliver files to minions. This file server is built into the master daemon and does not require a dedicated port.

The file server works on environments passed to the master. Each environment can have multiple root directories. The subdirectories in the multiple file roots cannot match, otherwise the downloaded files will not be able to be reliably ensured. A base environment is required to house the top file. Example:

file_roots:
  base:
    - /srv/salt/
  dev:
    - /srv/salt/dev/services
    - /srv/salt/dev/states
  prod:
    - /srv/salt/prod/services
    - /srv/salt/prod/states

base:
  - /srv/salt

  hash_type

Default: md5

The hash_type is the hash to use when discovering the hash of a file on the master server, the default is md5, but sha1, sha224, sha256, sha384 and sha512 are also supported.

hash_type: md5

  file_buffer_size

Default: 1048576

The buffer size in the file server in bytes

file_buffer_size: 1048576

  Pillar Configuration

  pillar_roots

Set the environments and directorirs used to hold pillar sls data. This configuration is the same as file_roots:

Default: base: [/srv/pillar]

file_roots:
  base:
    - /srv/pillar/
  dev:
    - /srv/pillar/dev/
  prod:
    - /srv/pillar/prod/

base:
  - /srv/pillar

  ext_pillar

The ext_pillar option allows for any number of external pillar interfaces to be called when populating pillar data. The configuration is based on ext_pillar functions. The available ext_pillar functions are: hiera, cmd_yaml. By default the ext_pillar interface is not configued to run.

Default:: None

ext_pillar:
  - hiera: /etc/hiera.yaml
  - cmd: cat /etc/salt/yaml

  Syndic Server Settings

A Salt syndic is a Salt master used to pass commands from a higher Salt master to minions below the syndic. Using the syndic is simple. If this is a master that will have syndic servers(s) below it, set the "order_masters" setting to True. If this is a master that will be running a syndic daemon for passthrough the "syndic_master" setting needs to be set to the location of the master server

  order_masters

Default: False

Extra data needs to be sent with publications if the master is controlling a lower level master via a syndic minion. If this is the case the order_masters value must be set to True

order_masters: False

  syndic_master

Default: None

If this master will be running a salt-syndic to connect to a higher level master, specify the higher level master with this configuration value

syndic_master: masterofmasters

  Peer Publish Settings

Salt minions can send commands to other minions, but only if the minion is allowed to. By default "Peer Publication" is disabled, and when enabled it is enabled for specific minions and specific commands. This allows secure compartmentalization of commands based on individual minions.

  peer

Default: {}

The configuration uses regular expressions to match minions and then a list of regular expressions to match functions. The following will allow the minion authenticated as foo.example.com to execute functions from the test and pkg modules

peer:
  foo.example.com:
      - test.*
      - pkg.*

This will allow all minions to execute all commands:

peer:
  .*:
      - .*

This is not recommended, since it would allow anyone who gets root on any single minion to instantly have root on all of the minions!

  peer_run

Default: {}

The peer_run option is used to open up runners on the master to access from the minions. The peer_run configuration matches the format of the peer configuration.

The following example would allow foo.example.com to execute the manage.up runner:

peer_run:
  foo.example.com:
      - manage.up

  Node Groups

Default: {}

Node groups allow for logical groupings of minion nodes. A group consists of a group name and a compound target.

nodegroups:
  group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com'
  group2: 'G@os:Debian and foo.domain.com'

  Master Logging Settings

  log_file

Default: /var/log/salt/master

The location of the master log file

log_file: /var/log/salt/master

  log_level

Default: warning

The level of messages to send to the log file. One of 'info', 'quiet', 'critical', 'error', 'debug', 'warning'.

log_level: warning

  log_granular_levels

Default: {}

Logger levels can be used to tweak specific loggers logging levels. Imagine you want to have the Salt library at the 'warning' level, but you still wish to have 'salt.modules' at the 'debug' level:

log_granular_levels:
  'salt': 'warning',
  'salt.modules': 'debug'

CONFIGURING THE SALT MINION

The Salt system is amazingly simple and easy to configure, the two components of the Salt system each have a respective configuration file. The salt-master is configured via the master configuration file, and the salt-minion is configured via the minion configuration file.

See also

    example minion configuration file

The Salt Minion configuration is very simple, typically the only value that needs to be set is the master value so the minion can find its master.

  Minion Primary Configuration

  master

Default: salt

The hostname or ipv4 of the master.

master: salt

  master_port

Default: 4506

The port of the master ret server, this needs to coincide with the ret_port option on the Salt master.

master_port: 4506

  user

Default: root

The user to run the Salt processes

user: root

  pki_dir

Default: /etc/salt/pki

The directory used to store the minion's public and private keys.

pki_dir: /etc/salt/pki

  id

Default: hostname (as returned by the Python call: socket.getfqdn())

Explicitly declare the id for this minion to use, if left commented the id will be the hostname as returned by the Python call: socket.getfqdn() Since Salt uses detached ids it is possible to run multiple minions on the same machine but with different ids, this can be useful for Salt compute clusters.

id: foo.bar.com

  sub_timeout

The minion connection to the master may be interrupted, the minion will verify the connection every so many seconds, to disable connection verification set this value to 0

sub_timeout: 60

  cachedir

Default: /var/cache/salt

The location for minion cache data.

cachedir: /var/cache/salt

  cache_jobs

Default: False

The minion can locally cache the return data from jobs sent to it, this can be a good way to keep track minion side of the jobs the minion has executed. By default this feature is disabled, to enable set cache_jobs to True

cache_jobs: False

  acceptance_wait_time

Default: 10

The number of seconds to wait until attempting to re-authenticate with the master.

acceptance_wait_time: 10

  Minion Module Management

  disable_modules

Default: [] (all modules are enabled by default)

The event may occur in which the administrator desires that a minion should not be able to execute a certain module. The sys module is built into the minion and cannot be disabled.

This setting can also tune the minion, as all modules are loaded into ram disabling modules will lover the minion's ram footprint.

disable_modules:
  - test
  - solr

  disable_returners

Default: [] (all returners are enabled by default)

If certain returners should be disabled, this is the place

disable_returners:
  - mongo_return

  module_dirs

Default: []

A list of extra directories to search for Salt modules

module_dirs:
  - /var/lib/salt/modules

  returner_dirs

Default: []

A list of extra directories to search for Salt returners

returners_dirs:
  - /var/lib/salt/returners

  states_dirs

Default: []

A list of extra directories to search for Salt states

states_dirs:
  - /var/lib/salt/states

  render_dirs

Default: []

A list of extra directories to search for Salt renderers

render_dirs:
  - /var/lib/salt/renderers

  cython_enable

Default: False

Set this value to true to enable auto-loading and compiling of .pyx modules, This setting requires that gcc and cython are installed on the minion

cython_enable: False

  State Management Settings

  renderer

Default: yaml_jinja

The default renderer used for local state executions

renderer: yaml_jinja

  state_verbose

Default: False

state_verbose allows for the data returned from the minion to be more verbose. Normally only states that fail or states that have changes are returned, but setting state_verbose to True will return all states that were checked

state_verbose: True

  autoload_dynamic_modules

Default: True

autoload_dynamic_modules Turns on automatic loading of modules found in the environments on the master. This is turned on by default, to turn of autoloading modules when states run set this value to False

autoload_dynamic_modules: True

Default: True

clean_dynamic_modules keeps the dynamic modules on the minion in sync with the dynamic modules on the master, this means that if a dynamic module is not on the master it will be deleted from the minion. By default this is enabled and can be disabled by changing this value to False

clean_dynamic_modules: True

  environment

Default: None

Normally the minion is not isolated to any single environment on the master when running states, but the environment can be isolated on the minion side by statically setting it. Remember that the recommended way to manage environments is to isolate via the top file.

environment: None

  Security Settings

  open_mode

Default: False

Open mode can be used to clean out the PKI key received from the Salt master, turn on open mode, restart the minion, then turn off open mode and restart the minion to clean the keys.

open_mode: False

  Thread Settings

Default: True

Disable multiprocessing support by default when a minion receives a publication a new process is spawned and the command is executed therein.

multiprocessing: True

  Minion Logging Settings

  log_file

Default: /var/log/salt/minion

The location of the minion log file

log_file: /var/log/salt/minion

  log_level

Default: warning

The level of messages to send to the log file. One of 'info', 'quiet', 'critical', 'error', 'debug', 'warning'.

log_level: warning

  log_granular_levels

Default: {}

Logger levels can be used to tweak specific loggers logging levels. Imagine you want to have the Salt library at the 'warning' level, but, you still wish to have 'salt.modules' at the 'debug' level:

log_granular_levels:
  'salt': 'warning',
  'salt.modules': 'debug'

COMMAND LINE REFERENCE

Salt can be controlled by a command line client by the root user on the Salt master. The Salt command line client uses the Salt client API to communicate with the Salt master server. The Salt client is straightforward and simple to use.

Using the Salt client commands can be easily sent to the minions.

Each of these commands accepts an explicit --config option to point to either the master or minion configuration file. If this option is not provided and the default configuration file does not exist then Salt falls back to use the environment variables SALT_MASTER_CONFIG and SALT_MINION_CONFIG.

See also

    /topics/configuration

  Using the Salt Command

The Salt command needs a few components to send information to the Salt minions. The target minions need to be defined, the function to call and any arguments the function requires.

  Defining the Target Minions

The first argument passed to salt, defines the target minions, the target minions are accessed via their hostname. The default target type is a bash glob:

salt \*foo.com sys.doc

Salt can also define the target minions with regular expressions:

salt -E '.*' cmd.run 'ls -l | grep foo'

Or to explicitly list hosts, salt can take a list:

salt -L foo.bar.baz,quo.qux cmd.run 'ps aux | grep foo'

  More Powerful Targets

The simple target specifications, glob, regex and list will cover many use cases, and for some will cover all use cases, but more powerful options exist.

  Targeting with Grains

The Grains interface was built into Salt to allow minions to be targeted by system properties. So minions running on a particular operating system can be called to execute a function, or a specific kernel.

Calling via a grain is done by passing the -G option to salt, specifying a grain and a regular expression to match the value of the grain.

salt -G 'os:Fedora' test.ping

Will return True from all of the minions running Fedora.

To discover what grains are available and what the values are, execute the grains.item salt function:

salt '*' grains.items

  Targeting with Executions

As of 0.8.8 targeting with executions is still under heavy development and this documentation is written to reference the behavior of execution matching in the future.

Execution matching allows for a primary function to be executed, and then based on the return of the primary function the main function is executed.

Execution matching allows for matching minions based on any arbitrary running data on the minions.

  Compound Targeting

New in version 0.9.5.

Multiple target interfaces can be used in conjunction to determine the command targets. These targets can then be combined using and or or statements. This is well defined with an example:

salt -C 'G@os:Debian and webser* or E@db.*' test.ping

In this example any minion who's id starts with webser and is running Debian, or any minion who's id starts with db will be matched.

The type of matcher defaults to glob, but can be specified with the corresponding letter followed by the @ symbol. In the above example a grain is used with G@ as well as a regular expression with E@. The webser* target does not need to be prefaced with a target type specifier because it is a glob.

  Node Group Targeting

New in version 0.9.5.

Often the convenience of having a predefined group of minions to execute targets on is desired. This can be accomplished with the new nodegroups feature. Nodegroups allow for predefined compound targets to be declared in the master configuration file:

nodegroups:
  group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com'
  group2: 'G@os:Debian and foo.domain.com'

  Calling the Function

The function to call on the specified target is placed after the target specification.

  Finding available minion functions

The Salt functions are self documenting, all of the function documentation can be retried from the minions via the sys.doc() function:

salt '*' sys.doc

  Compound Command Execution

If a series of commands needs to be sent to a single target specification then the commands can be sent in a single publish. This can make gathering groups of information faster, and lowers the stress on the network for repeated commands.

Compound command execution works by sending a list of functions and arguments instead of sending a single function and argument. The functions are executed on the minion in the order they are defined on the command line, and then the data from all of the commands are returned in a dictionary. This means that the set of commands are called in a predictable way, and the returned data can be easily interpreted.

Executing compound commands if done by passing a comma delimited list of functions, followed by a comma delimited list of arguments:

salt '*' cmd.run,test.ping,test.echo 'cat /proc/cpuinfo',,foo

The trick to look out for here, is that if a function is being passed no arguments, then there needs to be a placeholder for the absent arguments. This is why in the above example, there are two commas right next to each other. test.ping takes no arguments, so we need to add another comma, otherwise Salt would attempt to pass "foo" to test.ping.

SALT

  Synopsis
salt '*' [ options ] sys.doc

salt -E '.*' [ options ] sys.doc cmd

salt -G 'os:Arch.*' [ options ] test.ping

salt -C 'G@os:Arch.* and webserv* or G@kernel:FreeBSD' [ options ] test.ping

salt -Q test.ping

  Description

Salt allows for commands to be executed across a swath of remote systems in parallel. This means that remote systems can be both controlled and queried with ease.

  Options

-h, --help
    Print a usage message briefly summarizing these command-line options

-t TIMEOUT, --timeout=TIMEOUT
    The timeout in seconds to wait for replies from the Salt minions.

-s STATIC, --static=STATIC
    By default as of version 0.9.8 the salt command returns data to the console as it is received from minions, but previous releases would return data only after all data was received. To only return the data with a hard timeout and after all minions have returned then use the static option.

-b BATCH, --batch-size=BATCH
    Instead of executing on all targeted minions at once, execute on a progressive set of minions. This option takes an argument in the form of an explicit number of minions to execute at once, or a percentage of minions to execute on.

--version
    Print the version of Salt that is running.

-E, --pcre
    The target expression will be interpreted as a pcre regular expression rather than a shell glob.

-L, --list
    The target expression will be interpreted as a comma delimited list, example: server1.foo.bar,server2.foo.bar,example7.quo.qux

-G, --grain
    The target expression matches values returned by the Salt grains system on the minions. The target expression is in the format of '<grain value>:<glob expression>'; example: 'os:Arch*'

    This was changed in version 0.9.8 to accept glob expressions instead of regular expression. To use regular expression matching with grains use the --grain-pcre option.

--grain-pcre
    The target expression matches values returned by the Salt grains system on the minions. The target expression is in the format of '<grain value>:< regular expression>'; example: 'os:Arch.*'

-C, --compound
    Utilize many target definitions to make the call very granular. This option takes a group of targets separated by and or or. The default matcher is a glob as usual, if something other than a glob is used preface it with the letter denoting the type, example: 'webserv* and G@os:Debian or E@db*' make sure that the compound target is encapsulated in quotes.

-X, --exsel
    Instead of using shell globs use the return code of a function.

-N, --nodegroup
    Use a predefined compound target defined in the Salt master configuration file

-R, --range
    Instead of using shell globs to evaluate the target use a range expression to identify targets. Range expressions look like %cluster.

    Using the Range option requires that a range server is set up and the location of the range server is referenced in the master configuration file.

--return
    Chose an alternative returner to call on the minion, if an alternative returner is used then the return will not come back tot he command line but will be sent to the specified return system.

-Q, --query
    The -Q option is being deprecated and will be removed in version 0.9.9, Use the Salt jobs interface instead, for documentation on the Salt jobs interface execute the command "salt-run -d jobs"

    Execute a salt command query, this can be used to find the results of a previous function call: -Q test.echo')

-c CONFIG, --config=CONFIG
    The location of the Salt master configuration file, the Salt master settings are required to know where the connections are; default=/etc/salt/master

--raw-out
    Print the output from the salt command in raw Python form, this is suitable for re-reading the output into an executing Python script with eval.

--text-out
    Print the output from the salt command in the same form the shell would.

--yaml-out
    Print the output from the salt command in YAML.

--json-out
    Print the output from the salt command in JSON.

--no-color
    Disable all colored output

  See also

salt(7) salt-master(1) salt-minion(1)

SALT-MASTER

The Salt master daemon, used to control the Salt minions

  Synopsis

salt-master [ options ]

  Description

The master daemon controls the Salt minions

  Options

-h, --help
    Print a usage message briefly summarizing these command-line options.

-d, --daemon
    Run the Salt master as a daemon

-c CONFIG, --config=CONFIG
    The master configuration file to use, the default is /etc/salt/master

-u USER, --user=USER
    Specify user to run minion

--pid-file PIDFILE
    Specify the location of the pidfile.

-l LOG_LEVEL, --log-level=LOG_LEVEL
    Console log level. One of info, none, garbage, trace, warning, error, debug. For the logfile settings see the config file. Default: warning.

  See also

salt(1) salt(7) salt-minion(1)

SALT-MINION

The Salt minion daemon, receives commands from a remote Salt master.

  Synopsis

salt-minion [ options ]

  Description

The Salt minion receives commands from the central Salt master and replies with the results of said commands.

  Options

-h, --help
    Print a usage message briefly summarizing these command-line options.

-d, --daemon
    Run the Salt minion as a daemon

-c CONFIG, --config=CONFIG
    The minion configuration file to use, the default is /etc/salt/minion

-u USER, --user=USER
    Specify user to run minion

--pid-file PIDFILE
    Specify the location of the pidfile

-l LOG_LEVEL, --log-level=LOG_LEVEL
    Console log level. One of info, none, garbage, trace, warning, error, debug. For the logfile settings see the config file. Default: warning.

  See also

salt(1) salt(7) salt-master(1)

SALT-KEY

  Synopsis

salt-key [ options ]

  Description

Salt-key executes simple management of Salt server public keys used for authentication.

  Options

-h, --help
    Print a usage message briefly summarizing these command-line options.

-l, --list
    List the unaccepted minion public keys.

-L, --list-all
    List all public keys on this Salt master: accepted, pending, and rejected.

-a ACCEPT, --accept=ACCEPT
    Accept the named minion public key for command execution.

-A, --accept-all
    Accepts all pending public keys.

-r REJECT, --reject=REJECT
    Reject the named minion public key.

-R, --reject-all
    Rejects all pending public keys.

-d DELETE, --delete=DELETE
    Delete the named minion key for command execution.

-D DELETE_ALL, --delete-all=DELETE_ALL
    Deleta all keys

-c CONFIG, --config=CONFIG
    The master configuration file needs to be read to determine where the Salt keys are stored via the pki_dir configuration value; default=/etc/salt/master

SALT-CP

Copy a file to a set of systems

  Synopsis

salt-cp '*' [ options ] SOURCE DEST
salt-cp -E '.*' [ options ] SOURCE DEST
salt-cp -G 'os:Arch.*' [ options ] SOURCE DEST

  Description

Salt copy copies a local file out to all of the Salt minions matched by the given target.

  Options

-h, --help
    Print a usage message briefly summarizing these command-line options

-t TIMEOUT, --timeout=TIMEOUT
    The timeout in seconds to wait for replies from the Salt minions.

-E, --pcre
    The target expression will be interpreted as a PCRE regular expression rather than a shell glob.

-L, --list
    The target expression will be interpreted as a comma delimited list, example: server1.foo.bar,server2.foo.bar,example7.quo.qux

-G, --grain
    The target expression matches values returned by the Salt grains system on the minions. The target expression is in the format of '<grain value>:<glob expression>'; example: 'os:Arch*'

--grain-pcre
    The target expression matches values returned by the Salt grains system on the minions. The target expression is in the format of '<grain value>:<pcre regular expression>'; example: 'os:Arch.*'

-R, --range
    Instead of using shell globs to evaluate the target use a range expression to identify targets. Range expressions look like %cluster.

    Using the Range option requires that a range server is set up and the location of the range server is referenced in the master configuration file.

-C, --compound
    Utilize many target definitions to make the call very granular. This option takes a group of targets separated by and or or. The default matcher is a glob as usual, if something other than a glob is used preface it with the letter denoting the type, example: 'webserv* and G@os:Debian or E@db*' make sure that the compound target is encapsulated in quotes.

-c CONFIG, --config=CONFIG
    The location of the Salt master configuration file, the Salt master settings are required to know where the connections are; default=/etc/salt/master

  See also

salt(1) salt-master(1) salt-minion(1)

SALT-CALL

  Synopsis

salt-call [options]

  Options

-h, --help
    Print a usage message briefly summarizing these command-line options

-g, --grains
    Return the information generated by the Salt grains

-m MODULE_DIRS, --module-dirs=MODULE_DIRS
    Specify an additional directories to pull modules from, multiple directories can be delimited by commas

-d, --doc
    Return the documentation for the specified module or for all modules if none are specified

-l LOG_LEVEL, --log-level=LOG_LEVEL
    Console log level. One of info, none, garbage, trace, warning, error, debug. For the logfile settings see the config file. Default: info.

--raw-out
    Print the output from the salt command in raw Python form, this is suitable for re-reading the output into an executing Python script with eval.

--text-out
    Print the output from the salt command in the same form the shell would.

--yaml-out
    Print the output from the salt command in YAML.

--json-out
    Print the output from the salt command in JSON.

--no-color
    Disable all colored output

  See also

salt(1) salt-master(1) salt-minion(1)

SALT-RUN

Execute a Salt runner

  Synopsis

salt-run RUNNER

  Description

salt-run is the frontend command for executing Salt Runners. Salt runners are simple modules used to execute convenience functions on the master

  Options

-h, --help
    Print a usage message briefly summarizing these command-line options

-c CONFIG, --config=CONFIG
    The location of the Salt master configuration file, the Salt master settings are required to know where the connections are; default=/etc/salt/master

  See also

salt(1) salt-master(1) salt-minion(1)

SALT-SYNDIC

The Salt syndic daemon, a special minion that passes through commands from a higher master

  Synopsis

salt-syndic [ options ]

  Description

The Salt syndic daemon, a special minion that passes through commands from a higher master.

  Options

-h, --help
    Print a usage message briefly summarizing these command-line options.

-d, --daemon
    Run the Salt syndic as a daemon

--pid-file PIDFILE
    Specify the location of the pidfile

--master-config=MASTER_CONFIG
    The master configuration file to use, the default is /etc/salt/master

--minion-config=MINION_CONFIG
    The minion configuration file to use, the default is /etc/salt/minion

  See also

salt(1) salt-master(1) salt-minion(1)

ABSTRACT ON SALT AUTHENTICATION AND ENCRYPTION

The Salt authentication and encryption system uses Public Key authentication and AES encryption to facilitate both authentication and high speed encryption.

The core components of this system can be separated into a few sections, Message Formatting, PubKey Handshake, AES key management, and encryption.

  Message Formatting

All messages passed within Salt are formatted with a clear header and a "load". The header is always clear, and specifies the encryption used by the load. The load can be encrypted with the private key of the sending system, or with the shared, rotating, AES key.

The message itself is abstracted as a Python dict in this fashion:

{'enc': 'aes',
 'load': <encrypted msgpack binary data>}

When this message is received the load can be decrypted using the shared AES key. The 'enc' dict key can also be "pub" for pubkey encryption, or "clear" for passing messages in the clear.

  PubKey Handshake

RSA Public keys are generated on the Salt master and on the Salt minion. When A salt minion establishes an initial connection to the salt master the minion sends its public key in the clear to the salt master, along with the id of the minion, and the command to execute on the master, in this case "_auth":

{'enc': 'clear',
 'load':
    {'cmd': '_auth',
     'id': <minion id>,
     'pub': <minion public key>}}

If this is the first time this minion has authenticated, then the salt master returns a clear message informing the minion that it is pending authentication. The minion then queries the master every ten seconds awaiting authentication. When the public key of the minion has been approved by the master, then the master's public key is returned, with the AES key used to encrypt messages and information on how to connect to the salt master publish interface.

The returned AES key is encrypted with the minion's public key, and can therefore only be decrypted by the minion that sent out the public key.

Once the minion has authenticated and is in possession of the revolving master AES key (The AES key is regenerated when the master restarts) then it attaches the minion subscriber to the master publisher.

All messages sent from the publisher are encrypted using the revolving AES key, in the event that the master restarts the minions will all have an invalid AES key because it has been regenerated on the master. The master will then send out a publication that the minions cannot decrypt. If the minion receives a publication that cannot be decrypted then the minion will re-authenticate, obtain the correct AES key, and decrypt the message. This means that the AES key on the salt master can safely revolve without interrupting the minion connection.

  Regular Communication

Once the minion has authenticated, then all messages sent between the minion and the master are encrypted using the revolving AES key and the {'enc': 'aes'} header.

  Source Files Implimenting Components

The pubkey authentication is managed via the salt.master module: https://github.com/saltstack/salt/blob/v0.10.0/salt/master.py The regular minion authentication is managed via the salt.crypt module: https://github.com/saltstack/salt/blob/v0.10.0/salt/crypt.py The salt.crypt module contains a class "SAuth" that can be used for standalone authentication with the Salt master, this is most likely the best place to start when looking into how the authentication mechanism works The encrypted "load" portion of the messages are encrypted and decrypted using the Crypticle class in the crypt module.

  Conclusion

In the end Salt uses formatted messages with clear header data to specify how the message data is encrypted. Asymetric encryption via RSA keys is only used for authentication and to securely retrieve the master AES key. All further communications are are encrypted with 256 bit AES.

RELEASE NOTES AND UPGRADE INSTRUCTIONS

  Salt 0.10.0 Release Notes

0.10.0 has arrived! This release comes with MANY bug fixes, and new capabilities which greatly enhance performance and reliability. This release is primarily a bug fix release with many new tests and many repaired bugs. This release also introduces a few new key features which were brought in primarily to repair bugs and some limitations found in some of the components of the original architecture.

  Major Features

  Event System

The Salt Master now comes equipped with a new event system. This event system has replaced some of the back end of the Salt client and offers the beginning of a system which will make plugging external applications into Salt. The event system relies on a local zeromq publish socket and other processes can connect to this socket and listen for events. The new events can be easily managed via Salt's event library.

  Unprivileged User Updates

Some enhancements have been added to Salt for running as a user other than root. These new additions should make switching the user that the Salt Master is running as very painless, simply change the user option in the master configuration and restart the master, Salt will take care of all of the particulars for you.

  Peer Runner Execution

Salt has long had the peer communication system used to allow minions to send commands via the salt master. 0.10.0 adds a new capability here, now the master can be configured to allow for minions to execute Salt runners via the peer_run option in the salt master configuration.

  YAML Parsing Updates

In the past the YAML parser for sls files would return the incorrect numbers when the file mode was set with a preceding 0. The yaml parser used in Salt has been modified to no longer convert these number into octal but to keep them as the correct value so that sls files can be a little cleaner to write.

  State Call Data Files

It was requested that the minion keep a local cache of the most recent executed state run. This has been added and now with state runs the data is stored in a msgpack file in the minion's cachedir.

  Turning Off the Job Cache

A new option has been added to the master configuration file. In previous releases the Salt client would look over the Salt job cache to read in the minion return data. With the addition of the event system the Salt client can now watch for events directly from the master worker processes.

This means that the job cache is no longer a hard requirement. Keep in mind though, that turning off the job cache means that historic job execution data cannot be retrieved.

  Test Updates

  Minion Swarms Are Faster

To continue our efforts with testing Salt's ability to scale the minionswarm script has been updated. The minionswarm can now start up minions much faster than it could before and comes with a new feature allowing modules to be disabled, thus lowering the minion's footprint when making a swarm. These new updates have allows us to test

# python minionswarm.py -m 20 --master salt-master

  Many Fixes

To get a good idea for the number of bugfixes this release offers take a look at the closed tickets for 0.10.0, this is a very substantial update:

https://github.com/saltstack/salt/issues?milestone=12&state=closed

  Master and Minion Stability Fixes

As Salt deployments grow new ways to break Salt are discovered. 0.10.0 comes with a number of fixes for the minions and master greatly improving Salt stability.

  Salt 0.6.0 release notes

The Salt remote execution manager has reached initial functionality! Salt is a management application which can be used to execute commands on remote sets of servers.

The whole idea behind Salt is to create a system where a group of servers can be remotely controlled from a single master, not only can commands be executed on remote systems, but salt can also be used to gather information about your server environment.

Unlike similar systems, like Func and MCollective, Salt is extremely simple to setup and use, the entire application is contained in a single package, and the master and minion daemons require no running dependencies in the way that Func requires Certmaster and MCollective requires activeMQ.

Salt also manages authentication and encryption. Rather than using ssl for encryption, salt manages encryption on a payload level, so the data sent across the network is encrypted with fast aes encryption, and authentication uses RSA keys. This means that Salt is fast, secure, and very efficient.

Messaging in Salt is executed with zeromq, so the message passing interface is built into salt and does not require an external MQ server. This also adds speed to Salt since there is no additional bloat on the networking layer, and zeromq has already proven itself as a very fast networking system.

The remote execution in Salt is "Lazy Execution", in that once the command is sent the requesting network connection is closed. This makes it easier to detach the execution from the calling process on the master, it also means that replies are cached, so that information gathered from historic commands can be queried in the future.

Salt also allows users to make execution modules in Python. Writers of these modules should also be pleased to know that they have access to the impressive information gathered from PuppetLabs' Facter application, making Salt module more flexible. In the future I hope to also allow Salt to group servers based on facter information as well.

All in all Salt is fast, efficient and clean, can be used from a simple command line client or through an api, uses message queue technology to make network execution extremely fast, and encryption is handled in a very fast and efficient manner. Salt is also VERY easy to use and VERY easy to extend.

You can find the source code for Salt on my github page, I have also set up a few wiki pages explaining how to use and set up Salt. If you are using Arch Linux there is a package available in the Arch Linux AUR.

Salt 0.6.0 Source: https://github.com/downloads/saltstack/salt/salt-0.6.0.tar.gz

Github page: https://github.com/saltstack/salt

Wiki: https://github.com/saltstack/salt/wiki

Arch Linux Package: https://aur.archlinux.org/packages.php?ID=47512

I am very open to contributions, for instance I need packages for more Linux distributions as well as BSD packages and testers.

Give Salt a try, this is the initial release and is not a 1.0 quality release, but it has been working well for me! I am eager to get your feedback!

  Salt 0.7.0 release notes

I am pleased to announce the release of Salt 0.7.0!

This release marks what is the first stable release of salt, 0.7.0 should be suitable for general use.

0.7.0 Brings the following new features to Salt:

•   Integration with facter data from puppet labs

•   Allow for matching minions from the salt client via facter information

•   Minion job threading, many jobs can be executed from the master at once

•   Preview of master clustering support - Still experimental

•   Introduce new minion modules for stats, virtualization, service management and more

•   Add extensive logging to the master and minion daemons

•   Add sys.reload_functions for dynamic function reloading

•   Greatly improve authentication

•   Introduce the saltkey command for managing public keys

•   Begin backend development preparatory to introducing butter

•   Addition of man pages for the core commands

•   Extended and cleaned configuration

    0.7.0 Fixes the following major bugs:

•   Fix crash in minions when matching failed

•   Fix configuration file lookups for the local client

•   Repair communication bugs in encryption

•   Numerous fixes in the minion modules

    The next release of Salt should see the following features:

•   Stabilize the cluster support

•   Introduce a remote client for salt command tiers

•   salt-ftp system for distributed file copies

•   Initial support for "butter"

    Coming up next is a higher level management framework for salt called Butter. I want salt to stay as a simple and effective communication framework, and allow for more complicated executions to be managed via Butter.

    Right now Butter is being developed to act as a cloud controller using salt as the communication layer, but features like system monitoring and advanced configuration control (a puppet manager) are also in the pipe.

    Special thanks to Joseph Hall for the status and network modules, and thanks to Matthias Teege for tracking down some configuration bugs!

    Salt can be downloaded from the following locations;

    Source Tarball:

    https://github.com/downloads/saltstack/salt/salt-0.7.0.tar.gz

    Arch Linux Package:

    https://aur.archlinux.org/packages.php?ID=47512

    Please enjoy the latest Salt release!

  Salt 0.8.0 release notes

Salt 0.8.0 is ready for general consumption! The source tarball is available on github for download:

https://github.com/downloads/saltstack/salt/salt-0.8.0.tar.gz

A lot of work has gone into salt since the last release just 2 weeks ago, and salt has improved a great deal. A swath of new features are here along with performance and threading improvements!

The main new features of salt 0.8.0 are:

Salt-cp

Cython minion modules

Dynamic returners

Faster return handling

Lowered required Python version to 2.6

Advanced minion threading

Configurable minion modules

  Salt-cp -

The salt-cp command introduces the ability to copy simple files via salt to targeted servers. Using salt-cp is very simple, just call salt-cp with a target specification, the source file(s) and where to copy the files on the minions. For instance:

# salt-cp ‘*’ /etc/hosts /etc/hosts

Will copy the local /etc/hosts file to all of the minions.

Salt-cp is very young, in the future more advanced features will be added, and the functionality will much more closely resemble the cp command.

  Cython minion modules -

Cython is an amazing tool used to compile Python modules down to c. This is arguably the fastest way to run Python code, and since pyzmq requires cython, adding support to salt for cython adds no new dependencies.

Cython minion modules allow minion modules to be written in cython and therefore executed in compiled c. Simply write the salt module in cython and use the file extension “.pyx” and the minion module will be compiled when the minion is started. An example cython module is included in the main distribution called cytest.pyx:

https://github.com/saltstack/salt/blob/v0.10.0/salt/modules/cytest.pyx

  Dynamic Returners -

By default salt returns command data back to the salt master, but now salt can return command data to any system. This is enabled via the new returners modules feature for salt. The returners modules take the return data and sends it to a specific module. The returner modules work like minion modules, so any returner can be added to the minions.

This means that a custom data returner can be added to communicate the return data so anything from MySQL, redis, mongodb and more!

There are 2 simple stock returners in the returners directory:

https://github.com/saltstack/salt/blob/v0.10.0/salt/returners

The documentation on writing returners will be added to the wiki shortly, and returners can be written in pure Python, or in cython.

  Configurable Minion Modules -

Minion modules may need to be configured, now the options passed to the minion configuration file can be accessed inside of the minion modules via the __opt__ dict.

Information on how to use this simple addition has been added to the wiki: https://github.com/thatch45/salt/wiki/Writing-Salt-Modules

The test module has an example of using the __opts__ dict, and how to set default options:

https://github.com/saltstack/salt/blob/v0.10.0/salt/modules/test.py

  Advanced Minion Threading:

In 0.7.0 the minion would block after receiving a command from the master, now the minion will spawn a thread or multiprocess. By default Python threads are used because for general use they have proved to be faster, but the minion can now be configured to use the Python multiprocessing module instead. Using multiprocessing will cause executions that are cpu bound or would otherwise exploit the negative aspects of the Python GIL to run faster and more reliably, but simple calls will still be faster with Python threading. The configuration option can be found in the minion configuration file:

https://github.com/saltstack/salt/blob/v0.10.0/conf/minion

Lowered Supported Python to 2.6 -

The requirement for Python 2.7 has been removed to support Python 2.6. I have received requests to take the minimum Python version back to 2.4, but unfortunately this will not be possible, since the zeromq Python bindings do not support Python 2.4.

Salt 0.8.0 is a very major update, it also changes the network protocol slightly which makes communication with older salt daemons impossible, your master and minions need to be upgraded together! I could use some help bringing salt to the people! Right now I only have packages for Arch Linux, Fedora 14 and Gentoo. We need packages for Debian and people willing to help test on more platforms. We also need help writing more minion modules and returner modules. If you want to contribute to salt please hop on the mailing list and send in patches, make a fork on github and send in pull requests! If you want to help but are not sure where you can, please email me directly or post tot he mailing list!

I hope you enjoy salt, while it is not yet 1.0 salt is completely viable and usable!

-Thomas S. Hatch

  Salt 0.8.7 release notes

It has been a month since salt 0.8.0, and it has been a long month! But Salt is still coming along strong. 0.8.7 has a lot of changes and a lot of updates. This update makes Salt’s ZeroMQ back end better, strips facter from the dependencies, and introduces interfaces to handle more capabilities.

Many of the major updates are in the background, but the changes should shine through to the surface. A number of the new features are still a little thin, but the back end to support expansion is in place.

I also recently gave a presentation to the Utah Python users group in Salt Lake City, the slides from this presentation are available here: https://github.com/downloads/saltstack/salt/Salt.pdf

The video from this presentation will be available shortly.

The major new features and changes in Salt 0.8.7 are:

•   Revamp ZeroMQ topology on the master for better scalability

•   State enforcement

•   Dynamic state enforcement managers

•   Extract the module loader into salt.loader

•   Make Job ids more granular

•   Replace facter functionality with the new salt grains interface

•   Support for “virtual” salt modules

•   Introduce the salt-call command

•   Better debugging for minion modules

    The new ZeroMQ topology allows for better scalability, this will be required by the need to execute massive file transfers to multiple machines in parallel and state management. The new ZeroMQ topology is available in the aforementioned presentation.

    0.8.7 introduces the capability to declare states, this is similar to the capabilities of Puppet. States in salt are declared via state data structures. This system is very young, but the core feature set is available. Salt states work around rendering files which represent Salt high data. More on the Salt state system will be documented in the near future.

    The system for loading salt modules has been pulled out of the minion class to be a standalone module, this has enabled more dynamic loading of Salt modules and enables many of the updates in 0.8.7 –

    https://github.com/saltstack/salt/blob/v0.10.0/salt/loader.py

    Salt Job ids are now microsecond precise, this was needed to repair a race condition unveiled by the speed improvements in the new ZeroMQ topology.

    The new grains interface replaces the functionality of Facter, the idea behind grains differs from Facter in that the grains are only used for static system data, dynamic data needs to be derived from a call to a salt module. This makes grains much faster to use, since the grains data is generated when the minion starts.

    Virtual salt modules allows for a salt module to be presented as something other than its module name. The idea here is that based on information from the minion decisions about which module should be presented can be made. The best example is the pacman module. The pacman module will only load on Arch Linux minions, and will be called pkg. Similarly the yum module will be presented as pkg when the minion starts on a Fedora/RedHat system.

    The new salt-call command allows for minion modules to be executed from the minion. This means that on the minion a salt module can be executed, this is a great tool for testing Salt modules. The salt-call command can also be used to view the grains data.

    In previous releases when a minion module threw an exception very little data was returned to the master. Now the stack trace from the failure is returned making debugging of minion modules MUCH easier.

    Salt is nearing the goal of 1.0, where the core feature set and capability is complete!

    Salt 0.8.7 can be downloaded from github here: https://github.com/downloads/saltstack/salt/salt-0.8.7.tar.gz

    -Thomas S Hatch

  Salt 0.8.8 release notes

Salt 0.8.8 is here! This release adds a great deal of code and some serious new features. The latest release can be downloaded here: https://github.com/downloads/saltstack/salt/salt-0.8.8.tar.gz

Improved Documentation has been set up for salt using sphinx thanks to the efforts of Seth House. This new documentation system will act as the back end to the salt website which is still under heavy development. The new sphinx documentation system has also been used to greatly clean up the salt manpages. The salt 7 manpage in particular now contains extensive information which was previously only in the wiki. The new documentation can be found at: http://thatch45.github.com/salt-www/ We still have a lot to add, and when the domain is set up I will post another announcement.

More additions have been made to the ZeroMQ setup, particularly in the realm of file transfers. Salt 0.8.8 introduces a built in, stateless, encrypted file server which allows salt minions to download files from the salt master using the same encryption system used for all other salt communications. The main motivation for the salt file server has been to facilitate the new salt state system.

Much of the salt code has been cleaned up and a new cleaner logging system has been introduced thanks to the efforts of Pedro Algarvio. These additions will allow for much more flexible logging to be executed by salt, and fixed a great deal of my poor spelling in the salt docstrings! Pedro Algarvio has also cleaned up the api, making it easier to embed salt into another application.

The biggest addition to salt found in 0.8.8 is the new state system. The salt module system has received a new front end which allows salt to be used as a configuration management system. The configuration management system allows for system configuration to be defined in data structures. The configuration management system, or as it is called in salt, the “salt state system” supports many of the features found in other configuration managers, but allows for system states to be written in a far simpler format, executes at blazing speeds, and operates via the salt minion matching system. The state system also operates within the normal scope of salt, and requires no additional configuration to use.

The salt state system can enforce the following states with many more to come: Packages Files Services Executing commands Hosts

The system used to define the salt states is based on a data structure, the data structure used to define the salt states has been made to be as easy to use as possible. The data structure is defined by default using a yaml file rendered via a jinja template. This means that the state definition language supports all of the data structures that yaml supports, and all of the programming constructs and logic that jinja supports. If the user does not like yaml or jinja the states can be defined in yaml-mako, json-jinja, or json-mako. The system used to render the states is completely dynamic, and any rendering system can be added to the capabilities of Salt, this means that a rendering system that renders xml data in a cheetah template, or whatever you can imagine, can be easily added to the capabilities of salt.

The salt state system also supports isolated environments, as well as matching code from several environments to a single salt minion.

The feature base for Salt has grown quite a bit since my last serious documentation push. As we approach 0.9.0 the goals are becoming very clear, and the documentation needs a lot of work. The main goals for 0.9.0 are to further refine the state system, fix any bugs we find, get Salt running on as many platforms as we can, and get the documentation filled out. There is a lot more to come as Salt moves forward to encapsulate a much larger scope, while maintaining supreme usability and simplicity.

If you would like a more complete overview of Salt please watch the Salt presentation: Flash Video: http://blip.tv/thomas-s-hatch/salt-0-8-7-presentation-5180182 OGV Video Download: http://blip.tv/file/get/Thatch45-Salt087Presentation416.ogv Slides: https://github.com/downloads/saltstack/salt/Salt.pdf

-Thomas S Hatch

  Salt 0.8.9 Release Notes

Salt 0.8.9 has finally arrived! Unfortunately this is much later than I had hoped to release 0.8.9, life has been very crazy over the last month. But despite challenges, Salt has moved forward!

This release, as expected, adds few new features and many refinements. One of the most exciting aspect of this release is that the development community for salt has grown a great deal and much of the code is from contributors.

Also, I have filled out the documentation a great deal. So information on States is properly documented, and much of the documentation that was out of date has been filled in.

  Download!

The Salt source can be downloaded from the salt github site:

https://github.com/downloads/saltstack/salt/salt-0.8.9.tar.gz

Or from PiPy:

http://pypi.python.org/packages/source/s/salt/salt-0.8.9.tar.gz

Here s the md5sum:

7d5aca4633bc22f59045f59e82f43b56

For instructions on how to set up Salt please see the installation instructions.

  New Features

  Salt Run

A big feature is the addition of Salt run, the salt-run command allows for master side execution modules to be made that gather specific information or execute custom routines from the master.

Documentation for salt-run can be found here:

http://saltstack.org/ref/runners.html

  Refined Outputters

One problem often complained about in salt was the fact that the output was so messy. Thanks to help from Jeff Schroeder a cleaner interface for the command output for the Salt cli has been made. This new interface makes adding new printout formats easy and additions to the capabilities of minion modules makes it possible to set the printout mode or outputter for functions in minion modules.

  Cross Calling Salt Modules

Salt modules can now call each other, the __salt__ dict has been added to the predefined references in minion modules. This new feature is documented in the modules documentation:

http://saltstack.org/ref/modules/index.html

  Watch Option Added to Salt State System

Now in Salt states you can set the watch option, this will allow watch enabled states to change based on a change in the other defined states. This is similar to subscribe and notify statements in puppet.

  Root Dir Option

Travis Cline has added the ability to define the option root_dir which allows the salt minion to operate in a subdir. This is a strong move in supporting the minion running as an unprivileged user

  Config Files Defined in Variables

Thanks again to Travis Cline, the master and minion configuration file locations can be defined in environment variables now.

  New Modules

Quite a few new modules, states, returners and runners have been made.

  New Minion Modules

  apt

Support for apt-get has been added, this adds greatly improved Debian and Ubuntu support to Salt!

  useradd and groupadd

Support for manipulating users and groups on Unix-like systems.

  moosefs

Initial support for reporting on aspects of the distributed file system, MooseFS. For more information on MooseFS please see: http://moosefs.org

Thanks to Joseph Hall for his work on MooseFS support.

  mount

Manage mounts and the fstab.

  puppet

Execute puppet on remote systems.

  shadow

Manipulate and manage the user password file.

  ssh

Interact with ssh keys.

  New States

  user and group

Support for managing users and groups in Salt States.

  mount

Enforce mounts and the fstab.

  New Returners

  mongo_return

Send the return information to a mongodb server.

  New Runners

  manage

Display minions that are up or down.

  Salt 0.9.0 Release Notes

Salt 0.9.0 is here. This is an exciting release, 0.9.0 includes the new network topology features allowing peer salt commands and masters of masters via the syndic interface.

0.9.0 also introduces many more modules, improvements to the api and improvements to the ZeroMQ systems.

  Download!

The Salt source can be downloaded from the salt github site:

https://github.com/downloads/saltstack/salt/salt-0.9.0.tar.gz

Or from PiPy:

http://pypi.python.org/packages/source/s/salt/salt-0.9.0.tar.gz

Here is the md5sum:

9a925da04981e65a0f237f2e77ddab37

For instructions on how to set up Salt please see the installation instructions.

  New Features

  Salt Syndic

The new Syndic interface allows a master to be commanded via another higher level salt master. This is a powerful solution allowing a master control structure to exist, allowing salt to scale to much larger levels then before.

http://saltstack.org/ref/syndic.html

  Peer Communication

0.9.0 introduces the capability for a minion to call a publication on the master and receive the return from another set of minions. This allows salt to act as a communication channel between minions and as a general infrastructure message bus.

Peer communication is turned off by default but can be enabled via the peer option in the master configuration file. Documentation on the new peer interface can be found here:

http://saltstack.org/ref/peer.html

  Easily Extensible API

The minion and master classes have been redesigned to allow for specialized minion and master servers to be easily created. An example on how this is done for the master can be found in the master.py salt module:

https://github.com/saltstack/salt/blob/v0.10.0/salt/master.py

The Master class extends the SMaster class and set up the main master server.

The minion functions can now also be easily added to another application via the SMinion class, this class can be found in the minion.py module:

https://github.com/saltstack/salt/blob/v0.10.0/salt/minion.py

  Cleaner Key Management

This release changes some of the key naming to allow for multiple master keys to be held based on the type of minion gathering the master key.

The -d option has also been added to the salt-key command allowing for easy removal of accepted public keys.

The --gen-keys option is now available as well for salt-key, this allows for a salt specific RSA key pair to be easily generated from the command line.

  Improved 0MQ Master Workers

The 0MQ worker system has been further refined to be faster and more robust. This new system has been able to handle a much larger load than the previous setup. The new system uses the ipc protocol in 0MQ instead of tcp.

  New Modules

Quite a few new modules have been made.

  New Minion Modules

  apache

Work directly with apache servers, great for managing balanced web servers

  cron

Read out the contents of a systems crontabs

  mdadm

Module to manage raid devices in Linux, appears as the raid module

  mysql

Gather simple data from MySQL databases

  ps

Extensive utilities for managing processes

  publish

Used by the peer interface to allow minions to make publications

  Salt 0.9.2 Release Notes

Salt 0.9.2 has arrived! 0.9.2 is primarily a bugfix release, the exciting component in 0.9.2 is greatly improved support for salt states. All of the salt states interfaces have been more thoroughly tested and the new salt-states git repo is growing with example of how to use states.

This release introduces salt states for early developers and testers to start helping us clean up the states interface and make it ready for the world!

0.9.2 also fixes a number of bugs found on Python 2.6.

  Download!

The Salt source can be downloaded from the salt github site:

https://github.com/downloads/saltstack/salt/salt-0.9.2.tar.gz

Or from PiPy:

http://pypi.python.org/packages/source/s/salt/salt-0.9.2.tar.gz

For instructions on how to set up Salt please see the installation instructions.

  New Features

  Salt-Call Additions

The salt-call command has received an overhaul, it now hooks into the outputter system so command output looks clean, and the logging system has been hooked into salt-call, so the -l option allows the logging output from salt minion functions to be displayed.

The end result is that the salt-call command can execute the state system and return clean output:

# salt-call state.highstate

  State System Fixes

The state system has been tested and better refined. As of this release the state system is ready for early testers to start playing with. If you are interested in working with the state system please check out the (still very small) salt-states github repo:

https://github.com/thatch45/salt-states

This git repo is the active development branch for determining how a clean salt-state database should look and act. Since the salt state system is still very young a lot of help is still needed here. Please fork the salt-states repo and help us develop a truly large and scalable system for configuration management!

  Notable Bug Fixes

  Python 2.6 String Formatting

Python 2.6 does not support format strings without an index identifier, all of them have been repaired.

  Cython Loading Disabled by Default

Cython loading requires a development tool chain to be installed on the minion, requiring this by default can cause problems for most Salt deployments. If Cython auto loading is desired it will need to be turned on in the minion config.

  Salt 0.9.3 Release Notes

Salt 0.9.3 is finally arrived. This is another big step forward for Salt, new features range from proper FreeBSD support to fixing issues seen when attaching a minion to a master over the Internet.

The biggest improvements in 0.9.3 though can be found in the state system, it has progressed from something ready for early testers to a system ready to compete with platforms such as Puppet and Chef. The backbone of the state system has been greatly refined and many new features are available.

  Download!

The Salt source can be downloaded from the salt github site:

https://github.com/downloads/saltstack/salt/salt-0.9.3.tar.gz

Or from PiPy:

http://pypi.python.org/packages/source/s/salt/salt-0.9.3.tar.gz

For instructions on how to set up Salt please see the installation instructions.

  New Features

  WAN Support

Recently more people have been testing Salt minions connecting to Salt Masters over the Internet. It was found that Minions would commonly loose their connection to the master when working over the internet. The minions can now detect if the connection has been lost and reconnect to the master, making WAN connections much more reliable.

  State System Fixes

Substantial testing has gone into the state system and it is ready for real world usage. A great deal has been added to the documentation for states and the modules and functions available to states have been cleanly documented.

A number of State System bugs have also been founds and repaired, the output from the state system has also been refined to be extremely clear and concise.

Error reporting has also been introduced, issues found in sls files will now be clearly reported when executing Salt States.

  Extend Declaration

The Salt States have also gained the extend declaration. This declaration allows for states to be cleanly modified in a post environment. Simply said, if there is an apache.sls file that declares the apache service, then another sls can include apache and then extend it:

include:
  - apache
extend:
  apache:
    service:
      - require:
        - pkg: mod_python
mod_python:
  pkg:
    - installed

The notable behavior with the extend functionality is that it literally extends or overwrites a declaration set up in another sls module. This means that Salt will behave as though the modifications were made directly to the apache sls. This ensures that the apache service in this example is directly tied to all requirements.

  Highstate Structure Specification

This release comes with a clear specification of the Highstate data structure that is used to declare Salt States. This specification explains everything that can be declared in the Salt SLS modules.

The specification is extremely simple, and illustrates how Salt has been able to fulfill the requirements of a central configuration manager within a simple and easy to understand format and specification.

  SheBang Renderer Switch

It came to our attention that having many renderers means that there may be a situation where more than one State Renderer should be available within a single State Tree.

The method chosen to accomplish this was something already familiar to developers and systems administrators, a SheBang. The Python State Renderer displays this new capability.

  Python State Renderer

Until now Salt States could only be declared in yaml or json using jinja or mako. A new, very powerful, renderer has been added, making it possible to write Salt States in pure Python:

#!py
def run():
    '''
    Install the python-mako package
    '''
    return {'include': ['python'],
            'python-mako': {'pkg': ['installed']}}

This renderer is used by making a run function that returns the Highstate data structure. Any capabilities of Python can be used in pure Python sls modules.

This example of a pure Python sls module is the same as this example in yaml:

include:
  - python
python-mako:
  pkg:
    - installed

  FreeBSD Support

Additional support has been added for FreeBSD, this is Salt's first branch out of the Linux world and proves the viability of Salt on non-Linux platforms.

Salt remote execution already worked on FreeBSD, and should work without issue on any Unix-like platform. But this support comes in the form of package management and user support, so Salt States also work on FreeBSD now.

The new freebsdpkg module provides package management support for FreeBSD and the new pw_user and pw_group provide user and group management.

  Module and State Additions

  Cron Support

Support for managing the system crontab has been added, declaring a cron state can be done easily:

date > /tmp/datestamp:
  cron:
    - present
    - user: fred
    - minute: 5
    - hour: 3

  File State Additions

The file state has been given a number of new features, primarily the directory, recurse, symlink and absent functions.

file.directory
    Make sure that a directory exists and has the right permissions.

    /srv/foo:
      file:
        - directory
        - user: root
        - group: root
        - mode: 1755

file.symlink
    Make a symlink.

    /var/lib/www:
      file:
        - symlink
        - target: /srv/www
        - force: True

file.recurse
    The recurse state function will recursively download a directory on the master file server and place it on the minion. Any change in the files on the master will be pushed to the minion. The recuse function is very powerful and has been tested by pushing out the full Linux kernel source.

    /opt/code:
      file:
        - recurse
        - source: salt://linux

file.absent
    Make sure that the file is not on the system, recursively delets directories, files and symlinks.

    /etc/httpd/conf.d/somebogusfile.conf:
      file:
        - absent

  Sysctl Module and State

The sysctl module and state allows for sysctl components in the kernel to be managed easily. the sysctl module contains the following functions:

sysctl.show
    Return a list of sysctl parameters for this minion

sysctl.get
    Return a single sysctl parameter for this minion

sysctl.assign
    Assign a single sysctl parameter for this minion

sysctl.persist
    Assign and persist a simple sysctl parameter for this minion

    The sysctl state allows for sysctl parameters to be assigned:

    vm.swappiness:
      sysctl:
        - present
        - value: 20

  Kernel Module Management

A module for managing Linux kernel modules has been added. The new functions are as follows:

kmod.available
    Return a list of all available kernel modules

kmod.check_available
    Check to see if the specified kernel module is available

kmod.lsmod
    Return a dict containing information about currently loaded modules

kmod.load
    Load the specified kernel module

kmod.remove
    Unload the specified kernel module

    The kmod state can enforce modules be either present or absent:

    kvm_intel:
      kmod:
        - present

  Ssh Authorized Keys

The ssh_auth state can distribute ssh authorized keys out to minions. Ssh authorized keys can be present or absent.

 :
  ssh_auth:
    - present
    - user: frank
    - enc: dsa
    - comment: 'Frank's key'

  Salt 0.9.4 Release Notes

Salt 0.9.4 has arrived. This is a critical update that repairs a number of key bugs found in 0.9.3. But this update is not without feature additions as well! 0.9.4 adds support for Gentoo portage to the pkg module and state system. Also there are 2 major new state additions, the failhard option and the ability to set up finite state ordering with the order option.

This release also sees our largest increase in community contributions. These contributors have and continue to be the life blood of the Salt project, and the team continues to grow. I want to put out a big thanks to our new and existing contributors.

  Download!

The Salt source can be downloaded from the salt github site:

https://github.com/downloads/saltstack/salt/salt-0.9.4.tar.gz

Or from PiPy:

http://pypi.python.org/packages/source/s/salt/salt-0.9.4.tar.gz

For instructions on how to set up Salt please see the installation instructions.

  New Features

  Failhard State Option

Normally, when a state fails Salt continues to execute the remainder of the defined states and will only refuse to execute states that require the failed state.

But the situation may exist, where you would want all state execution to stop if a single state execution fails. The capability to do this is called failing hard.

  State Level Failhard

A single state can have a failhard set, this means that if this individual state fails that all state execution will immediately stop. This is a great thing to do if there is a state that sets up a critical config file and setting a require for each state that reads the config would be cumbersome. A good example of this would be setting up a package manager early on:

/etc/yum.repos.d/company.repo:
  file:
    - managed
    - source: salt://company/yumrepo.conf
    - user: root
    - group: root
    - mode: 644
    - order: 1
    - failhard: True

In this situation, the yum repo is going to be configured before other states, and if it fails to lay down the config file, than no other states will be executed.

  Global Failhard

It may be desired to have failhard be applied to every state that is executed, if this is the case, then failhard can be set in the master configuration file. Setting failhard in the master configuration file will result in failing hard when any minion gathering states from the master have a state fail.

This is NOT the default behavior, normally Salt will only fail states that require a failed state.

Using the global failhard is generally not recommended, since it can result in states not being executed or even checked. It can also be confusing to see states failhard if an admin is not actively aware that the failhard has been set.

To use the global failhard set failhard: True in the master configuration

  Finite Ordering of State Execution

When creating salt sls files, it is often important to ensure that they run in a specific order. While states will always execute in the same order, that order is not necessarily defined the way you want it.

A few tools exist in Salt to set up the correct state ordering, these tools consist of requisite declarations and order options.

  The Order Option

Before using the order option, remember that the majority of state ordering should be done with requisite statements, and that a requisite statement will override an order option.

The order option is used by adding an order number to a state declaration with the option order:

vim:
  pkg:
    - installed
    - order: 1

By adding the order option to 1 this ensures that the vim package will be installed in tandem with any other state declaration set to the order 1.

Any state declared without an order option will be executed after all states with order options are executed.

But this construct can only handle ordering states from the beginning. Sometimes you may want to send a state to the end of the line, to do this set the order to last:

vim:
  pkg:
    - installed
    - order: last

Substantial testing has gone into the state system and it is ready for real world usage. A great deal has been added to the documentation for states and the modules and functions available to states have been cleanly documented.

A number of State System bugs have also been founds and repaired, the output from the state system has also been refined to be extremely clear and concise.

Error reporting has also been introduced, issues found in sls files will now be clearly reported when executing Salt States.

  Gentoo Support

Additional experimental support has been added for Gentoo. This is found in the contribution from Doug Renn, aka nestegg.

  Salt 0.9.5 Release Notes

Salt 0.9.5 is one of the largest steps forward in the development of Salt.

0.9.5 comes with many milestones, this release has seen the community of developers grow out to an international team of 46 code contributors and has many feature additions, feature enhancements, bug fixes and speed improvements.

Warning
    Be sure to read the upgrade instructions about the switch to msgpack before upgrading!

  Community

Nothing has proven to have more value to the development of Salt that the outstanding community that has been growing at such a great pace around Salt. This has proven not only that Salt has great value, but also the expandability of Salt is as exponential as I originally intended.

0.9.5 has received over 600 additional commits since 0.9.4 with a swath of new commiters. The following individuals have contributed to the development of 0.9.5:

•   Aaron Bull Schaefer

•   Antti Kaihola

•   Bas Tichelaar

•   Brad Barden

•   Brian Wagner

•   Byron Clark

•   Chris Scheller

•   Christer Edwards

•   Clint Savage

•   Corey Quinn

•   David Boucha

•   Eivind Uggedal

•   Eric Poelke

•   Evan Borgstrom

•   Jed Glazner

•   Jeff Schroeder

•   Jeffrey C. Ollie

•   Jonas Buckner

•   Kent Tenney

•   Martin Schnabel

•   Maxim Burgerhout

•   Mitch Anderson

•   Nathaniel Whiteinge

•   Seth House

•   Thomas S Hatch

•   Thomas Schreiber

•   Tor Hveem

•   lzyeval

•   syphernl

    This makes 21 new developers since 0.9.4 was released!

    To keep up with the growing community follow Salt on Ohloh (http://www.ohloh.net/p/salt), to join the Salt development community, fork Salt on Github, and get coding (https://github.com/saltstack/salt)!

  Major Features

  SPEED! Pickle to msgpack

For a few months now we have been talking about moving away from Python pickles for network serialization, but a preferred serialization format had not yet been found. After an extensive performance testing period involving everything from JSON to protocol buffers, a clear winner emerged. Message Pack (http://msgpack.org/) proved to not only be the fastest and most compact, but also the most "salt like". Message Pack is simple, and the code involved is very small. The msgpack library for Python has been added directly to Salt.

This move introduces a few changes to Salt. First off, Salt is no longer a "noarch" package, since the msgpack lib is written in C. Salt 0.9.5 will also have compatibility issues with 0.9.4 with the default configuration.

We have gone through great lengths to avoid backwards compatibility issues with Salt, but changing the serialization medium was going to create issues regardless. Salt 0.9.5 is somewhat backwards compatible with earlier minions. A 0.9.5 master can command older minions, but only if the serial config value in the master is set to pickle. This will tell the master to publish messages in pickle format and will allow the master to receive messages in both msgpack and pickle formats.

Therefore the suggested methods for upgrading are either to just upgrade everything at once, or:

1.  Upgrade the master to 0.9.5

2.  Set serial to pickle in the master config

3.  Upgrade the minions

4.  Remove the serial option from the master config

    Since pickles can be used as a security exploit the ability for a master to accept pickles from minions at all will be removed in a future release.

  C Bindings for YAML

All of the YAML rendering is now done with the YAML C bindings. This speeds up all of the sls files when running states.

  Experimental Windows Support

David Boucha has worked tirelessly to bring initial support to Salt for Microsoft Windows operating systems. Right now the Salt Minion can run as a native Windows service and accept commands.

In the weeks and months to come Windows will receive the full treatment and will have support for Salt States and more robust support for managing Windows systems. This is a big step forward for Salt to move entirely outside of the Unix world, and proves Salt is a viable cross platform solution. Big Thanks to Dave for his contribution here!

  Dynamic Module Distribution

Many Salt users have expressed the desire to have Salt distribute in-house modules, states, renderers, returners, and grains. This support has been added in a number of ways:

  Modules via States

Now when salt modules are deployed to a minion via the state system as a file, then the modules will be automatically loaded into the active running minion - no restart required - and into the active running state. So custom state modules can be deployed and used in the same state run.

  Modules via Module Environment Directories

Under the file_roots each environment can now have directories that are used to deploy large groups of modules. These directories sync modules at the beginning of a state run on the minion, or can be manually synced via the Salt module salt.modules.saltutil.sync_all.

The directories are named:

•   _modules

•   _states

•   _grains

•   _renderers

•   _returners

    The modules are pushed to their respective scopes on the minions.

  Module Reloading

Modules can now be reloaded without restarting the minion, this is done by calling the salt.modules.sys.reload_modules function.

But wait, there's more! Now when a salt module of any type is added via states the modules will be automatically reloaded, allowing for modules to be laid down with states and then immediately used.

Finally, all modules are reloaded when modules are dynamically distributed from the salt master.

  Enable / Disable Added to Service

A great deal of demand has existed for adding the capability to set services to be started at boot in the service module. This feature also comes with an overhaul of the service modules and initial systemd support.

This means that the service state can now accept - enable: True to make sure a service is enabled at boot, and - enable: False to make sure it is disabled.

  Compound Target

A new target type has been added to the lineup, the compound target. In previous versions the desired minions could only be targeted via a single specific target type, but now many target specifications can be declared.

These targets can also be separated by and/or operators, so certain properties can be used to omit a node:

salt -C 'webserv* and G@os:Debian or E@db.*' test.ping

will match all minions with ids starting with webserv via a glob and minions matching the os:Debian grain. Or minions that match the db.* regular expression.

  Node Groups

Often the convenience of having a predefined group of minions to execute targets on is desired. This can be accomplished with the new nodegroups feature. Nodegroups allow for predefined compound targets to be declared in the master configuration file:

nodegroups:
  group1: 'L@foo.domain.com,bar.domain.com,baz.domain.com and bl*.domain.com'
  group2: 'G@os:Debian and foo.domain.com'

And then used via the -N option:

salt -N group1 test.ping

  Minion Side Data Store

The data module introduces the initial approach into storing persistent data on the minions, specific to the minions. This allows for data to be stored on minions that can be accessed from the master or from the minion.

The Minion datastore is young, and will eventually provide an interface similar to a more mature key/value pair server.

  Major Grains Improvement

The Salt grains have been overhauled to include a massive amount of extra data. this includes hardware data, os data and salt specific data.

  Salt -Q is Useful Now

In the past the salt query system, which would display the data from recent executions would be displayed in pure Python, and it was unreadable.

0.9.5 has added the outputter system to the -Q option, thus enabling the salt query system to return readable output.

  Packaging Updates

Huge strides have been made in packaging Salt for distributions. These additions are thanks to our wonderful community where the work to set up packages has proceeded tirelessly.

  FreeBSD

Salt on FreeBSD? There a port for that:

http://www.freebsd.org/cgi/cvsweb.cgi/ports/sysutils/salt/pkg-descr

This port was developed and added by Christer Edwards. This also marks the first time Salt has been included in an upstream packaging system!

  Fedora and Red Hat Enterprise

Salt packages have been prepared for inclusion in the Fedora Project and in EPEL for Red Hat Enterprise 5 and 6. These packages are the result of the efforts made by Clint Savage (herlo).

  Debian/Ubuntu

A team of many contributors have assisted in developing packages for Debian and Ubuntu. Salt is still actively seeking inclusion in upstream Debian and Ubuntu and the package data that has been prepared is being pushed through the needed channels for inclusion.

These packages have been prepared with the help of:

•   Corey

•   Aaron Toponce

•   and`

  More to Come

We are actively seeking inclusion in more distributions. Primarily getting Salt into Gentoo, Suse, OpenBSD and preparing Solaris support are all turning into higher priorities.

  Refinement

Salt continues to be refined into a faster, more stable and more usable application. 0.9.5 comes with more debug logging, more bug fixes and more complete support.

  More Testing, More BugFixes

0.9.5 comes with more bugfixes due to more testing than any previous release. The growing community and the introduction a a dedicated QA environment have unearthed many issues that were hiding under the covers. This has further refined and cleaned the state interface, taking care of things from minor visual issues to repairing misleading data.

  Custom Exceptions

A custom exception module has been added to throw salt specific exceptions. This allows Salt to give much more granular error information.

  New Modules

  data

The new data module manages a persistent datastore on the minion. Big thanks to bastichelaar for his help refining this module

  freebsdkmod

FreeBSD kernel modules can now be managed in the same way Salt handles Linux kernel modules.

This module was contributed thanks to the efforts of Christer Edwards

  gentoo_service

Support has been added for managing services in Gentoo. Now Gentoo services can be started, stopped, restarted, enabled, disabled and viewed.

  pip

The pip module introduces management for pip installed applications. Thanks goes to whitinge for the addition of the pip module

  rh_service

The rh_service module enables Red Hat and Fedora specific service management. Now Red Hat like systems come with extensive management of the classic init system used by Red Hat

  saltutil

The saltutil module has been added as a place to hold functions used in the maintenance and management of salt itself. Saltutil is used to salt the salt minion. The saltutil module is presently used only to sync extension modules from the master server.

  systemd

Systemd support has been added to Salt, now systems using this next generation init system are supported on systems running systemd.

  virtualenv

The virtualenv module has been added to allow salt to create virtual Python environments. Thanks goes to whitinge for the addition of the virtualenv module

  win_disk

Support for gathering disk information on Microsoft Windows minions The windows modules come courtesy of Utah_Dave

  win_service

The win_service module adds service support to Salt for Microsoft Windows services

  win_useradd

Salt can now manage local users on Microsoft Windows Systems

  yumpkg5

The yumpkg module introduces in 0.9.4 uses the yum api to interact with the yum package manager. Unfortunately, on Red Hat 5 systems salt does not have access to the yum api because the yum api is running under Python 2.4 and Salt needs to run under Python 2.6.

The yumpkg5 module bypasses this issue by shelling out to yum on systems where the yum api is not available.

  New States

  mysql_database

The new mysql_database state adds the ability to systems running a mysql server to manage the existence of mysql databases.

The mysql states are thanks to syphernl

  mysql_user

The mysql_user state enables mysql user management.

  virtualenv

The virtualenv state can manage the state of Python virtual environments. Thanks to Whitinge for the virtualenv state

  New Returners

  cassandra_returner

A returner allowing Salt to send data to a cassandra server. Thanks to Byron Clark for contributing this returner

  Salt 0.9.6 Release Notes

Salt 0.9.6 is a release targeting a few bugs and changes. This is primarily targeting an issue found in the names declaration in the state system. But a few other bugs were also repaired, like missing support for grains in extmods.

Due to a conflict in distribution packaging msgpack will no longer be bundled with Salt, and is required as a dependency.

  New Features

  http and ftp support in files.managed

Now under the source option in the file.managed state a http or ftp address can be used instead of a file located on the salt master.

  Allow Multiple Returners

Now the returner interface can define multiple returners, and will also return data back to the master, making the process less ambiguous.

  Minion Memory Improvements

A number of modules have been taken out of the minion if the underlying systems required by said modules are not present on the minion system. A number of other modules need to be stripped out in this same way which should continue to make the minion more efficient.

  Minions Can Locally Cache Return Data

A new option, cache_jobs, has been added to the minion to allow for all of the historically run jobs to cache on the minion, allowing for looking up historic returns. By default cache_jobs is set to False.

  Pure Python Template Support For file.managed

Templates in the file.managed state can now be defined in a Python script. This script needs to have a run function that returns the string that needs to be in the named file.

  Salt 0.9.7 Release Notes

Salt 0.9.7 is here! The latest iteration of Salt brings more features and many fixes. This release is a great refinement over 0.9.6, adding many conveniences under the hood, as well as some features that make working with Salt much better.

A few highlights include the new Job system, refinements to the requisite system in states, the mod_init interface for states, external node classification, search path to managed files in the file state, and refinements and additions to dynamic module loading.

0.9.7 also introduces the long developed (and oft changed) unit test framework and the initial unit tests.

  Major Features

  Salt Jobs Interface

The new jobs interface makes the management of running executions much cleaner and more transparent. Building on the existing execution framework the jobs system allows clear introspection into the active running state of the running Salt interface.

The Jobs interface is centered in the new minion side proc system. The minions now store msgpack serialized files under /var/cache/salt/proc. These files keep track of the active state of processes on the minion.

  Functions in the saltutil Module

A number of functions have been added to the saltutil module to manage and view the jobs:

running - Returns the data of all running jobs that are found in the proc directory.

find_job - Returns specific data about a certain job based on job id.

signal_job - Allows for a given jid to be sent a signal.

term_job - Sends a termination signal (SIGTERM, 15) to the process controlling the specified job.

kill_job Sends a kill signal (SIGKILL, 9) to the process controlling the specified job.

  The jobs Runner

A convenience runner front end and reporting system has been added as well. The jobs runner contains functions to make viewing data easier and cleaner.

The jobs runner contains a number of functions...

  active

The active function runs saltutil.running on all minions and formats the return data about all running jobs in a much more usable and compact format. The active function will also compare jobs that have returned and jobs that are still running, making it easier to see what systems have completed a job and what systems are still being waited on.

  lookup_jid

When jobs are executed the return data is sent back to the master and cached. By default is is cached for 24 hours, but this can be configured via the keep_jobs option in the master configuration.

Using the lookup_jid runner will display the same return data that the initial job invocation with the salt command would display.

  list_jobs

Before finding a historic job, it may be required to find the job id. list_jobs will parse the cached execution data and display all of the job data for jobs that have already, or partially returned.

  External Node Classification

Salt can now use external node classifiers like Cobbler's cobbler-ext-nodes.

Salt uses specific data from the external node classifier. In particular the classes value denotes which sls modules to run, and the environment value sets to another environment.

An external node classification can be set in the master configuration file via the external_nodes option: http://salt.readthedocs.org/en/latest/ref/configuration/master.html#external-nodes

External nodes are loaded in addition to the top files. If it is intended to only use external nodes, do not deploy any top files.

  State Mod Init System

An issue arose with the pkg state. Every time a package was run Salt would need to refresh the package database. This made systems with slower package metadata refresh speeds much slower to work with. To alleviate this issue the mod_init interface has been added to salt states.

The mod_init interface is a function that can be added to a state file. This function is called with the first state called. In the case of the pkg state, the mod_init function sets up a tag which makes the package database only refresh on the first attempt to install a package.

In a nutshell, the mod_init interface allows a state to run any command that only needs to be run once, or can be used to set up an environment for working with the state.

  Source File Search Path

The file state continues to be refined, adding speed and capabilities. This release adds the ability to pass a list to the source option. This list is then iterated over until the source file is found, and the first found file is used.

The new syntax looks like this:

/etc/httpd/conf/httpd.conf:
  file:
    - managed
    - source:
      - salt://httpd/httpd.conf
      - http://myserver/httpd.conf: md5=8c1fe119e6f1fd96bc06614473509bf1

The source option can take sources in the list from the salt file server as well as an arbitrary web source. If using an arbitrary web source the checksum needs to be passed as well for file verification.

  Refinements to the Requisite System

A few discrepancies were still lingering in the requisite system, in particular, it was not possible to have a require and a watch requisite declared in the same state declaration.

This issue has been alleviated, as well as making the requisite system run more quickly.

  Initial Unit Testing Framework

Because of the module system, and the need to test real scenarios, the development of a viable unit testing system has been difficult, but unit testing has finally arrived. Only a small amount of unit testing coverage has been developed, much more coverage will be in place soon.

A huge thanks goes out to those who have helped with unit testing, and the contributions that have been made to get us where we are. Without these contributions unit tests would still be in the dark.

  Compound Targets Expanded

Originally only support for and and or were available in the compound target. 0.9.7 adds the capability to negate compound targets with not.

  Nodegroups in the Top File

Previously the nodegroups defined in the master configuration file could not be used to match nodes for states. The nodegroups support has been expanded and the nodegroups defined in the master configuration can now be used to match minions in the top file.

  Salt 0.9.8 Release Notes

Salt 0.9.8 is a big step forward, with many additions and enhancements, as well as a number of precursors to advanced future developments.

This version of Salt adds much more power to the command line, making the old hard timeout issues a thing of the past and adds keyword argument support. These additions are also available in the salt client api, making the available api tools much more powerful.

The new pillar system allows for data to be stored on the master and assigned to minions in a granular way similar to the state system. It also allows flexibility for users who want to keep data out of their state tree similar to 'external lookup' functionality in other tools.

A new way to extend requisites was added, the "requisite in" statement. This makes adding requires or watch statements to external state decs much easier.

Additions to requisites making them much more powerful have been added as well as improved error checking for sls files in the state system. A new provider system has been added to allow for redirecting what modules run in the background for individual states.

Support for OpenSUSE has been added and support for Solaris has begun serious development. Windows support has been significantly enhanced as well.

The matcher and target systems have received a great deal of attention. The default behavior of grain matching has changed slightly to reflect the rest of salt and the compound matcher system has been refined.

A number of impressive features with keyword arguments have been added to both the cli and to the state system. This makes states much more powerful and flexible while maintaining the simple configuration everyone loves.

The new batch size capability allows for executions to be rolled through a group of targeted minions a percentage or specific number at a time. This was added to prevent the "thundering herd" problem when targeting large numbers of minions for things like service restarts or file downloads.

  Upgrade Considerations

  Upgrade Issues

There was a previously missed oversight which could cause a newer minion to crash an older master. That oversight has been resolved so the version incompatibility issue will no longer occur. When upgrading to 0.9.8 make sure to upgrade the master first, followed by the minions.

  Debian/Ubuntu Packages

The original Debian/Ubuntu packages were called salt and included all salt applications. New packages in the ppa are split by function. If an old salt package is installed then it should be manually removed and the new split packages need to be freshly installed.

On the master:

# apt-get purge salt
# apt-get install salt-{master,minion}

On the minions:

# apt-get purge salt
# apt-get install salt-minion

And on any Syndics:

# apt-get install salt-syndic

The official salt stack ppa for Ubuntu is located at: https://launchpad.net/~saltstack/+archive/salt

  Major Features

  Pillar

Pillar offers an interface to declare variable data on the master that is then assigned to the minions. The pillar data is made available to all modules, states, sls files etc. It is compiled on the master and is declared using the existing renderer system. This means that learning pillar should be fairly trivial to those already familiar with salt states.

  CLI Additions

The salt command has received a serious overhaul and is more powerful than ever. Data is returned to the terminal as it is received, and the salt command will now wait for all running minions to return data before stopping. This makes adding very large --timeout arguments completely unnecessary and gets rid of long running operations returning empty {} when the timeout is exceeded.

When calling salt via sudo, the user originally running salt is saved to the log for auditing purposes. This makes it easy to see who ran what by just looking through the minion logs.

The salt-key command gained the -D and --delete-all arguments for removing all keys. Be careful with this one!

  Running States Without a Master

The addition of running states without a salt-master has been added to 0.9.8. This feature allows for the unmodified salt state tree to be read locally from a minion. The result is that the UNMODIFIED state tree has just become portable, allowing minions to have a local copy of states or to manage states without a master entirely.

This is accomplished via the new file client interface in Salt that allows for the salt:// uri to be redirected to custom interfaces. This means that there are now two interfaces for the salt file server, calling the master or looking in a local, minion defined file_roots.

This new feature can be used by modifying the minion config to point to a local file_roots and setting the file_client option to local.

  Keyword Arguments and States

State modules now accept the **kwargs argument. This results in all data in a sls file assigned to a state being made available to the state function.

This passes data in a transparent way back to the modules executing the logic. In particular, this allows adding arguments to the pkg.install module that enable more advanced and granular controls with respect to what the state is capable of.

An example of this along with the new debconf module for installing ldap client packages on Debian:

ldap-client-packages:
  pkg:
    - debconf: salt://debconf/ldap-client.ans
    - installed
    - names:
      - nslcd
      - libpam-ldapd
      - libnss-ldapd

  Keyword Arguments and the CLI

In the past it was required that all arguments be passed in the proper order to the salt and salt-call commands. As of 0.9.8, keyword arguments can be passed in the form of kwarg=argument.

# salt -G 'type:dev' git.clone \
    repository=https://github.com/saltstack/salt.git cwd=/tmp/salt user=jeff

  Matcher Refinements and Changes

A number of fixes and changes have been applied to the Matcher system. The most noteworthy is the change in the grain matcher. The grain matcher used to use a regular expression to match the passed data to a grain, but now defaults to a shell glob like the majority of match interfaces in Salt. A new option is available that still uses the old style regex matching to grain data called grain-pcre. To use regex matching in compound matches use the letter P.

For example, this would match any ArchLinux or Fedora minions:

# salt --grain-pcre 'os:(Arch:Fed).*' test.ping

And the associated compound matcher suitable for top.sls is P:

P@os:(Arch|Fed).*

NOTE: Changing the grains matcher from pcre to glob is backwards incompatible.

Support has been added for matching minions with Yahoo's range library. This is handled by passing range syntax with -R or --range arguments to salt.

More information at: https://github.com/grierj/range/wiki/Introduction-to-Range-with-YAML-files

  Requisite in

A new means to updating requisite statements has been added to make adding watchers and requires to external states easier. Before 0.9.8 the only way to extend the states that were watched by a state outside of the sls was to use an extend statement:

include:
  - http
extend:
  apache:
    service:
      - watch:
        - pkg: tomcat
tomcat:
  pkg:
    - installed

But the new Requisite in statement allows for easier extends for requisites:

include:
  - http
tomcat:
  pkg:
    - installed
    - watch_in:
      - service: apache

Requisite in is part of the extend system, so still remember to always include the sls that is being extended!

  Providers

Salt predetermines what modules should be mapped to what uses based on the properties of a system. These determinations are generally made for modules that provide things like package and service management. The apt module maps to pkg on Debian and the yum module maps to pkg on Fedora for instance.

Sometimes in states, it may be necessary for a non-default module to be used for the desired functionality. For instance, an Arch Linux system may have been set up with systemd support. Instead of using the default service module detected for Arch Linux, the systemd module can be used:

http:
  service:
    - running
    - enable: True
    - provider: systemd

Default providers can also be defined in the minion config file:

providers:
  pkg: yumpkg5
  service: systemd

When default providers are passed in the minion config, then those providers will be applied to all functionality in Salt, this means that the functions called by the minion will use these modules, as well as states.

  Requisite Glob Matching

Requisites can now be defined with glob expansion. This means that if there are many requisites, they can be defined on a single line.

To watch all files in a directory:

http:
  service:
    - running
    - enable: True
    - watch:
      - file: /etc/http/conf.d/*

This example will watch all defined files that match the glob /etc/http/conf.d/*

  Batch Size

The new batch size option allows commands to be executed while maintaining that only so many hosts are executing the command at one time. This option can take a percentage or a finite number:

salt \* -b 10 test.ping
salt -G 'os:RedHat' --batch-size 25% apache.signal restart

This will only run test.ping on 10 of the targeted minions at a time and then restart apache on 25% of the minions matching os:RedHat at a time and work through them all until the task is complete. This makes jobs like rolling web server restarts behind a load balancer or doing maintenance on BSD firewalls using carp much easier with salt.

  Module Updates

This is a list of notable, but non-exhaustive updates with new and existing modules.

Windows support has seen a flurry of support this release cycle. We've gained all new file, network, and shadow modules. Please note that these are still a work in progress.

For our ruby users, new rvm and gem modules have been added along with the associated states

The virt module gained basic Xen support.

The yum pkg modules gained Scientific Linux support.

The pkg module on Debian, Ubuntu, and derivatives force apt to run in a non-interactive mode. This prevents issues when package installation waits for confirmation.

A pkg module for OpenSUSE's zypper was added.

The service module on ubuntu natively supports upstart.

A new debconf module was contributed by our community for more advanced control over deb package deployments on Debian based distributions.

The mysql.user state and mysql module gained a password_hash argument.

The cmd module and state gained a shell keyword argument for specifying a shell other than /bin/sh on Linux / Unix systems.

New git and mercurial modules have been added for fans of distributed version control.

  In Progress Development

  Master Side State Compiling

While we feel strongly that the advantages gained with minion side state compiling are very critical, it does prevent certain features that may be desired. 0.9.8 has support for initial master side state compiling, but many more components still need to be developed, it is hoped that these can be finished for 0.9.9.

The goal is that states can be compiled on both the master and the minion allowing for compilation to be split between master and minion. Why will this be great? It will allow storing sensitive data on the master and sending it to some minions without all minions having access to it. This will be good for handling ssl certificates on front-end web servers for instance.

  Solaris Support

Salt 0.9.8 sees the introduction of basic Solaris support. The daemon runs well, but grains and more of the modules need updating and testing.

  Windows Support

Salt states on windows are now much more viable thanks to contributions from our community! States for file, service, local user, and local group management are more fully fleshed out along with network and disk modules. Windows users can also now manage registry entries using the new "reg" module.

  Salt 0.9.9 Release Notes

0.9.9 is out and comes with some serious bug fixes and even more serious features. This release is the last major feature release before 1.0.0 and could be considered the 1.0.0 release candidate.

A few updates include more advanced kwargs support, the ability for salt states to more safely configure a running salt minion, better job directory management and the new state test interface.

Many new tests have been added as well, including the new minion swarm test that allows for easier testing of Salt working with large groups of minions. This means that if you have experienced stability issues with Salt before, particularly in larger deployments, that these bugs have been tested for, found, and killed.

  Major Features

  State Test Interface

Until 0.9.9 the only option when running states to see what was going to be changed was to print out the highstate with state.show_highstate and manually look it over. But now states can be run to discover what is going to be changed.

Passing the option test=True to many of the state functions will now cause the salt state system to only check for what is going to be changed and report on those changes.

# salt \* state.highstate test=True

Now states that would have made changes report them back in yellow.

  State Syntax Update

A shorthand syntax has been added to sls files, and it will be the default syntax in documentation going forward. The old syntax is still fully supported and will not be deprecated, but it is recommended to move to the new syntax in the future. This change moves the state function up into the state name using a dot notation. This is in-line with how state functions are generally referred to as well:

The new way:

/etc/sudoers:
  file.present:
    - source: salt://sudo/sudoers
    - user: root
    - mode: 400

  Use and Use_in Requisites

Two new requisite statements are available in 0.9.9. The use and use_in requisite and requisite-in allow for the transparent duplication of data between states. When a state "uses" another state it copies the other state's arguments as defaults. This was created in direct response to the new network state, and allows for many network interfaces to be configured in the same way easily. A simple example:

root_file:
  file.absent:
    - name: /tmp/nothing
    - user: root
    - mode: 644
    - group: root
    - use_in:
      - file: /etc/vimrc
fred_file:
  file.absent:
    - name: /tmp/nothing
    - user: fred
    - group: marketing
    - mode: 660
/files/marketing/district7.rst:
  file.present:
    - source: salt://marketing/district7.rst
    - template: jinja
    - use:
      - file: fred_file
/etc/vimrc:
  file.present:
    - source: salt://edit/vimrc

This makes the 2 lower state decs inherit the options from their respectively "used" state decs.

  Network State

The new network state allows for the configuration of network devices via salt states and the ip salt module. This addition has been given to the project by Jeff Hutchins and Bret Palsson from Jive Communications.

Currently the only network configuration backend available is for Red Hat based systems, like Red Hat Enterprise, CentOS, and Fedora.

  Exponential Jobs

Originally the jobs executed were stored on the master in the format: <cachedir>/jobs/jid/{minion ids} But this format restricted the number of jobs in the cache to the number of subdirectories allowed on the filesystem. Ext3 for instance limits subdirectories to 32000. To combat this the new format for 0.9.9 is: <cachedir>/jobs/jid_hash[:2]/jid_hash[2:]/{minion ids} So that now the number of maximum jobs that can be run before the cleanup cycle hits the job directory is substantially higher.

  ssh_auth Additions

The original ssh_auth state was limited to accepting only arguments to apply to a public key, and the key itself. This was restrictive due to the way the we learned that many people were using the state, so the key section has been expanded to accept options and arguments to the key that over ride arguments passed in the state. This gives substantial power to using ssh_auth with names:

sshkeys:
  ssh_auth:
    - present
    - user: backup
    - enc: ssh-dss
    - options:
      - option1="value1"
      - option2="value2 flag2"
    - comment: backup
    - names:
      - AAAAB3NzaC1yc2EAAAABIwAAAQEAlyE26SMFFVY5YJvnL7AF5CRTPtAigSW1U887ASfBt6FDa7Qr1YdO5ochiLoz8aSiMKd5h4dhB6ymHbmntMPjQena29jQjXAK4AK0500rMShG1Y1HYEjTXjQxIy/SMjq2aycHI+abiVDn3sciQjsLsNW59t48Udivl2RjWG7Eo+LYiB17MKD5M40r5CP2K4B8nuL+r4oAZEHKOJUF3rzA20MZXHRQuki7vVeWcW7ie8JHNBcq8iObVSoruylXav4aKG02d/I4bz/l0UdGh18SpMB8zVnT3YF5nukQQ/ATspmhpU66s4ntMehULC+ljLvZL40ByNmF0TZc2sdSkA0111==
      - AAAAB3NzaC1yc2EAAAABIwAAAQEAlyE26SMFFVY5YJvnL7AF5CRTPtAigSW1U887ASfBt6FDa7Qr1YdO5ochiLoz8aSiMKd5h4dhB6ymHbmntMPjQena29jQjXAK4AK0500rMShG1Y1HYEjTXjQxIy/SMjq2aycHI+abiVDn3sciQjsLsNW59t48Udivl2RjWG7Eo+LYiB17MKD5M40r5CP2K4B8nuL+r4oAZEHKOJUF3rzA20MZXHRQuki7vVeWcW7ie8JHNBcq8iObVSoruylXav4aKG02d/I4bz/l0UdGh18SpMB8zVnT3YF5nukQQ/ATspmhpU66s4ntMehULC+ljLvZL40ByNmF0TZc2sdSkA0222== override
      - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAlyE26SMFFVY5YJvnL7AF5CRTPtAigSW1U887ASfBt6FDa7Qr1YdO5ochiLoz8aSiMKd5h4dhB6ymHbmntMPjQena29jQjXAK4AK0500rMShG1Y1HYEjTXjQxIy/SMjq2aycHI+abiVDn3sciQjsLsNW59t48Udivl2RjWG7Eo+LYiB17MKD5M40r5CP2K4B8nuL+r4oAZEHKOJUF3rzA20MZXHRQuki7vVeWcW7ie8JHNBcq8iObVSoruylXav4aKG02d/I4bz/l0UdGh18SpMB8zVnT3YF5nukQQ/ATspmhpU66s4ntMehULC+ljLvZL40ByNmF0TZc2sdSkA0333== override
      - ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAlyE26SMFFVY5YJvnL7AF5CRTPtAigSW1U887ASfBt6FDa7Qr1YdO5ochiLoz8aSiMKd5h4dhB6ymHbmntMPjQena29jQjXAK4AK0500rMShG1Y1HYEjTXjQxIy/SMjq2aycHI+abiVDn3sciQjsLsNW59t48Udivl2RjWG7Eo+LYiB17MKD5M40r5CP2K4B8nuL+r4oAZEHKOJUF3rzA20MZXHRQuki7vVeWcW7ie8JHNBcq8iObVSoruylXav4aKG02d/I4bz/l0UdGh18SpMB8zVnT3YF5nukQQ/ATspmhpU66s4ntMehULC+ljLvZL40ByNmF0TZc2sdSkA0444==
      - option3="value3",option4="value4 flag4" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAlyE26SMFFVY5YJvnL7AF5CRTPtAigSW1U887ASfBt6FDa7Qr1YdO5ochiLoz8aSiMKd5h4dhB6ymHbmntMPjQena29jQjXAK4AK0500rMShG1Y1HYEjTXjQxIy/SMjq2aycHI+abiVDn3sciQjsLsNW59t48Udivl2RjWG7Eo+LYiB17MKD5M40r5CP2K4B8nuL+r4oAZEHKOJUF3rzA20MZXHRQuki7vVeWcW7ie8JHNBcq8iObVSoruylXav4aKG02d/I4bz/l0UdGh18SpMB8zVnT3YF5nukQQ/ATspmhpU66s4ntMehULC+ljLvZL40ByNmF0TZc2sdSkA0555== override
      - option3="value3" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAlyE26SMFFVY5YJvnL7AF5CRTPtAigSW1U887ASfBt6FDa7Qr1YdO5ochiLoz8aSiMKd5h4dhB6ymHbmntMPjQena29jQjXAK4AK0500rMShG1Y1HYEjTXjQxIy/SMjq2aycHI+abiVDn3sciQjsLsNW59t48Udivl2RjWG7Eo+LYiB17MKD5M40r5CP2K4B8nuL+r4oAZEHKOJUF3rzA20MZXHRQuki7vVeWcW7ie8JHNBcq8iObVSoruylXav4aKG02d/I4bz/l0UdGh18SpMB8zVnT3YF5nukQQ/ATspmhpU66s4ntMehULC+ljLvZL40ByNmF0TZc2sdSkA0666==

  LocalClient Additions

To follow up the recent additions in 0.9.8 of additional kwargs support, 0.9.9 also adds the capability to send kwargs into commands via a dict. This addition to the LocalClient api can be used like so:

import salt.client
client = salt.client.LocalClient('/etc/salt/master')
ret = client.cmd('*', 'cmd.run', ['ls -l'], kwarg={'cwd': '/etc'})

This update has been added to all cmd methods in the LocalClient class.

  Better Self Salting

One problem faced with running Salt states, is that it has been difficult to manage the Salt minion via states, this is due to the fact that if the minion is called to restart while a state run is happening then the state run would be killed. 0.9.9 slightly changes the process scope of the state runs, so now when salt is executing states it can safely restart the salt-minion daemon.

In addition to daemonizing the state run, the apt module also daemonizes. This update makes it possible to cleanly update the salt-minion package on Debian/Ubuntu systems without leaving apt in an inconsistent state or killing the active minion process mid-execution.

  Wildcards for SLS Modules

Now, when including sls modules in include statements or in the top file, shell globs can be used. This can greatly simplify listing matched sls modules in the top file and include statements:

base:
  '*':
    - files*
    - core*

include:
  - users.dev.*
  - apache.ser*

  External Pillar

Since the pillar data is just, data, it does not need to come expressly from the pillar interface. The external pillar system allows for hooks to be added making it possible to extract pillar data from any arbitrary external interface. The external pillar interface is configured via the ext_pillar option. Currently interfaces exist to gather external pillar data via hiera or via a shell command that sends yaml data to the terminal:

ext_pillar:
  - cmd_yaml: cat /etc/salt/ext.yaml
  - hiera: /etc/hirea.yaml

The initial external pillar interfaces and extra interfaces can be added to the file salt/pillar.py, it is planned to add more external pillar interfaces. If the need arises a new module loader interface will be created in the future to manage external pillar interfaces.

  Single State Executions

The new state.single function allows for single states to be cleanly executed. This is a great tool for setting up a small group of states on a system or for testing out the behavior of single states:

# salt \* state.single user.present name=wade uid=2000

The test interface functions here as well, so changes can also be tested against as:

# salt \* state.single user.present name=wade uid=2000 test=True

  New Tests

A few exciting new test interfaces have been added, the minion swarm allows not only testing of larger loads, but also allows users to see how Salt behaves with large groups of minions without having to create a large deployment.

  Minion Swarm

The minion swarm test system allows for large groups of minions to be tested against easily without requiring large numbers of servers or virtual machines. The minion swarm creates as many minions as a system can handle and roots them in the /tmp directory and connects them to a master.

The benefit here is that we were able to replicate issues that happen only when there are large numbers of minions. A number of elusive bugs which were causing stability issues in masters and minions have since been hunted down. Bugs that used to take careful watch by users over several days can now be reliably replicated in minutes, and fixed in minutes.

Using the swarm is easy, make sure a master is up for the swarm to connect to, and then use the minionswarm.py script in the tests directory to spin up as many minions as you want. Remember, this is a fork bomb, don't spin up more than your hardware can handle!

# python minionswarm.py -m 20 --master salt-master

  Shell Tests

The new Shell testing system allows us to test the behavior of commands executed from a high level. This allows for the high level testing of salt runners and commands like salt-key.

  Client Tests

Tests have been added to test the aspects of the client apis and ensure that the client calls work, and that they manage passed data, in a desirable way.

AUTHOR
Thomas S. Hatch <thatch@gmail.com> and many others, please see the Authors file

COPYRIGHT
2012, Thomas S. Hatch