.\" Man page generated from reStructuredText. . .TH "SALT" "7" "September 18, 2013" "0.17.0" "Salt" .SH NAME salt \- Salt Documentation . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH FREQUENTLY ASKED QUESTIONS .SS Is Salt open\-core? .sp No. Salt is 100% committed to being open\-source, including all of our APIs and the new \fI\%\(aqHalite\(aq web interface\fP which will be included in version 0.17.0. It is developed under the \fI\%Apache 2.0 license\fP, allowing it to be used in both open and proprietary projects. .SS What ports should I open on my firewall? .sp Minions need to be able to connect to the Master on TCP ports 4505 and 4506. Minions do not need any inbound ports open. More detailed information on firewall settings can be found \fBhere\fP\&. .SS My script runs every time I run a \fBstate.highstate\fP\&. Why? .sp You are probably using \fBcmd.run\fP rather than \fBcmd.wait\fP\&. A \fBcmd.wait\fP state will only run when there has been a change in a state that it is watching. .sp A \fBcmd.run\fP state will run the corresponding command \fIevery time\fP (unless it is prevented from running by the \fBunless\fP or \fBonlyif\fP arguments). .sp More details can be found in the docmentation for the \fBcmd\fP states. .SS When I run \fBtest.ping\fP, why do the Minions that aren\(aqt responding return anything? Returning \fBFalse\fP would be helpful. .sp The reason for this is because the Master tells Minions to run commands/functions, and listens for the return data, printing it to the screen when it is received. If it doesn\(aqt receive anything back, it doesn\(aqt have anything to display for that Minion. .sp There are a couple options for getting information on Minions that are not responding. One is to use the verbose (\fB\-v\fP) option when you run salt commands, as it will display "Minion did not return" for any Minions which time out. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-v \(aq*\(aq pkg.install zsh .ft P .fi .UNINDENT .UNINDENT .sp Another option is to use the \fBmanage.down\fP runner: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-run manage.down .ft P .fi .UNINDENT .UNINDENT .SS How does Salt determine the Minion\(aqs id? .sp If the Minion id is not configured explicitly (using the \fBid\fP parameter), Salt will determine the id based on the hostname. Exactly how this is determined varies a little between operating systems and is described in detail \fIhere\fP\&. .SS I\(aqm using gitfs and my custom modules/states/etc are not syncing. Why? .sp In versions of Salt 0.16.3 or older, there is a bug in \fBgitfs\fP which can affect the syncing of custom types. Upgrading to 0.16.4 or newer will fix this. .SS Why aren\(aqt my custom modules/states/etc. available on my Minions? .sp Custom modules are only synced to Minions when \fBstate.highstate\fP, \fBsaltutil.sync_modules\fP, or \fBsaltutil.sync_all\fP is run. Similarly, custom states are only synced to Minions when \fBstate.highstate\fP, \fBsaltutil.sync_states\fP, or \fBsaltutil.sync_all\fP is run. .sp Other custom types (renderers, outputters, etc.) have similar behavior, see the documentation for the \fBsaltutil\fP module for more information. .SS Module \fBX\fP isn\(aqt available, even though the shell command it uses is installed. Why? .sp This is most likely a PATH issue. Did you custom\-compile the software which the module requires? RHEL/CentOS/etc. in particular override the root user\(aqs path in \fB/etc/init.d/functions\fP, setting it to \fB/sbin:/usr/sbin:/bin:/usr/bin\fP, making software installed into \fB/usr/local/bin\fP unavailable to Salt when the Minion is started using the initscript. In version 0.18.0, Salt will have a better solution for these sort of PATH\-related issues, but recompiling the software to install it into a location within the PATH should resolve the issue in the meantime. Alternatively, you can create a symbolic link within the PATH using a \fBfile.symlink\fP state. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /usr/bin/foo: file.symlink: \- target: /usr/local/bin/foo .ft P .fi .UNINDENT .UNINDENT .SH INTRODUCTION TO SALT We’re not just talking about NaCl..SS The 30 second summary .sp Salt is: .INDENT 0.0 .IP \(bu 2 a configuration management system, capable of maintaining remote nodes in defined states (for example, ensuring that specific packages are installed and specific services are running) .IP \(bu 2 a distributed remote execution system used to execute commands and query data on remote nodes, either individually or by arbitrary selection criteria .UNINDENT .sp 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. .SS Simplicity .sp Providing 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. .SS Parallel execution .sp The core functions of Salt: .INDENT 0.0 .IP \(bu 2 enable commands to remote systems to be called in parallel rather than serially .IP \(bu 2 use a secure and encrypted protocol .IP \(bu 2 use the smallest and fastest network payloads possible .IP \(bu 2 provide a simple programming interface .UNINDENT .sp Salt also introduces more granular controls to the realm of remote execution, allowing systems to be targeted not just by hostname, but also by system properties. .SS Building on proven technology .sp Salt takes advantage of a number of technologies and techniques. The networking layer is built with the excellent \fI\%ZeroMQ\fP networking library, so the Salt daemon includes a viable and transparent AMQ broker. Salt uses public keys for authentication with the master daemon, then uses faster \fI\%AES\fP encryption for payload communication; authentication and encryption are integral to Salt. Salt takes advantage of communication via \fI\%msgpack\fP, enabling fast and light network traffic. .SS Python client interface .sp In order to allow for simple expansion, Salt execution routines can be written as plain Python modules. 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. .SS Fast, flexible, scalable .sp The result is a system that can execute commands at high speed on target server groups ranging from one to very many servers. Salt is very fast, easy to set up, amazingly malleable and provides a single remote execution architecture that can manage the diverse requirements of any number of servers. The Salt infrastructure brings together the best of the remote execution world, amplifies its capabilities and expands its range, resulting in a system that is as versatile as it is practical, suitable for any network. .SS Open .sp Salt is developed under the \fI\%Apache 2.0 license\fP, 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. Please feel free to sprinkle Salt around your systems and let the deliciousness come forth. .SH INSTALLATION .sp The Salt system setup is amazingly simple, as this is one of the central design goals of Salt. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fBInstalling Salt for development\fP and contributing to the project. .UNINDENT .UNINDENT .SS Quick Install .sp Many popular distributions will be able to install the salt minion by executing the bootstrap script: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C wget \-O \- http://bootstrap.saltstack.org | sudo sh .ft P .fi .UNINDENT .UNINDENT .sp Run the following script to install just the Salt Master: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C curl \-L http://bootstrap.saltstack.org | sudo sh \-s \-\- \-M \-N .ft P .fi .UNINDENT .UNINDENT .sp The script should also make it simple to install a salt master, if desired. .sp Currently the install script has been tested to work on: .INDENT 0.0 .IP \(bu 2 Ubuntu 10.x/11.x/12.x .IP \(bu 2 Debian 6.x .IP \(bu 2 CentOS 6.3 .IP \(bu 2 Fedora .IP \(bu 2 Arch .IP \(bu 2 FreeBSD 9.0 .UNINDENT .sp See \fI\%Salt Bootstrap\fP for more information. .SS Platform\-specific installation instructions .sp These guides go into detail how to install salt on a given platform. .SS Arch Linux .SS Installation .sp Salt is currently available via the Arch User Repository (AUR). There are currently stable and \-git packages available. .SS Stable Release .sp Install Salt stable releases from the Arch Linux AUR as follows: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C wget https://aur.archlinux.org/packages/sa/salt/salt.tar.gz tar xf salt.tar.gz cd salt/ makepkg \-is .ft P .fi .UNINDENT .UNINDENT .sp A few of Salt\(aqs dependencies are currently only found within the AUR, so it is necessary to download and run \fBmakepkg \-is\fP on these as well. As a reference, Salt currently relies on the following packages which are only available via the AUR: .INDENT 0.0 .IP \(bu 2 \fI\%https://aur.archlinux.org/packages/py/python2\-msgpack/python2\-msgpack.tar.gz\fP .IP \(bu 2 \fI\%https://aur.archlinux.org/packages/py/python2\-psutil/python2\-psutil.tar.gz\fP .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 yaourt .sp If a tool such as \fI\%Yaourt\fP is used, the dependencies will be gathered and built automatically. .sp The command to install salt using the yaourt tool is: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yaourt salt .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Tracking develop .sp To install the bleeding edge version of Salt (\fBmay include bugs!\fP), use the \-git package. Installing the \-git package as follows: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C wget https://aur.archlinux.org/packages/sa/salt\-git/salt\-git.tar.gz tar xf salt\-git.tar.gz cd salt\-git/ makepkg \-is .ft P .fi .UNINDENT .UNINDENT .sp See the note above about Salt\(aqs dependencies. .SS Post\-installation tasks .sp \fBsystemd\fP .sp Activate the Salt Master and/or Minion via \fBsystemctl\fP as follows: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C systemctl enable salt\-master.service systemctl enable salt\-minion.service .ft P .fi .UNINDENT .UNINDENT .sp \fBStart the Master\fP .sp Once you\(aqve completed all of these steps you\(aqre ready to start your Salt Master. You should be able to start your Salt Master now using the command seen here: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C systemctl start salt\-master .ft P .fi .UNINDENT .UNINDENT .sp Now go to the \fBConfiguring Salt\fP page. .SS Debian Installation .sp Currently the latest packages for Debian Old Stable, Stable and Unstable (Squeeze, Wheezy and Sid) are published in our (saltstack.com) debian repository. .SS Configure Apt .SS Squeeze (Old Stable) .sp For squeeze, you will need to enable the debian backports repository as well as the debian.saltstack.com repository. To do so, add the following to \fB/etc/apt/sources.list\fP or a file in \fB/etc/apt/sources.list.d\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C deb http://debian.saltstack.com/debian squeeze\-saltstack main deb http://backports.debian.org/debian\-backports squeeze\-backports main contrib non\-free .ft P .fi .UNINDENT .UNINDENT .SS Wheezy (Stable) .sp For wheezy, the following line is needed in either \fB/etc/apt/sources.list\fP or a file in \fB/etc/apt/sources.list.d\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C deb http://debian.saltstack.com/debian wheezy\-saltstack main .ft P .fi .UNINDENT .UNINDENT .SS Sid (Unstable) .sp For sid, the following line is needed in either \fB/etc/apt/sources.list\fP or a file in \fB/etc/apt/sources.list.d\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C deb http://debian.saltstack.com/debian unstable main .ft P .fi .UNINDENT .UNINDENT .SS Import the repository key. .sp You will need to import the key used for signing. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C wget \-q \-O\- "http://debian.saltstack.com/debian\-salt\-team\-joehealy.gpg.key" | apt\-key add \- .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 You can optionally verify the key integrity with \fBsha512sum\fP using the public key signature shown here. E.g: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C echo "b702969447140d5553e31e9701be13ca11cc0a7ed5fe2b30acb8491567560ee62f834772b5095d735dfcecb2384a5c1a20045f52861c417f50b68dd5ff4660e6 debian\-salt\-team\-joehealy.gpg.key" | sha512sum \-c .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Update the package database .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apt\-get update .ft P .fi .UNINDENT .UNINDENT .SS Install packages .sp Install the Salt master, minion, or syndic from the repository with the apt\-get command. These examples each install one daemon, but more than one package name may be given at a time: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apt\-get install salt\-master .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apt\-get install salt\-minion .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apt\-get install salt\-syndic .ft P .fi .UNINDENT .UNINDENT .SS Post\-installation tasks .sp Now, go to the \fBConfiguring Salt\fP page. .SS Notes .sp 1. These packages will be backported from the packages intended to be uploaded into debian unstable. This means that the packages will be built for unstable first and then backported over the next day or so. .sp 2. These packages will be tracking the released versions of salt rather than maintaining a stable fixed feature set. If a fixed version is what you desire, then either pinning or manual installation may be more appropriate for you. .sp 3. The version numbering and backporting process should provide clean upgrade paths between debian versions. .sp If you have any questions regarding these, please email the mailing list or look for joehh on irc. .SS Fedora .sp Beginning with version 0.9.4, Salt has been available in the primary Fedora repositories and \fI\%EPEL\fP\&. 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! .SS Installation .sp Salt can be installed using \fByum\fP and is available in the standard Fedora repositories. .SS Stable Release .sp Salt is packaged separately for the minion and the master. It is necessary only to install the appropriate package for the role the machine will play. Typically, there will be one master and multiple minions. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yum install salt\-master yum install salt\-minion .ft P .fi .UNINDENT .UNINDENT .SS Post\-installation tasks .sp \fBMaster\fP .sp To have the Master start automatically at boot time: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C systemctl enable salt\-master.service .ft P .fi .UNINDENT .UNINDENT .sp To start the Master: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C systemctl start salt\-master.service .ft P .fi .UNINDENT .UNINDENT .sp \fBMinion\fP .sp To have the Minion start automatically at boot time: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C systemctl enable salt\-minion.service .ft P .fi .UNINDENT .UNINDENT .sp To start the Minion: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C systemctl start salt\-minion.service .ft P .fi .UNINDENT .UNINDENT .sp Now go to the \fBConfiguring Salt\fP page. .SS FreeBSD .sp Salt was added to the FreeBSD ports tree Dec 26th, 2011 by Christer Edwards <\fI\%christer.edwards@gmail.com\fP>. It has been tested on FreeBSD 7.4, 8.2, 9.0 and 9.1 releases. .sp Salt is dependent on the following additional ports. These will be installed as dependencies of the \fBsysutils/py\-salt\fP port. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /devel/py\-yaml /devel/py\-pyzmq /devel/py\-Jinja2 /devel/py\-msgpack /security/py\-pycrypto /security/py\-m2crypto .ft P .fi .UNINDENT .UNINDENT .SS Installation .sp To install Salt from the FreeBSD ports tree, use the command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C make \-C /usr/ports/sysutils/py\-salt install clean .ft P .fi .UNINDENT .UNINDENT .SS Post\-installation tasks .sp \fBMaster\fP .sp Copy the sample configuration file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cp /usr/local/etc/salt/master.sample /usr/local/etc/salt/master .ft P .fi .UNINDENT .UNINDENT .sp \fBrc.conf\fP .sp Activate the Salt Master in \fB/etc/rc.conf\fP or \fB/etc/rc.conf.local\fP and add: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C + salt_master_enable="YES" .ft P .fi .UNINDENT .UNINDENT .sp \fBStart the Master\fP .sp Start the Salt Master as follows: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C service salt_master start .ft P .fi .UNINDENT .UNINDENT .sp \fBMinion\fP .sp Copy the sample configuration file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cp /usr/local/etc/salt/minion.sample /usr/local/etc/salt/minion .ft P .fi .UNINDENT .UNINDENT .sp \fBrc.conf\fP .sp Activate the Salt Minion in \fB/etc/rc.conf\fP or \fB/etc/rc.conf.local\fP and add: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C + salt_minion_enable="YES" + salt_minion_paths="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" .ft P .fi .UNINDENT .UNINDENT .sp \fBStart the Minion\fP .sp Start the Salt Minion as follows: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C service salt_minion start .ft P .fi .UNINDENT .UNINDENT .sp Now go to the \fBConfiguring Salt\fP page. .SS Gentoo .sp Salt can be easily installed on Gentoo via Portage: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C emerge app\-admin/salt .ft P .fi .UNINDENT .UNINDENT .SS Post\-installation tasks .sp Now go to the \fBConfiguring Salt\fP page. .SS OS X .SS Dependency Installation .sp ZeroMQ and swig need to be installed first. .sp For installs using \fI\%python installed via homebrew\fP, sudo should be unnecessary: .INDENT 0.0 .TP .B Using homebrew with \fI\%XCode Command Line Tool (XCode: Preferences: Downloads: Command Line Tools: Install)\fP pre\-installed: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C brew install python brew install swig brew install zmq pip install salt .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .TP .B This should pip install salt and its dependencies, such as: Jinja2 M2Crypto msgpack\-python pycrypto PyYAML pyzmq markupsafe .UNINDENT .sp Whereas when using macports, zmq, swig, and pip may need to be installed this way: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo port install py\-zmq sudo port install py27\-m2crypto sudo port install py27\-crypto sudo port install py27\-msgpack sudo port install swig\-python sudo port install py\-pip .ft P .fi .UNINDENT .UNINDENT .sp For installs using the OS X system python, pip install needs to use \(aqsudo\(aq: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo pip install salt .ft P .fi .UNINDENT .UNINDENT .SS Salt\-Master Customizations .sp To run salt\-master on OS X, the root user maxfiles limit must be increased: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo launchctl limit maxfiles 4096 8192 .ft P .fi .UNINDENT .UNINDENT .sp And sudo add this configuration option to the /etc/salt/master file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C max_open_files: 8192 .ft P .fi .UNINDENT .UNINDENT .sp Now the salt\-master should run without errors: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo /usr/local/share/python/salt\-master \-\-log\-level=all .ft P .fi .UNINDENT .UNINDENT .SS Post\-installation tasks .sp Now go to the \fBConfiguring Salt\fP page. .SS RHEL / CentOS / Scientific Linux / Amazon Linux / Oracle Linux .sp Beginning with version 0.9.4, Salt has been available in \fI\%EPEL\fP\&. It is installable using yum. Salt should work properly with all mainstream derivatives of RHEL, including CentOS, Scientific Linux, Oracle Linux and Amazon Linux. Report any bugs or issues to the salt GitHub project. .SS Installation .sp Salt and all dependencies have been accepted into the yum repositories for EPEL5 and EPEL6. The latest salt version can be found in epel\-testing, while an older but more tested version can be found in regular epel. .sp Example showing how to install salt from epel\-testing: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yum \-\-enablerepo=epel\-testing install salt\-minion .ft P .fi .UNINDENT .UNINDENT .sp On RHEL6, the proper Jinja package \(aqpython\-jinja2\(aq was moved from EPEL to the "RHEL Server Optional Channel". Verify this repository is enabled before installing salt on RHEL6. .sp Salt can be installed using \fByum\fP and is available in the standard Fedora repositories. .SS Enabling EPEL on RHEL .sp If EPEL is not enabled on your system, you can use the following commands to enable it. .sp For RHEL 5: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C rpm \-Uvh http://mirror.pnl.gov/epel/5/i386/epel\-release\-5\-4.noarch.rpm .ft P .fi .UNINDENT .UNINDENT .sp For RHEL 6: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C rpm \-Uvh http://ftp.linux.ncsu.edu/pub/epel/6/i386/epel\-release\-6\-8.noarch.rpm .ft P .fi .UNINDENT .UNINDENT .SS Stable Release .sp Salt is packaged separately for the minion and the master. It is necessary only to install the appropriate package for the role the machine will play. Typically, there will be one master and multiple minions. .sp On the salt\-master, run this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yum install salt\-master .ft P .fi .UNINDENT .UNINDENT .sp On each salt\-minion, run this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yum install salt\-minion .ft P .fi .UNINDENT .UNINDENT .SS Post\-installation tasks .sp \fBMaster\fP .sp To have the Master start automatically at boot time: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C chkconfig salt\-master on .ft P .fi .UNINDENT .UNINDENT .sp To start the Master: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C service salt\-master start .ft P .fi .UNINDENT .UNINDENT .sp \fBMinion\fP .sp To have the Minion start automatically at boot time: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C chkconfig salt\-minion on .ft P .fi .UNINDENT .UNINDENT .sp To start the Minion: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C service salt\-minion start .ft P .fi .UNINDENT .UNINDENT .sp Now go to the \fBConfiguring Salt\fP page. .SS Solaris .sp Salt was added to the OpenCSW package repository in September of 2012 by Romeo Theriault <\fI\%romeot@hawaii.edu\fP> at version 0.10.2 of Salt. It has mainly been tested on Solaris 10 (sparc), though it is built for and has been tested minimally on Solaris 10 (x86), Solaris 9 (sparc/x86) and 11 (sparc/x86). (Please let me know if you\(aqre using it on these platforms!) Most of the testing has also just focused on the minion, though it has verified that the master starts up successfully on Solaris 10. .sp Comments and patches for better support on these platforms is very welcome. .sp As of version 0.10.4, Solaris is well supported under salt, with all of the following working well: .INDENT 0.0 .IP 1. 3 remote execution .IP 2. 3 grain detection .IP 3. 3 service control with SMF .IP 4. 3 \(aqpkg\(aq states with \(aqpkgadd\(aq and \(aqpkgutil\(aq modules .IP 5. 3 cron modules/states .IP 6. 3 user and group modules/states .IP 7. 3 shadow password management modules/states .UNINDENT .sp Salt is dependent on the following additional packages. These will automatically be installed as dependencies of the \fBpy_salt\fP package.: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C py_yaml py_pyzmq py_jinja2 py_msgpack_python py_m2crypto py_crypto python .ft P .fi .UNINDENT .UNINDENT .SS Installation .sp To install Salt from the OpenCSW package repository you first need to install \fI\%pkgutil\fP assuming you don\(aqt already have it installed: .sp On Solaris 10: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pkgadd \-d http://get.opencsw.org/now .ft P .fi .UNINDENT .UNINDENT .sp On Solaris 9: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C wget http://mirror.opencsw.org/opencsw/pkgutil.pkg pkgadd \-d pkgutil.pkg all .ft P .fi .UNINDENT .UNINDENT .sp Once pkgutil is installed you\(aqll need to edit it\(aqs config file \fB/etc/opt/csw/pkgutil.conf\fP to point it at the unstable catalog: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \- #mirror=http://mirror.opencsw.org/opencsw/testing + mirror=http://mirror.opencsw.org/opencsw/unstable .ft P .fi .UNINDENT .UNINDENT .sp OK, time to install salt. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Update the catalog root> /opt/csw/bin/pkgutil \-U # Install salt root> /opt/csw/bin/pkgutil \-i \-y py_salt .ft P .fi .UNINDENT .UNINDENT .SS Minion Configuration .sp Now that salt is installed you can find it\(aqs configuration files in \fB/etc/opt/csw/salt/\fP\&. .sp You\(aqll want to edit the minion config file to set the name of your salt master server: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \- #master: salt + master: your\-salt\-server .ft P .fi .UNINDENT .UNINDENT .sp If you would like to use \fI\%pkgutil\fP as the default package provider for your Solaris minions, you can do so using the \fBproviders\fP option in the minion config file. .sp You can now start the salt minion like so: .sp On Solaris 10: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C svcadm enable salt\-minion .ft P .fi .UNINDENT .UNINDENT .sp On Solaris 9: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /etc/init.d/salt\-minion start .ft P .fi .UNINDENT .UNINDENT .sp You should now be able to log onto the salt master and check to see if the salt\-minion key is awaiting acceptance: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-key \-l un .ft P .fi .UNINDENT .UNINDENT .sp Accept the key: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-key \-a .ft P .fi .UNINDENT .UNINDENT .sp Run a simple test against the minion: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .SS Troubleshooting .sp Logs are in \fB/var/log/salt\fP .SS Ubuntu Installation .SS Add repository .sp The latest packages for Ubuntu are published in the saltstack PPA. If you have the \fBadd\-apt\-repository\fP utility, you can add the repository and import the key in one step: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo add\-apt\-repository ppa:saltstack/salt .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .IP "add\-apt\-repository: command not found?" .sp The \fBadd\-apt\-repository\fP command is not always present on Ubuntu systems. This can be fixed by installing \fIpython\-software\-properties\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo apt\-get install python\-software\-properties .ft P .fi .UNINDENT .UNINDENT .sp Note that since Ubuntu 12.10 (Raring Ringtail), \fBadd\-apt\-repository\fP is found in the \fIsoftware\-properties\-common\fP package, and is part of the base install. Thus, \fBadd\-apt\-repository\fP should be able to be used out\-of\-the\-box to add the PPA. .UNINDENT .UNINDENT .sp Alternately, manually add the repository and import the PPA key with these commands: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C echo deb http://ppa.launchpad.net/saltstack/salt/ubuntu \(galsb_release \-sc\(ga main | sudo tee /etc/apt/sources.list.d/saltstack.list wget \-q \-O\- "http://keyserver.ubuntu.com:11371/pks/lookup?op=get&search=0x4759FA960E27C0A6" | sudo apt\-key add \- .ft P .fi .UNINDENT .UNINDENT .sp After adding the repository, update the package management database: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo apt\-get update .ft P .fi .UNINDENT .UNINDENT .SS Install packages .sp Install the Salt master, minion, or syndic from the repository with the apt\-get command. These examples each install one daemon, but more than one package name may be given at a time: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo apt\-get install salt\-master .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo apt\-get install salt\-minion .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo apt\-get install salt\-syndic .ft P .fi .UNINDENT .UNINDENT .SS Post\-installation tasks .sp Now go to the \fBConfiguring Salt\fP page. .SS Windows .sp Salt has full support for running the Salt Minion on Windows. .sp There are no plans for the foreseeable 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. .sp 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. .SS Windows Installer .sp A Salt Minion Windows installer can be found here: .INDENT 0.0 .INDENT 3.5 .IP "Download here" .INDENT 0.0 .IP \(bu 2 0.16.3 .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.16.3\-win32\-Setup.exe\fP .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.16.3\-AMD64\-Setup.exe\fP .IP \(bu 2 0.16.2 .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.16.2\-win32\-Setup.exe\fP .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.16.2\-AMD64\-Setup.exe\fP .IP \(bu 2 0.16.0 .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.16.0\-win32\-Setup.exe\fP .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.16.0\-AMD64\-Setup.exe\fP .IP \(bu 2 0.15.3 .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.15.3\-win32\-Setup.exe\fP .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.15.3\-AMD64\-Setup.exe\fP .IP \(bu 2 0.14.1 .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.14.1\-win32\-Setup.exe\fP .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.14.1\-AMD64\-Setup.exe\fP .IP \(bu 2 0.14.0 .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.14.0\-win32\-Setup.exe\fP .IP \(bu 2 \fI\%http://saltstack.com/downloads/Salt\-Minion\-0.14.0\-AMD64\-Setup.exe\fP .UNINDENT .UNINDENT .UNINDENT .sp The 64bit installer has been tested on Windows 7 64bit and Windows Server 2008R2 64bit. The 32bit installer has been tested on Windows 2003 Server 32bit. Please file a bug report on our GitHub repo if issues for other platforms are found. .sp The installer asks for 2 bits of information; the master hostname and the minion name. The installer will update the minion config with these options and then start the minion. .sp The \fIsalt\-minion\fP service will appear in the Windows Service Manager and can be started and stopped there or with the command line program \fIsc\fP like any other Windows service. .sp If the minion won\(aqt start, try installing the Microsoft Visual C++ 2008 x64 SP1 redistributable. Allow all Windows updates to run salt\-minion smoothly. .sp Make sure that the minion config file has the line \fIipc_mode: tcp\fP .SS Silent Installer option .sp The installer can be run silently by providing the \fI/S\fP option at the command line. The options \fI/master\fP and \fI/minion\-name\fP allow for configuring the master hostname and minion name, respectively. Here\(aqs an example of using the silent installer: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C Salt\-Minion\-0.15.3\-Setup\-amd64.exe /S /master=yoursaltmaster /minion\-name=yourminionname .ft P .fi .UNINDENT .UNINDENT .SS Installer Source .sp The Salt Windows installer is built with the open\-source NSIS compiler. The source for the installer is found in the pkg directory of the Salt repo here: \fI\%https://github.com/saltstack/salt/blob/develop/pkg/windows/installer/Salt\-Minion\-Setup.nsi\fP\&. To create the installer run \fBpython setup.py bdist_esky\fP, extract the frozen archive from \fBdist/\fP into \fBpkg/windows/buildenv/\fP and run NSIS. .sp The NSIS installer can be found here: \fI\%http://nsis.sourceforge.net/Main_Page\fP .SS Installation from source .sp To install Salt from source one must install each dependency separately and configure Salt to run on your Windows host. .sp Rather than send you on a wild goose chase across the Internet, we\(aqve collected some of the more difficult to find installers in our GitHub repo for you. .SS Install on Windows XP 32bit .INDENT 0.0 .IP 1. 3 Install \fI\%msysgit\fP .INDENT 3.0 .IP 1. 3 Clone the Salt git repository from GitHub .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git clone git://github.com/saltstack/salt.git .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 2. 4 Install Microsoft Visual Studio 2008 Express. You must use Visual Studio 2008 Express, \fBnot\fP Visual Studio 2010 Express. .IP 3. 4 Install \fI\%Python 2.7.x\fP .IP 4. 4 Add c:\ePython27 to your system path .IP 5. 4 Install the Microsoft Visual C++ 2008 SP1 Redistributable, \fI\%vcredist_x86\fP\&. .IP 6. 4 Install \fI\%Win32OpenSSL\-1_0_0e.exe\fP .INDENT 4.0 .IP 1. 3 Choose first option to install in Windows system directory .UNINDENT .IP 7. 4 Install \fI\%pyzmq\-2.1.11.win32\-py2.7.msi\fP .IP 8. 4 Install \fI\%pycrypto\-2.3.win32\-py2.7.msi\fP .IP 9. 4 Install \fI\%M2Crypto\fP .IP 10. 4 Install \fI\%pywin32\fP .IP 11. 4 Install \fI\%PyYAML\-3.10.win32\-py2.7.msi\fP .IP 12. 4 Install \fI\%Cython\-0.15.1.win32\-py2.79.exe\fP .IP 13. 4 Download and run \fI\%distribute_setup.py\fP .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C python distribute_setup.py .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 14. 4 Download and run \fI\%pip\fP .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C python get\-pip.py .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 15. 4 Add c:\epython27\escripts to your path .IP 16. 4 Close terminal window and open a new terminal window (\fIcmd\fP) .IP 17. 4 Install jinja2 .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install jinja2 .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 18. 4 Install wmi .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install wmi .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 19. 4 Install Messagepack .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install msgpack\-python .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 20. 4 Install Salt .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cd ./salt python setup.py install .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 21. 4 Edit c:\eetc\esalt\eminion .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C master: ipaddress or hostname of your salt\-master master_port: 4506 ipc_mode: tcp root_dir: c:\e pki_dir: /etc/salt/pki cachedir: /var/cache/salt renderer: yaml_jinja open_mode: False multiprocessing: False .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 22. 4 Start the salt\-minion .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cd c:\epython27\escripts python salt\-minion .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 23. 4 On the salt\-master accept the new minion\(aqs key .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo salt\-key \-A (This accepts all unaccepted keys. If you\(aqre concerned about security just accept the key for this specific minion) .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 24. 4 Test that your minion is responding .INDENT 4.0 .INDENT 3.5 .INDENT 0.0 .IP a. 3 On the salt\-master run: .UNINDENT .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sudo salt \(aq*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp You should get the following response: {\(aqyour minion hostname\(aq: True} .SS Single command bootstrap script .sp On a 64 bit Windows host the following script makes an unattended install of salt, including all dependencies: .INDENT 0.0 .INDENT 3.5 .IP "Not up to date." .sp This script is not up to date. Please use the installer found above .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C "PowerShell (New\-Object System.Net.WebClient).DownloadFile(\(aqhttp://csa\-net.dk/salt/bootstrap64.bat\(aq,\(aqC:\ebootstrap.bat\(aq);(New\-Object \-com Shell.Application).ShellExecute(\(aqC:\ebootstrap.bat\(aq);" (All in one line.) .ft P .fi .UNINDENT .UNINDENT .sp You can execute the above command remotely from a Linux host using winexe: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C winexe \-U "administrator" //fqdn "PowerShell (New\-Object ......);" .ft P .fi .UNINDENT .UNINDENT .sp For more info check \fI\%http://csa\-net.dk/salt\fP .SS Packages management under Windows 2003 .sp On windows server 2003, you need to install optional component "wmi windows installer provider" to have full list of installed packages. If you don\(aqt have this, salt\-minion can\(aqt report some installed softwares. .SS SUSE Installation .SS openSUSE .sp For openSUSE Factory run the following as root: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C zypper addrepo http://download.opensuse.org/repositories/devel:languages:python/openSUSE_Factory/devel:languages:python.repo zypper refresh zypper install salt salt\-minion salt\-master .ft P .fi .UNINDENT .UNINDENT .sp For openSUSE 12.3 run the following as root: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C zypper addrepo http://download.opensuse.org/repositories/devel:languages:python/openSUSE_12.3/devel:languages:python.repo zypper refresh zypper install salt salt\-minion salt\-master .ft P .fi .UNINDENT .UNINDENT .sp For openSUSE 12.2 run the following as root: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C zypper addrepo http://download.opensuse.org/repositories/devel:languages:python/openSUSE_12.2/devel:languages:python.repo zypper refresh zypper install salt salt\-minion salt\-master .ft P .fi .UNINDENT .UNINDENT .sp For openSUSE 12.1 run the following as root: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C zypper addrepo http://download.opensuse.org/repositories/devel:languages:python/openSUSE_12.1/devel:languages:python.repo zypper refresh zypper install salt salt\-minion salt\-master .ft P .fi .UNINDENT .UNINDENT .sp For bleeding edge python Factory run the following as root: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C zypper addrepo http://download.opensuse.org/repositories/devel:languages:python/bleeding_edge_python_Factory/devel:languages:python.repo zypper refresh zypper install salt salt\-minion salt\-master .ft P .fi .UNINDENT .UNINDENT .SS SLES 11 SP2 .sp For SLE 11 SP2 run the following as root: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C zypper addrepo http://download.opensuse.org/repositories/devel:languages:python/SLE_11_SP2/devel:languages:python.repo zypper refresh zypper install salt salt\-minion salt\-master .ft P .fi .UNINDENT .UNINDENT .SS Post\-installation tasks .sp Now go to the \fBConfiguring Salt\fP page. .SS Dependencies .sp Salt should run on any Unix\-like platform so long as the dependencies are met. .INDENT 0.0 .IP \(bu 2 \fI\%Python 2.6\fP >= 2.6 <3.0 .IP \(bu 2 \fI\%ZeroMQ\fP >= 2.1.9 .IP \(bu 2 \fI\%pyzmq\fP >= 2.1.9 \- ZeroMQ Python bindings .IP \(bu 2 \fI\%PyCrypto\fP \- The Python cryptography toolkit .IP \(bu 2 \fI\%msgpack\-python\fP \- High\-performance message interchange format .IP \(bu 2 \fI\%YAML\fP \- Python YAML bindings .IP \(bu 2 \fI\%Jinja2\fP \- parsing Salt States (configurable in the master settings) .UNINDENT .SS Optional Dependencies .INDENT 0.0 .IP \(bu 2 \fI\%mako\fP \- an optional parser for Salt States (configurable in the master settings) .IP \(bu 2 gcc \- dynamic \fI\%Cython\fP module compiling .UNINDENT .SH CONFIGURING SALT .sp Salt configuration is very simple. The default configuration for the \fImaster\fP will work for most installations and the only requirement for setting up a \fIminion\fP is to set the location of the master in the minion configuration file. .INDENT 0.0 .TP .B master The Salt master is the central server that all minions connect to. Commands are run on the minions through the master, and minions send data back to the master (unless otherwise redirected with a \fBreturner\fP). It is started with the \fBsalt\-master\fP program. .TP .B minion Salt minions are the potentially hundreds or thousands of servers that may be queried and controlled from the master. .UNINDENT .sp The configuration files will be installed to \fB/etc/salt\fP and are named after the respective components, \fB/etc/salt/master\fP and \fB/etc/salt/minion\fP\&. .SS Master Configuration .sp By default the Salt master listens on ports 4505 and 4506 on all interfaces (0.0.0.0). To bind Salt to a specific IP, redefine the "interface" directive in the master configuration file, typically \fB/etc/salt/master\fP, as follows: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \- #interface: 0.0.0.0 + interface: 10.0.0.1 .ft P .fi .UNINDENT .UNINDENT .sp After updating the configuration file, restart the Salt master. See the \fBmaster configuration reference\fP for more details about other configurable options. .SS Minion Configuration .sp Although there are many Salt Minion configuration options, configuring a Salt Minion is very simple. By default a Salt Minion will try to connect to the DNS name "salt"; if the Minion is able to resolve that name correctly, no configuration is needed. .sp If the DNS name "salt" does not resolve to point to the correct location of the Master, redefine the "master" directive in the minion configuration file, typically \fB/etc/salt/minion\fP, as follows: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \- #master: salt + master: 10.0.0.1 .ft P .fi .UNINDENT .UNINDENT .sp After updating the configuration file, restart the Salt minion. See the \fBminion configuration reference\fP for more details about other configurable options. .SS Running Salt .INDENT 0.0 .IP 1. 3 Start the master in the foreground (to daemonize the process, pass the \fI\-d flag\fP): .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C salt\-master .ft P .fi .UNINDENT .UNINDENT .IP 2. 3 Start the minion in the foreground (to daemonize the process, pass the \fI\-d flag\fP): .INDENT 3.0 .INDENT 3.5 .sp .nf .ft C salt\-minion .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .IP "Having trouble?" .sp The simplest way to troubleshoot Salt is to run the master and minion in the foreground with \fIlog level\fP set to \fBdebug\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-master \-\-log\-level=debug .ft P .fi .UNINDENT .UNINDENT .sp For information on salt\(aqs logging system please see the \fBlogging document\fP\&. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .IP "Run as an unprivileged (non\-root) user" .sp To run Salt as another user, specify \fB\-\-user\fP in the command line or assign \fBuser\fP in the \fBconfiguration file\fP\&. .UNINDENT .UNINDENT .sp There is also a full \fBtroubleshooting guide\fP available. .SS Key Management .sp Salt uses AES encryption for all communication between the Master and the Minion. This ensures that the commands sent to the Minions cannot be tampered with, and that communication between Master and Minion is authenticated through trusted, accepted keys. .sp Before commands can be sent to a Minion, its key must be accepted on the Master. Run the \fBsalt\-key\fP command to list the keys known to the Salt Master: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C [root@master ~]# salt\-key \-L Unaccepted Keys: alpha bravo charlie delta Accepted Keys: .ft P .fi .UNINDENT .UNINDENT .sp This example shows that the Salt Master is aware of four Minions, but none of the keys has been accepted. To accept the keys and allow the Minions to be controlled by the Master, again use the \fBsalt\-key\fP command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C [root@master ~]# salt\-key \-A [root@master ~]# salt\-key \-L Unaccepted Keys: Accepted Keys: alpha bravo charlie delta .ft P .fi .UNINDENT .UNINDENT .sp The \fBsalt\-key\fP command allows for signing keys individually or in bulk. The example above, using \fB\-A\fP bulk\-accepts all pending keys. To accept keys individually use the lowercase of the same option, \fB\-a keyname\fP\&. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fBsalt\-key manpage\fP .UNINDENT .UNINDENT .SS Sending Commands .sp Communication between the Master and a Minion may be verified by running the \fBtest.ping\fP command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C [root@master ~]# salt alpha test.ping alpha: True .ft P .fi .UNINDENT .UNINDENT .sp Communication between the Master and all Minions may be tested in a similar way: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C [root@master ~]# salt \(aq*\(aq test.ping alpha: True bravo: True charlie: True delta: True .ft P .fi .UNINDENT .UNINDENT .sp Each of the Minions should send a \fBTrue\fP response as shown above. .SS What\(aqs Next? .sp Understanding \fBtargeting\fP is important. From there, depending on the way you wish to use Salt, you should also proceed to learn about \fBStates\fP and \fBExecution Modules\fP\&. .SH DEVELOPING SALT .sp There is a great need for contributions to salt and patches are welcome! The goal here is to make contributions clear, make sure there is a trail for where the code has come from, and most importantly, to give credit where credit is due! .sp There are a number of ways to contribute to salt development. .SS Sending a GitHub pull request .sp This is the preferred method for contributions. Simply create a GitHub fork, commit changes to the fork, and then open up a pull request. .sp The following is an example (from \fI\%Open Comparison Contributing Docs\fP ) of an efficient workflow for forking, cloning, branching, committing, and sending a pull request for a GitHub repository. .sp First, make a local clone of your GitHub fork of the salt GitHub repo and make edits and changes locally. .sp Then, create a new branch on your clone by entering the following commands: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git checkout \-b fixed\-broken\-thing Switched to a new branch \(aqfixed\-broken\-thing\(aq .ft P .fi .UNINDENT .UNINDENT .sp Choose a name for your branch that describes its purpose. .sp Now commit your changes to this new branch with the following command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git commit \-am \(aqdescription of my fixes for the broken thing\(aq .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Using \fBgit commit \-am\fP, followed by a quoted string, both stages and commits all modified files in a single command. Depending on the nature of your changes, you may wish to stage and commit them separately. Also, note that if you wish to add newly\-tracked files as part of your commit, they will not be caught using \fBgit commit \-am\fP and will need to be added using \fBgit add\fP before committing. .UNINDENT .UNINDENT .sp Push your locally\-committed changes back up to GitHub: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git push \-\-set\-upstream origin fixed\-broken\-thing .ft P .fi .UNINDENT .UNINDENT .sp Now go look at your fork of the salt repo on the GitHub website. The new branch will now be listed under the "Source" tab where it says "Switch Branches". Select the new branch from this list, and then click the "Pull request" button. .sp Put in a descriptive comment, and include links to any project issues related to the pull request. .sp The repo managers will be notified of your pull request and it will be reviewed. If a reviewer asks for changes, just make the changes locally in the same local feature branch, push them to GitHub, then add a comment to the discussion section of the pull request. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Travis\-CI .sp To make reviewing pull requests easier for the maintainers, please enable Travis\-CI on your fork. Salt is already configured, so simply follow the first 2 steps on the Travis\-CI \fI\%Getting Started Doc\fP\&. .UNINDENT .UNINDENT .SS Keeping Salt Forks in Sync .sp Salt is advancing quickly. It is therefore critical to pull upstream changes from master into forks on a regular basis. Nothing is worse than putting in a days of hard work into a pull request only to have it rejected because it has diverged too far from master. .sp To pull in upstream changes: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # For ssh github git remote add upstream git@github.com:saltstack/salt.git git fetch upstream # For https github git remote add upstream https://github.com/saltstack/salt.git git fetch upstream .ft P .fi .UNINDENT .UNINDENT .sp To check the log to be sure that you actually want the changes, run the following before merging: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git log upstream/develop .ft P .fi .UNINDENT .UNINDENT .sp Then to accept the changes and merge into the current branch: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git merge upstream/develop .ft P .fi .UNINDENT .UNINDENT .sp For more info, see \fI\%GitHub Fork a Repo Guide\fP or \fI\%Open Comparison Contributing Docs\fP .SS Posting patches to the mailing list .sp Patches will also be accepted by email. Format patches using \fI\%git format\-patch\fP and send them to the Salt users mailing list. The contributor will then get credit for the patch, and the Salt community will have an archive of the patch and a place for discussion. .SS Installing Salt for development .sp Clone the repository using: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git clone https://github.com/saltstack/salt .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 tags .sp Just cloning the repository is enough to work with Salt and make contributions. However, fetching additional tags from git is required to have Salt report the correct version for itself. To do this, first add the git repository as an upstream source: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git remote add upstream http://github.com/saltstack/salt .ft P .fi .UNINDENT .UNINDENT .sp Fetching tags is done with the git \(aqfetch\(aq utility: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git fetch \-\-tags upstream .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp Create a new \fI\%virtualenv\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C virtualenv /path/to/your/virtualenv .ft P .fi .UNINDENT .UNINDENT .sp On Arch Linux, where Python 3 is the default installation of Python, use the \fBvirtualenv2\fP command instead of \fBvirtualenv\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Using system Python modules in the virtualenv .sp To use already\-installed python modules in virtualenv (instead of having pip download and compile new ones), run \fBvirtualenv \-\-system\-site\-packages\fP Using this method eliminates the requirement to install the salt dependencies again, although it does assume that the listed modules are all installed in the system PYTHONPATH at the time of virtualenv creation. .UNINDENT .UNINDENT .sp Activate the virtualenv: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C source /path/to/your/virtualenv/bin/activate .ft P .fi .UNINDENT .UNINDENT .sp Install Salt (and dependencies) into the virtualenv: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install M2Crypto # Don\(aqt install on Debian/Ubuntu (see below) pip install pyzmq PyYAML pycrypto msgpack\-python jinja2 psutil pip install \-e ./salt # the path to the salt git clone from above .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Installing M2Crypto .sp \fBswig\fP and \fBlibssl\-dev\fP are required to build M2Crypto. To fix the error \fBcommand \(aqswig\(aq failed with exit status 1\fP while installing M2Crypto, try installing it with the following command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C env SWIG_FEATURES="\-cpperraswarn \-includeall \-D__\(gauname \-m\(ga__ \-I/usr/include/openssl" pip install M2Crypto .ft P .fi .UNINDENT .UNINDENT .sp Debian and Ubuntu systems have modified openssl libraries and mandate that a patched version of M2Crypto be installed. This means that M2Crypto needs to be installed via apt: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apt\-get install python\-m2crypto .ft P .fi .UNINDENT .UNINDENT .sp This also means that pulling in the M2Crypto installed using apt requires using \fB\-\-system\-site\-packages\fP when creating the virtualenv. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Installing psutil .sp Python header files are required to build this module, otherwise the pip install will fail. If your distribution separates binaries and headers into separate packages, make sure that you have the headers installed. In most Linux distributions which split the headers into their own package, this can be done by installing the \fBpython\-dev\fP or \fBpython\-devel\fP package. For other platforms, the package will likely be similarly named. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Important note for those developing using RedHat variants .sp For developers using a RedHat variant, be advised that the package provider for newer Redhat\-based systems (\fByumpkg.py\fP) relies on RedHat\(aqs python interface for yum. The variants that use this module to provide package support include the following: .INDENT 0.0 .IP \(bu 2 \fI\%RHEL\fP and \fI\%CentOS\fP releases 6 and later .IP \(bu 2 \fI\%Fedora Linux\fP releases 11 and later .IP \(bu 2 \fI\%Amazon Linux\fP .UNINDENT .sp Developers using one of these systems should create the salt virtualenv using the \fB\-\-system\-site\-packages\fP option to ensure that the correct modules are available. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Installing dependencies on OS X. .sp You can install needed dependencies on OS X using homebrew or macports. See \fBOS X Installation\fP .UNINDENT .UNINDENT .SS Running a self\-contained development version .sp During development it is easiest to be able to run the Salt master and minion that are installed in the virtualenv you created above, and also to have all the configuration, log, and cache files contained in the virtualenv as well. .sp Copy the master and minion config files into your virtualenv: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C mkdir \-p /path/to/your/virtualenv/etc/salt cp ./salt/conf/master /path/to/your/virtualenv/etc/salt/master cp ./salt/conf/minion /path/to/your/virtualenv/etc/salt/minion .ft P .fi .UNINDENT .UNINDENT .sp Edit the master config file: .INDENT 0.0 .IP 1. 3 Uncomment and change the \fBuser: root\fP value to your own user. .IP 2. 3 Uncomment and change the \fBroot_dir: /\fP value to point to \fB/path/to/your/virtualenv\fP\&. .IP 3. 3 If you are running version 0.11.1 or older, uncomment and change the \fBpidfile: /var/run/salt\-master.pid\fP value to point to \fB/path/to/your/virtualenv/salt\-master.pid\fP\&. .IP 4. 3 If you are also running a non\-development version of Salt you will have to change the \fBpublish_port\fP and \fBret_port\fP values as well. .UNINDENT .sp Edit the minion config file: .INDENT 0.0 .IP 1. 3 Repeat the edits you made in the master config for the \fBuser\fP and \fBroot_dir\fP values as well as any port changes. .IP 2. 3 If you are running version 0.11.1 or older, uncomment and change the \fBpidfile: /var/run/salt\-minion.pid\fP value to point to \fB/path/to/your/virtualenv/salt\-minion.pid\fP\&. .IP 3. 3 Uncomment and change the \fBmaster: salt\fP value to point at \fBlocalhost\fP\&. .IP 4. 3 Uncomment and change the \fBid:\fP value to something descriptive like "saltdev". This isn\(aqt strictly necessary but it will serve as a reminder of which Salt installation you are working with. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Using \fIsalt\-call\fP with a \fBStandalone Minion\fP .sp If you plan to run \fIsalt\-call\fP with this self\-contained development environment in a masterless setup, you should invoke \fIsalt\-call\fP with \fB\-c /path/to/your/virtualenv/etc/salt\fP so that salt can find the minion config file. Without the \fB\-c\fP option, Salt finds its config files in \fI/etc/salt\fP\&. .UNINDENT .UNINDENT .sp Start the master and minion, accept the minion\(aqs key, and verify your local Salt installation is working: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cd /path/to/your/virtualenv salt\-master \-c ./etc/salt \-d salt\-minion \-c ./etc/salt \-d salt\-key \-c ./etc/salt \-L salt\-key \-c ./etc/salt \-A salt \-c ./etc/salt \(aq*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Running the master and minion in debug mode can be helpful when developing. To do this, add \fB\-l debug\fP to the calls to \fBsalt\-master\fP and \fBsalt\-minion\fP\&. If you would like to log to the console instead of to the log file, remove the \fB\-d\fP\&. .sp Once the minion starts, you may see an error like the following: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C zmq.core.error.ZMQError: ipc path "/path/to/your/virtualenv/var/run/salt/minion/minion_event_7824dcbcfd7a8f6755939af70b96249f_pub.ipc" is longer than 107 characters (sizeof(sockaddr_un.sun_path)). .ft P .fi .UNINDENT .UNINDENT .sp This means the the path to the socket the minion is using is too long. This is a system limitation, so the only workaround is to reduce the length of this path. This can be done in a couple different ways: .INDENT 0.0 .IP 1. 3 Create your virtualenv in a path that is short enough. .IP 2. 3 Edit the \fBsock_dir\fP minion config variable and reduce its length. Remember that this path is relative to the value you set in \fBroot_dir\fP\&. .UNINDENT .sp \fBNOTE:\fP The socket path is limited to 107 characters on Solaris and Linux, and 103 characters on BSD\-based systems. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 File descriptor limits .sp Ensure that the system open file limit is raised to at least 2047: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # check your current limit ulimit \-n # raise the limit. persists only until reboot # use \(aqlimit descriptors 2047\(aq for c\-shell ulimit \-n 2047 .ft P .fi .UNINDENT .UNINDENT .sp To set file descriptors on OSX, refer to the \fBOS X Installation\fP instructions. .UNINDENT .UNINDENT .SS Using easy_install to Install Salt .sp If you are installing using \fBeasy_install\fP, you will need to define a \fBUSE_SETUPTOOLS\fP environment variable, otherwise dependencies will not be installed: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C USE_SETUPTOOLS=1 easy_install salt .ft P .fi .UNINDENT .UNINDENT .SS Running the tests .sp You will need \fBmock\fP to run the tests: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install mock .ft P .fi .UNINDENT .UNINDENT .sp If you are on Python < 2.7 then you will also need unittest2: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install unittest2 .ft P .fi .UNINDENT .UNINDENT .sp Finally you use setup.py to run the tests with the following command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \&./setup.py test .ft P .fi .UNINDENT .UNINDENT .sp For greater control while running the tests, please try: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \&./tests/runtests.py \-h .ft P .fi .UNINDENT .UNINDENT .SS Editing and previewing the documentation .sp You need \fBsphinx\-build\fP command to build the docs. In Debian/Ubuntu this is provided in the \fBpython\-sphinx\fP package. Sphinx can also be installed to a virtualenv using pip: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install Sphinx .ft P .fi .UNINDENT .UNINDENT .sp Change to salt documentation directory, then: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cd doc; make html .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 This will build the HTML docs. Run \fBmake\fP without any arguments to see the available make targets, which include \fBhtml\fP, \fBman\fP, and \fBtext\fP\&. .IP \(bu 2 The docs then are built within the \fBdocs/_build/\fP folder. To update the docs after making changes, run \fBmake\fP again. .IP \(bu 2 The docs use \fI\%reStructuredText\fP for markup. See a live demo at \fI\%http://rst.ninjs.org/\fP\&. .IP \(bu 2 The help information on each module or state is culled from the python code that runs for that piece. Find them in \fBsalt/modules/\fP or \fBsalt/states/\fP\&. .IP \(bu 2 To build the docs on Arch Linux, the \fBpython2\-sphinx\fP package is required. Additionally, it is necessary to tell \fBmake\fP where to find the proper \fBsphinx\-build\fP binary, like so: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C make SPHINXBUILD=sphinx\-build2 html .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 To build the docs on RHEL/CentOS 6, the \fBpython\-sphinx10\fP package must be installed from EPEL, and the following make command must be used: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C make SPHINXBUILD=sphinx\-1.0\-build html .ft P .fi .UNINDENT .UNINDENT .SH TARGETING .INDENT 0.0 .TP .B 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. .UNINDENT .sp For example the command \fBsalt web1 apache.signal restart\fP to restart the Apache httpd server specifies the machine \fBweb1\fP as the target and the command will only be run on that one minion. .sp Similarly when using States, the following \fItop file\fP specifies that only the \fBweb1\fP minion should execute the contents of \fBwebserver.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aqweb1\(aq: \- webserver .ft P .fi .UNINDENT .UNINDENT .sp There are many ways to target individual minions or groups of minions in Salt: .SS Matching the \fBminion id\fP .INDENT 0.0 .TP .B 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. .UNINDENT .sp 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\(aqs \fBid\fP configuration setting. .sp \fBTIP:\fP .INDENT 0.0 .INDENT 3.5 minion id and minion keys .sp The \fIminion id\fP is used to generate the minion\(aqs public/private keys and if it ever changes the master must then accept the new key as though the minion was a new host. .UNINDENT .UNINDENT .SS Globbing .sp The default matching that Salt utilizes is \fI\%shell\-style globbing\fP around the \fIminion id\fP\&. This also works for states in the \fItop file\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 You must wrap \fBsalt\fP calls that use globbing in single\-quotes to prevent the shell from expanding the globs before Salt is invoked. .UNINDENT .UNINDENT .sp Match all minions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Match all minions in the example.net domain or any of the example domains: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*.example.net\(aq test.ping salt \(aq*.example.*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Match all the \fBwebN\fP minions in the example.net domain (\fBweb1.example.net\fP, \fBweb2.example.net\fP … \fBwebN.example.net\fP): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aqweb?.example.net\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Match the \fBweb1\fP through \fBweb5\fP minions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aqweb[1\-5]\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Match the \fBweb\-x\fP, \fBweb\-y\fP, and \fBweb\-z\fP minions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aqweb\-[x\-z]\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .SS Regular Expressions .sp Minions can be matched using Perl\-compatible \fI\%regular expressions\fP (which is globbing on steroids and a ton of caffeine). .sp Match both \fBweb1\-prod\fP and \fBweb1\-devel\fP minions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-E \(aqweb1\-(prod|devel)\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp When using regular expressions in a State\(aqs \fItop file\fP, you must specify the matcher as the first option. The following example executes the contents of \fBwebserver.sls\fP on the above\-mentioned minions. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aqweb1\-(prod|devel)\(aq: \- match: pcre \- webserver .ft P .fi .UNINDENT .UNINDENT .SS Lists .sp At the most basic level, you can specify a flat list of minion IDs: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-L \(aqweb1,web2,web3\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .SS Grains .sp 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. .INDENT 0.0 .TP .B Grains Static bits of information that a minion collects about the system when the minion first starts. .UNINDENT .sp 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. .sp 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. .sp Match all CentOS minions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-G \(aqos:CentOS\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Match all minions with 64\-bit CPUs, and return number of CPU cores for each matching minion: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-G \(aqcpuarch:x86_64\(aq grains.item num_cpus .ft P .fi .UNINDENT .UNINDENT .sp Additionally, globs can be used in grain matches, and grains that are nested in a \fI\%dictionary\fP can be matched by adding a colon for each level that is traversed. For example, the following will match hosts that have a grain called \fBec2_tags\fP, which itself is a \fI\%dict\fP with a key named \fBenvironment\fP, which has a value that contains the word \fBproduction\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-G \(aqec2_tags:environment:*production*\(aq .ft P .fi .UNINDENT .UNINDENT .SS Listing Grains .sp Available grains can be listed by using the \(aqgrains.ls\(aq module: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq grains.ls .ft P .fi .UNINDENT .UNINDENT .sp Grains data can be listed by using the \(aqgrains.items\(aq module: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq grains.items .ft P .fi .UNINDENT .UNINDENT .SS Grains in the Minion Config .sp Grains can also be statically assigned within the minion configuration file. Just add the option \fBgrains\fP and pass options to it: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C grains: roles: \- webserver \- memcache deployment: datacenter4 cabinet: 13 cab_u: 14\-15 .ft P .fi .UNINDENT .UNINDENT .sp 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. .SS Grains in /etc/salt/grains .sp If you do not want to place your custom static grains in the minion config file, you can also put them in \fB/etc/salt/grains\fP\&. They are configured in the same way as in the above example, only without a top\-level \fBgrains:\fP key: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C roles: \- webserver \- memcache deployment: datacenter4 cabinet: 13 cab_u: 14\-15 .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .IP "Precedece of Custom Static Grains" .sp Be careful when defining grains both in \fB/etc/salt/grains\fP and within the minion config file. If a grain is defined in both places, the value in the minion config file takes precedence, and will always be used over its counterpart in \fB/etc/salt/grains\fP\&. .UNINDENT .UNINDENT .SS Grains in Top file .sp With correctly setup grains on the Minion, the Top file used in Pillar or during Highstate can be made really efficient. Like for example, you could do: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \(aqnode_type:web\(aq: \- match: grain \- webserver \(aqnode_type:postgres\(aq: \- match: grain \- database \(aqnode_type:redis\(aq: \- match: grain \- redis \(aqnode_type:lb\(aq: \- match: grain \- lb .ft P .fi .UNINDENT .UNINDENT .sp For this example to work, you would need the grain \fBnode_type\fP and the correct value to match on. This simple example is nice, but too much of the code is similar. To go one step further, we can place some Jinja template code into the Top file. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% set self = grains[\(aqnode_type\(aq] %} \(aqnode_type:{{ self }}\(aq: \- match: grain \- {{ self }} .ft P .fi .UNINDENT .UNINDENT .sp The Jinja code simplified the Top file, and allowed SaltStack to work its magic. .SS Writing Grains .sp 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 \fI\%dict\fP, where the keys in the \fI\%dict\fP are the names of the grains and the values are the values. .sp Custom grains should be placed in a \fB_grains\fP directory located under the \fBfile_roots\fP specified by the master config file. They will be distributed to the minions when \fBstate.highstate\fP is run, or by executing the \fBsaltutil.sync_grains\fP or \fBsaltutil.sync_all\fP functions. .sp Before adding a grain to Salt, consider what the grain is and remember that grains need to be static data. If the data is something that is likely to change, consider using \fBPillar\fP instead. .SS Examples of Grains .sp 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: .sp \fI\%https://github.com/saltstack/salt/blob/develop/salt/grains/core.py\fP .SS Syncing Grains .sp Syncing grains can be done a number of ways, they are automatically synced when \fBstate.highstate\fP is called, or (as noted above) the grains can be manually synced and reloaded by calling the \fBsaltutil.sync_grains\fP or \fBsaltutil.sync_all\fP functions. .SS Node groups .INDENT 0.0 .TP .B Node group A predefined group of minions declared in the master configuration file \fBnodegroups\fP setting as a compound target. .UNINDENT .sp Nodegroups are declared using a compound target specification. The compound target documentation can be found \fBhere\fP\&. .sp The \fBnodegroups\fP master config file parameter is used to define nodegroups. Here\(aqs an example nodegroup configuration: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C nodegroups: group1: \(aqL@foo.domain.com,bar.domain.com,baz.domain.com or bl*.domain.com\(aq group2: \(aqG@os:Debian and foo.domain.com\(aq .ft P .fi .UNINDENT .UNINDENT .sp To match a nodegroup on the CLI, use the \fB\-N\fP command\-line option: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-N group1 test.ping .ft P .fi .UNINDENT .UNINDENT .sp To match in your \fItop file\fP, make sure to put \fB\- match: nodegroup\fP on the line directly following the nodegroup name. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: group1: \- match: nodegroup \- webserver .ft P .fi .UNINDENT .UNINDENT .SS Compound matchers .INDENT 0.0 .TP .B Compound matcher A combination of many target definitions that can be combined with boolean operators. .UNINDENT .sp Compound matchers allow very granular minion targeting using any of Salt\(aqs matchers. The default matcher is a \fI\%glob\fP match, just as with CLI and \fItop file\fP matching. To match using anything other than a glob, prefix the match string with the appropriate letter from the table below, followed by an \fB@\fP sign. .TS center; |l|l|l|. _ T{ Letter T} T{ Match Type T} T{ Example T} _ T{ G T} T{ Grains glob T} T{ \fBG@os:Ubuntu\fP T} _ T{ E T} T{ PCRE Minion ID T} T{ \fBE@web\ed+\e.(dev|qa|prod)\e.loc\fP T} _ T{ P T} T{ Grains PCRE T} T{ \fBP@os:(RedHat|Fedora|CentOS)\fP T} _ T{ L T} T{ List of minions T} T{ \fBL@minion1.example.com,minion3.domain.com or bl*.domain.com\fP T} _ T{ I T} T{ Pillar glob T} T{ \fBI@pdata:foobar\fP T} _ T{ S T} T{ Subnet/IP address T} T{ \fBS@192.168.1.0/24\fP or \fBS@192.168.1.100\fP T} _ T{ R T} T{ Range cluster T} T{ \fBR@%foo.bar\fP T} _ .TE .nf Matchers can be joined using boolean \fBand\fP, \fBor\fP, and \fBnot\fP operators. .fi .sp .sp For example, the following string matches all Debian minions with a hostname that begins with \fBwebserv\fP, as well as any minions that have a hostname which matches the \fI\%regular expression\fP \fBweb\-dc1\-srv.*\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-C \(aqwebserv* and G@os:Debian or E@web\-dc1\-srv.*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp That same example expressed in a \fItop file\fP looks like the following: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aqwebserv* and G@os:Debian or E@web\-dc1\-srv.*\(aq: \- match: compound \- webserver .ft P .fi .UNINDENT .UNINDENT .sp Note that a leading \fBnot\fP is not supported in compound matches. Instead, something like the following must be done: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-C \(aq* and not G@kernel:Darwin\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .SS Batch Size .sp The \fB\-b\fP (or \fB\-\-batch\-size\fP) option allows commands to be executed on only a specifed number of minions at a time. Both percentages and finite numbers are supported. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq \-b 10 test.ping salt \-G \(aqos:RedHat\(aq \-\-batch\-size 25% apache.signal restart .ft P .fi .UNINDENT .UNINDENT .sp 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 \fBos:RedHat\fP 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. .sp 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. .SH SALT TUTORIALS .SS Bootstrapping Salt on Linux EC2 with Cloud\-Init .sp \fI\%Salt\fP 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 \fI\%AMI\fP, but this creates another resource to maintain and document. .sp A better method for Linux machines uses Canonical\(aqs \fI\%CloudInit\fP to run a bootstrap script during an \fI\%EC2 Instance\fP initialization. Cloud\-init takes the \fBuser_data\fP string passed into a new AWS instance and runs it in a manner similar to rc.local. The bootstrap script needs to: .INDENT 0.0 .IP 1. 3 Install \fI\%Salt\fP with dependencies .IP 2. 3 Point the minion to the master .UNINDENT .sp Here is a sample script: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C #!/bin/bash # Install saltstack add\-apt\-repository ppa:saltstack/salt \-y apt\-get update \-y apt\-get install salt\-minion \-y apt\-get install salt\-master \-y apt\-get upgrade \-y # Set salt master location and start minion sed \-i \(aqs/#master: salt/master: [salt_master_fqdn]/\(aq /etc/salt/minion salt\-minion \-d .ft P .fi .UNINDENT .UNINDENT .sp 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 \fB[salt_master_fqdn]\fP with something that resolves to your Salt master. .SS Used With Boto .sp \fI\%Boto\fP 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import boto user_data = open(\(aqsalt_bootstrap.sh\(aq) conn = boto.connect_ec2(, ) reservation = conn.run_instances(image_id=, key_name=, user_data=user_data.read()) .ft P .fi .UNINDENT .UNINDENT .SS Additional Notes .sp Sometime in the future the ppa will include and install an upstart file. In the meantime, you can use the bootstrap to \fI\%build one\fP\&. .sp It may also be useful to set the node\(aqs role during this phase. One option would be saving the node\(aqs role to a file and then using a custom Grain to select it. .SS Salt as a Cloud Controller .sp In Salt 0.14.0 advanced cloud control systems were introduced, allowing for private cloud vms to be managed directly with Salt. This system is generally referred to as \fBSalt Virt\fP\&. .sp The Salt Virt system already exists and is installed within Salt itself, this means that beyond setting up Salt no additional salt code needs to be deployed. .SS Setting up Hypervisors .sp The first step to set up the hypervisors involves getting the correct software installed and setting up the hypervisor network interfaces. .SS Installing Hypervisor Software .sp Salt Virt is made to be hypervisor agnostic, but currently the only implemented hypervisor is KVM via libvirt. .sp The required software for a hypervisor is libvirt and kvm. For advanced features install libguestfs or qemu\-nbd. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Libguestfs and qemu\-nbd allow for virtual machine images to be mounted before startup and get pre\-seeded with configurations and a salt minion .UNINDENT .UNINDENT .sp A simple sls formula to deploy the required software and service: .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Package names used are Red Hat specific, different package names will be required for different platforms .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C libguestfs: pkg.installed qemu\-kvm: pkg.installed libvirt: pkg.installed libvirtd: service.running: \- enable: True \- watch: \- pkg: libvirt .ft P .fi .UNINDENT .UNINDENT .SS Network Setup .sp Salt virt comes with a system to model the network interfaces used by the deployed virtual machines, by default a single interface is created for the deployed virtual machine and is bridged to \fBbr0\fP\&. To get going with the default networking setup ensure that the bridge interface named \fBbr0\fP exists on the hypervisor and is bridged to an active network device. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 To use more advanced networking in Salt Virt read the \fISalt Virt Networking\fP document: .sp \fBSalt Virt Networking\fP .UNINDENT .UNINDENT .SS Libvirt State .sp One of the challenges of deploying a libvirt based cloud is the distribution of libvirt certificates. These certificates allow for virtual machine migration. Salt comes with a system used to auto deploy these certificates. Salt manages the signing authority key and generates keys for libvirt clients on the master, signs them with the certificate authority and uses pillar to distribute them. This is managed via the \fBlibvirt\fP state. Simply execute this formula on the minion to ensure that the certificate is in place and up to date: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C libvirt_keys: libvirt.keys .ft P .fi .UNINDENT .UNINDENT .SS Getting Virtual Machine Images Ready .sp Salt Virt, requires that virtual machine images be provided as these are not generated on the fly. Generating these virtual machine images differs greatly based on the underlying platform. .sp Virtual machine images can be manually created using KVM and running through the installer, but this process is not recommended since it is very manual and prone to errors. .sp Virtual Machine generation applications are avilable for many platforms: .INDENT 0.0 .TP .B vm\-builder: \fI\%http://wiki.debian.org/VMBuilder\fP .UNINDENT .SS Using Salt Virt .sp With hypervisors set up and virtual machine images ready, Salt can start issuing cloud commands. .sp Start by deploying .SS Using cron with Salt .sp The Salt Minion can initiate its own highstate using the \fBsalt\-call\fP command. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ salt\-call state.highstate .ft P .fi .UNINDENT .UNINDENT .sp This will cause the minion to check in with the master and ensure it is in the correct \(aqstate\(aq. .SS Use cron to initiate a highstate .sp If you would like the Salt Minion to regularly check in with the master you can use the venerable cron to run the \fBsalt\-call\fP command. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # PATH=/bin:/sbin:/usr/bin:/usr/sbin 00 00 * * * salt\-call state.highstate .ft P .fi .UNINDENT .UNINDENT .sp The above cron entry will run a highstate every day at midnight. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Be aware that you may need to ensure the PATH for cron includes any scripts or commands that need to be executed. .UNINDENT .UNINDENT .SS Automatic Updates / Frozen Deployments .sp New in version 0.10.3.d. .sp Salt has support for the \fI\%Esky\fP application freezing and update tool. This tool allows one to build a complete zipfile out of the salt scripts and all their dependencies \- including shared objects / DLLs. .SS Getting Started .sp To build frozen applications, you\(aqll need a suitable build environment for each of your platforms. You should probably set up a virtualenv in order to limit the scope of Q/A. .sp This process does work on Windows. Follow the directions at \fI\%https://github.com/saltstack/salt\-windows\-install\fP for details on installing Salt in Windows. Only the 32\-bit Python and dependencies have been tested, but they have been tested on 64\-bit Windows. .sp You will need to install \fBesky\fP and \fBbbfreeze\fP from Pypi in order to enable the \fBbdist_esky\fP command in \fBsetup.py\fP\&. .SS Building and Freezing .sp Once you have your tools installed and the environment configured, you can then \fBpython setup.py bdist\fP to get the eggs prepared. After that is done, run \fBpython setup.py bdist_esky\fP to have Esky traverse the module tree and pack all the scripts up into a redistributable. There will be an appropriately versioned \fBsalt\-VERSION.zip\fP in \fBdist/\fP if everything went smoothly. .SS Windows .sp You will need to add \fBC:\ePython27\elib\esite\-packages\ezmq\fP to your PATH variable. This helps bbfreeze find the zmq dll so it can pack it up. .SS Using the Frozen Build .sp Unpack the zip file in your desired install location. Scripts like \fBsalt\-minion\fP and \fBsalt\-call\fP will be in the root of the zip file. The associated libraries and bootstrapping will be in the directories at the same level. (Check the \fI\%Esky\fP documentation for more information) .sp To support updating your minions in the wild, put your builds on a web server that your minions can reach. \fBsalt.modules.saltutil.update()\fP will trigger an update and (optionally) a restart of the minion service under the new version. .SS Gotchas .SS My Windows minion isn\(aqt responding .sp The process dispatch on Windows is slower than it is on *nix. You may need to add \(aq\-t 15\(aq to your salt calls to give them plenty of time to return. .SS Windows and the Visual Studio Redist .sp You will need to install the Visual C++ 2008 32\-bit redistributable on all Windows minions. Esky has an option to pack the library into the zipfile, but OpenSSL does not seem to acknowledge the new location. If you get a \fBno OPENSSL_Applink\fP error on the console when trying to start your frozen minion, you have forgotten to install the redistributable. .SS Mixed Linux environments and Yum .sp The Yum Python module doesn\(aqt appear to be available on any of the standard Python package mirrors. If you need to support RHEL/CentOS systems, you should build on that platform to support all your Linux nodes. Also remember to build your virtualenv with \fB\-\-system\-site\-packages\fP so that the \fByum\fP module is included. .SS Automatic (Python) module discovery .sp Automatic (Python) module discovery does not work with the late\-loaded scheme that Salt uses for (Salt) modules. You will need to explicitly add any misbehaving modules to the \fBfreezer_includes\fP in Salt\(aqs \fBsetup.py\fP\&. Always check the zipped application to make sure that the necessary modules were included. .SS Opening the Firewall up for Salt .sp The Salt master communicates with the minions using an AES\-encrypted ZeroMQ connection. These communications are done over TCP 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. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 No firewall configuration needs to be done on Salt minions. These changes refer to the master only. .UNINDENT .UNINDENT .SS RHEL 6 / CENTOS 6 .sp The \fBlokkit\fP command packaged with some Linux distributions makes opening iptables firewall ports very simple via the command line. Just be careful to not lock out access to the server by neglecting to open the ssh port. .sp \fBlokkit example\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C lokkit \-p 22:tcp \-p 4505:tcp \-p 4506:tcp .ft P .fi .UNINDENT .UNINDENT .sp The \fBsystem\-config\-firewall\-tui\fP command provides a text\-based interface to modifying the firewall. .sp \fBsystem\-config\-firewall\-tui\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C system\-config\-firewall\-tui .ft P .fi .UNINDENT .UNINDENT .SS openSUSE .sp Salt installs firewall rules in \fI\%/etc/sysconfig/SuSEfirewall2.d/services/salt\fP\&. Enable with: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C SuSEfirewall2 open SuSEfirewall2 start .ft P .fi .UNINDENT .UNINDENT .sp If you have an older package of Salt where the above configuration file is not included, the \fBSuSEfirewall2\fP command makes opening iptables firewall ports very simple via the command line. .sp \fBSuSEfirewall example\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C SuSEfirewall2 open EXT TCP 4505 SuSEfirewall2 open EXT TCP 4506 .ft P .fi .UNINDENT .UNINDENT .sp The firewall module in YaST2 provides a text\-based interface to modifying the firewall. .sp \fBYaST2\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C yast2 firewall .ft P .fi .UNINDENT .UNINDENT .SS iptables .sp Different Linux distributions store their \fI\%iptables\fP rules in different places, which makes it difficult to standardize firewall documentation. Included are some of the more common locations, but your mileage may vary. .sp \fBFedora / RHEL / CentOS\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /etc/sysconfig/iptables .ft P .fi .UNINDENT .UNINDENT .sp \fBArch Linux\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /etc/iptables/iptables.rules .ft P .fi .UNINDENT .UNINDENT .sp \fBDebian\fP .sp Follow these instructions: \fI\%http://wiki.debian.org/iptables\fP .sp Once you\(aqve found your firewall rules, you\(aqll need to add the two lines below to allow traffic on \fBtcp/4505\fP and \fBtcp/4506\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \-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 .ft P .fi .UNINDENT .UNINDENT .sp \fBUbuntu\fP .sp Salt installs firewall rules in \fI\%/etc/ufw/applications.d/salt.ufw\fP\&. Enable with: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C ufw allow salt .ft P .fi .UNINDENT .UNINDENT .SS pf.conf .sp The BSD\-family of operating systems uses \fI\%packet filter (pf)\fP\&. The following example describes the additions to \fBpf.conf\fP needed to access the Salt master. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .sp Once these additions have been made to the \fBpf.conf\fP the rules will need to be reloaded. This can be done using the \fBpfctl\fP command. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pfctl \-vf /etc/pf.conf .ft P .fi .UNINDENT .UNINDENT .SS GitFS Backend Walkthrough .sp While the default location of the salt state tree is on the Salt master, in /srv/salt, the master can create a bridge to external resources for files. One of these resources is the ability for the master to directly pull files from a git repository and serve them to minions. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This walkthrough assumes basic knowledge of Salt. To get up to speed, check out the \fBwalkthrough\fP\&. .UNINDENT .UNINDENT .sp The gitfs backend hooks into any number of remote git repositories and caches the data from the repository on the master. This makes distributing a state tree to multiple masters seamless and automated. .sp Salt\(aqs file server also has a concept of environments, when using the gitfs backend, Salt translates git branches and tags into environments, making environment management very simple. Just merging a QA or staging branch up to a production branch can be all that is required to make those file changes available to Salt. .SS Simple Configuration .sp To use the gitfs backend only two configuration changes are required on the master. The \fBfileserver_backend\fP option needs to be set with a value of \fBgit\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C fileserver_backend: \- git .ft P .fi .UNINDENT .UNINDENT .sp To configure what fileserver backends will be searched for requested files. .sp Now the gitfs system needs to be configured with a remote: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gitfs_remotes: \- git://github.com/saltstack/salt\-states.git .ft P .fi .UNINDENT .UNINDENT .sp These changes require a restart of the master, then the git repo will be cached on the master and new requests for the \fBsalt://\fP protocol will send files found in the remote git repository via the master. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The master caches the files from the git server and serves them out, minions do not connect directly to the git server meaning that only requested files are delivered to minions. .UNINDENT .UNINDENT .SS Multiple Remotes .sp The \fBgitfs_remotes\fP option can accept a list of git remotes, the remotes are then searched in order for the requested file. A simple scenario can illustrate this behavior. .sp Assuming that the \fBgitfs_remotes\fP option specifies three remotes: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gitfs_remotes: \- git://github.com/example/first.git \- git://github.com/example/second.git \- file:///root/third .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This example is purposefully contrived to illustrate the behavior of the gitfs backend. This example should not be read as a recommended way to lay out files and git repos. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fBfile://\fP prefix denotes a git repository in a local directory. However, it will still use the given \fBfile://\fP URL as a remote, rather than copying the git repo to the salt cache. This means that any refs you want accessible must exist as \fIlocal\fP refs in the specified repo. .UNINDENT .UNINDENT .sp Assume that each repository contains some files: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C first.git: top.sls edit/vim.sls edit/vimrc nginx/init.sls second.git: edit/dev_vimrc haproxy/init.sls third: haproxy/haproxy.conf edit/dev_vimrc .ft P .fi .UNINDENT .UNINDENT .sp The repositories will be searched for files by the master in the order in which they are defined in the configuration, Therefore the remote \fBgit://github.com/example/first.git\fP will be searched first, if the requested file is found then it is served and no further searching is executed. This means that if the file \fBsalt://haproxy/init.sls\fP is requested then it will be pulled from the \fBgit://github.com/example/second.git\fP git repo. If \fBsalt://haproxy/haproxy.conf\fP is requested then it will be pulled from the third repo. .SS Serving from a Subdirectory .sp The \fBgitfs_root\fP option gives the ability to serve files from a subdirectory within the repository. The path is defined relative to the root of the repository. .sp With this repository structure: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C repository.git: somefolder otherfolder top.sls edit/vim.sls edit/vimrc nginx/init.sls .ft P .fi .UNINDENT .UNINDENT .sp Configuration and files can be accessed normally with: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gitfs_root: somefolder/otherfolder .ft P .fi .UNINDENT .UNINDENT .SS Multiple Backends .sp Sometimes it may make sense to use multiple backends. For instance, if sls files are stored in git, but larger files need to be stored directly on the master. .sp The logic used for multiple remotes is also used for multiple backends. If the \fBfileserver_backend\fP option contains multiple backends: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C fileserver_backend: \- roots \- git .ft P .fi .UNINDENT .UNINDENT .sp Then the \fBroots\fP backend (the default backend of files in \fB/srv/salt\fP) will be searched first for the requested file, then if it is not found on the master the git remotes will be searched. .SS GitFS Remotes over SSH .sp In order to configure a \fBgitfs_remotes\fP repository over SSH transport the \fBgit+ssh\fP URL form must be used. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C gitfs_remotes: \- git+ssh://git@github.com/example/salt\-states.git .ft P .fi .UNINDENT .UNINDENT .sp The private key used to connect to the repository must be located in \fB~/.ssh/id_rsa\fP for the user running the salt\-master. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 GitFS requires the Python module \fBGitPython\fP, version 0.3.0 or newer. .UNINDENT .UNINDENT .SS Why aren\(aqt my custom modules/states/etc. syncing to my Minions? .sp In versions 0.16.3 and older, when using the \fBgit fileserver backend\fP, certain versions of GitPython may generate errors when fetching, which Salt fails to catch. While not fatal to the fetch process, these interrupt the fileserver update that takes place before custom types are synced, and thus interrupt the sync itself. Try disabling the git fileserver backend in the master config, restarting the master, and attempting the sync again. .sp This issue will be worked around in Salt 0.16.4 and newer. .SS Remote execution tutorial .sp \fBBefore continuing\fP make sure you have a working Salt installation by following the \fBinstallation\fP and the \fBconfiguration\fP instructions. .INDENT 0.0 .INDENT 3.5 .IP "Stuck?" .sp There are many ways to \fBget help from the Salt community\fP including our \fI\%mailing list\fP and our \fI\%IRC channel\fP #salt. .UNINDENT .UNINDENT .SS Order your minions around .sp Now that you have a \fImaster\fP and at least one \fIminion\fP communicating with each other you can perform commands on the minion via the \fBsalt\fP command. Salt calls are comprised of three main components: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq\(aq [arguments] .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fBsalt manpage\fP .UNINDENT .UNINDENT .SS target .sp 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq test.ping salt \(aq*.example.org\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Targets can be based on minion system information using the Grains system: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-G \(aqos:Ubuntu\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fBGrains system\fP .UNINDENT .UNINDENT .sp Targets can be filtered by regular expression: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-E \(aqvirtmach[0\-9]\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Targets can be explicitly specified in a list: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-L \(aqfoo,bar,baz,quo\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Or Multiple target types can be combined in one command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-C \(aqG@os:Ubuntu and webser* or E@database.*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .SS function .sp 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sys.doc .ft P .fi .UNINDENT .UNINDENT .sp Here are some examples: .sp Show all currently available minions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Run an arbitrary shell command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run \(aquname \-a\(aq .ft P .fi .UNINDENT .UNINDENT .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fBthe full list of modules\fP .UNINDENT .UNINDENT .SS arguments .sp Space\-delimited arguments to the function: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.exec_code python \(aqimport sys; print sys.version\(aq .ft P .fi .UNINDENT .UNINDENT .sp Optional, keyword arguments are also supported: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pip.install salt timeout=5 upgrade=True .ft P .fi .UNINDENT .UNINDENT .sp They are always in the form of \fBkwarg=argument\fP\&. .SS Multi Master Tutorial .sp As of Salt 0.16.0, the ability to connect minions to multiple masters has been made available. The multi\-master system allows for redundancy of Salt masters and facilitates multiple points of communication out to minions. When using a multi\-master setup, all masters are running hot, and any active master can be used to send commands out to the minions. .sp In 0.16.0, the masters do not share any information, keys need to be accepted on both masters, and shared files need to be shared manually or use tools like the git fileserver backend to ensure that the \fBfile_roots\fP are kept consistent. .SS Summary of Steps .INDENT 0.0 .IP 1. 3 Create a redundant master server .IP 2. 3 Copy primary master key to redundant master .IP 3. 3 Start redundant master .IP 4. 3 Configure minions to connect to redundant master .IP 5. 3 Restart minions .IP 6. 3 Accept keys on redundant master .UNINDENT .SS Prepping a Redundant Master .sp The first task is to prepare the redundant master. There is only one requirement when preparing a redundant master, which is that masters share the same private key. When the first master was created, the master\(aqs identifying key was generated and placed in the master\(aqs \fBpki_dir\fP\&. The default location of the key is \fB/etc/salt/pki/master/master.pem\fP\&. Take this key and copy it to the same location on the redundant master. Assuming that no minions have yet been connected to the new redundant master, it is safe to delete any existing key in this location and replace it. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 There is no logical limit to the number of redundant masters that can be used. .UNINDENT .UNINDENT .sp Once the new key is in place, the redundant master can be safely started. .SS Configure Minions .sp Since minions need to be master\-aware, the new master needs to be added to the minion configurations. Simply update the minion configurations to list all connected masters: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C master: \- saltmaster1.example.com \- saltmaster2.example.com .ft P .fi .UNINDENT .UNINDENT .sp Now the minion can be safely restarted. .sp Now the minions will check into the original master and also check into the new redundant master. Both masters are first\-class and have rights to the minions. .SS Sharing Files Between Masters .sp Salt does not automatically share files between multiple masters. A number of files should be shared or sharing of these files should be strongly considered. .SS Minion Keys .sp Minion keys can be accepted the normal way using \fBsalt\-key\fP on both masters. Keys accepted, deleted, or rejected on one master will NOT be automatically managed on redundant masters; this needs to be taken care of by running salt\-key on both masters or sharing the \fB/etc/salt/pki/master/{minions,minions_pre,minions_rejected}\fP directories between masters. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 While sharing the \fB/etc/salt/pki/master\fP directory will work, it is strongly discouraged, since allowing access to the \fBmaster.pem\fP key outside of Salt creates a \fISERIOUS\fP security risk. .UNINDENT .UNINDENT .SS File_Roots .sp The \fBfile_roots\fP contents should be kept consistent between masters. Otherwise state runs will not always be consistent on minions since instructions managed by one master will not agree with other masters. .sp The recommended way to sync these is to use a fileserver backend like gitfs or to keep these files on shared storage. .SS Pillar_Roots .sp Pillar roots should be given the same considerations as \fBfile_roots\fP\&. .SS Master Configurations .sp While reasons may exist to maintain separate master configurations, it is wise to remember that each master maintains independent control over minions. Therefore, access controls should be in sync between masters unless a valid reason otherwise exists to keep them inconsistent. .sp These access control options include but are not limited to: .INDENT 0.0 .IP \(bu 2 external_auth .IP \(bu 2 client_acl .IP \(bu 2 peer .IP \(bu 2 peer_run .UNINDENT .SS Pillar Walkthrough .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This walkthrough assumes that the reader has already completed the initial Salt Stack \fBwalkthrough\fP\&. .UNINDENT .UNINDENT .sp The pillar interface inside of Salt is one of the most important components of a Salt deployment. Pillar is the interface used to generate arbitrary data for specific minions. The data generated in pillar is made available to almost every component of Salt and is used for a number of purposes: .INDENT 0.0 .TP .B Highly Sensitive Data: Information transferred via pillar is guaranteed to only be presented to the minions that are targeted, this makes pillar the engine to use in Salt for managing security information, such as cryptographic keys and passwords. .TP .B Minion Configuration: Minion modules such as the execution modules, states, and returners can often be configured via data stored in pillar. .TP .B Variables: Variables which need to be assigned to specific minions or groups of minions can be defined in pillar and then accessed inside sls formulas and template files. .TP .B Arbitrary Data: Pillar can contain any basic data structure, so a list of values, or a key/value store can be defined making it easy to iterate over a group of values in sls formulas .UNINDENT .sp Pillar is therefore one of the most important systems when using Salt, this walkthrough is designed to get a simple pillar up and running in a few minutes and then to dive into the capabilities of pillar and where the data is available. .SS Setting Up Pillar .sp The pillar is already running in Salt by default. The data in the minion\(aqs pillars can be seen via the following command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pillar.items .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Prior to version 0.16.2, this function is named \fBpillar.data\fP\&. This function name is still supported for backwards compatibility. .UNINDENT .UNINDENT .sp By default the contents of the master configuration file are loaded into pillar for all minions, this is to enable the master configuration file to be used for global configuration of minions. .sp The pillar is built in a similar fashion as the state tree, it is comprised of sls files and has a top file, just like the state tree. The pillar is stored in a different location on the Salt master than the state tree. The default location for the pillar is in /srv/pillar. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The pillar location can be configured via the \fIpillar_roots\fP option inside the master configuration file. .UNINDENT .UNINDENT .sp To start setting up the pillar, the /srv/pillar directory needs to be present: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C mkdir /srv/pillar .ft P .fi .UNINDENT .UNINDENT .sp Now a simple top file, following the same format as the top file used for states needs to be created: .sp \fB/srv/pillar/top.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aq*\(aq: \- data .ft P .fi .UNINDENT .UNINDENT .sp This top file associates the data.sls file to all minions. Now the \fB/srv/pillar/data.sls\fP file needs to be populated: .sp \fB/srv/pillar/data.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C info: some data .ft P .fi .UNINDENT .UNINDENT .sp Now that the file has been saved the minions\(aq pillars will be updated: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pillar.items .ft P .fi .UNINDENT .UNINDENT .sp The key \fBinfo\fP should now appear in the returned pillar data. .SS More Complex Data .sp Pillar files are sls files, just like states, but unlike states they do not need to define \fBformulas\fP, the data can be arbitrary, this example for instance sets up user data with a UID: .sp \fB/srv/pillar/users/init.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C users: thatch: 1000 shouse: 1001 utahdave: 1002 redbeard: 1003 .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The same directory lookups that exist in states exist in pillar, so the file \fBusers/init.sls\fP can be referenced with \fBusers\fP in the \fItop file\fP\&. .UNINDENT .UNINDENT .sp The top file will need to be updated to include this sls file: .sp \fB/srv/pillar/top.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aq*\(aq: \- data \- users .ft P .fi .UNINDENT .UNINDENT .sp Now the data will be available to the minions. To use the pillar data in a state just access the pillar via Jinja: .sp \fB/srv/salt/users/init.sls\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% for user, uid in pillar.get(\(aqusers\(aq, {}).items() %} {{user}}: user.present: \- uid: {{uid}} {% endfor %} .ft P .fi .UNINDENT .UNINDENT .sp This approach allows for users to be safely defined in a pillar and then the user data is applied in an sls file. .SS Paramaterizing States With Pillar .sp One of the most powerful abstractions in pillar is the ability to parameterize states. Instead of defining macros or functions within the state context the entire state tree can be freely parameterized relative to the minion\(aqs pillar. .sp This approach allows for Salt to be very flexible while staying very straightforward. It also means that simple sls formulas used in the state tree can be directly parameterized without needing to refactor the state tree. .sp A simple example is to set up a mapping of package names in pillar for separate Linux distributions: .sp \fB/srv/pillar/pkg/init.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pkgs: {% if grains[\(aqos_family\(aq] == \(aqRedHat\(aq %} apache: httpd vim: vim\-enhanced {% elif grains[\(aqos_family\(aq] == \(aqDebian\(aq %} apache: apache2 vim: vim {% elif grains[\(aqos\(aq] == \(aqArch\(aq %} apache: apache vim: vim {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp The new \fBpkg\fP sls needs to be added to the top file: .sp \fB/srv/pillar/top.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aq*\(aq: \- data \- users \- pkg .ft P .fi .UNINDENT .UNINDENT .sp Now the minions will auto map values based on respective operating systems inside of the pillar, so sls files can be safely parameterized: .sp \fB/srv/salt/apache/init.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: pkg.installed: \- name: {{ pillar[\(aqpkgs\(aq][\(aqapache\(aq] }} .ft P .fi .UNINDENT .UNINDENT .sp Or, if no pillar is available a default can be set as well: .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The function \fBpillar.get\fP used in this example was added to Salt in version 0.14.0 .UNINDENT .UNINDENT .sp \fB/srv/salt/apache/init.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: pkg.installed: \- name: {{ salt[\(aqpillar.get\(aq](\(aqpkgs:apache\(aq, \(aqhttpd\(aq) }} .ft P .fi .UNINDENT .UNINDENT .sp In the above example, if the pillar value \fBpillar[\(aqpkgs\(aq][\(aqapache\(aq]\fP is not set in the minion\(aqs pillar, then the default of \fBhttpd\fP will be used. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Under the hood, pillar is just a python dict, so python dict methods such as \fIget\fP and \fIitems\fP can be used. .UNINDENT .UNINDENT .SS Pillar Makes Simple States Grow Easily .sp One of the design goals of pillar is to make simple sls formulas easily grow into more flexible formulas without refactoring or complicating the states. .sp A simple formula: .sp \fB/srv/salt/edit/vim.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C vim: pkg: \- installed /etc/vimrc: file.managed: \- source: salt://edit/vimrc \- mode: 644 \- user: root \- group: root \- require: \- pkg: vim .ft P .fi .UNINDENT .UNINDENT .sp Can be easily transformed into a powerful, parameterized formula: .sp \fB/srv/salt/edit/vim.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C vim: pkg: \- installed \- name: {{ pillar[\(aqpkgs\(aq][\(aqvim\(aq] }} /etc/vimrc: file.managed: \- source: {{ pillar[\(aqvimrc\(aq] }} \- mode: 644 \- user: root \- group: root \- require: \- pkg: vim .ft P .fi .UNINDENT .UNINDENT .sp Where the vimrc source location can now be changed via pillar: .sp \fB/srv/pillar/edit/vim.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if grain[\(aqid\(aq].startswith(\(aqdev\(aq) %} vimrc: salt://edit/dev_vimrc {% elif grain[\(aqid\(aq].startswith(\(aqqa\(aq) %} vimrc: salt://edit/qa_vimrc {% else %} vimrc: salt://edit/vimrc {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp Ensuring that the right vimrc is sent out to the correct minions. .SS More On Pillar .sp The pillar data is generated on the Salt master and securely distributed to minions. Salt is not restricted to the pillar sls files when defining the pillar but can retrieve data from external sources. This can be useful when information about an infrastructure is stored in a separate location. .sp Reference information on pillar and the external pillar interface can be found in the Salt Stack documentation: .sp \fBPillar\fP .SS Preseed Minion with Accepted Key .sp In some situations, it is not convenient to wait for a minion to start before accepting its key on the master. For instance, you may want the minion to bootstrap itself as soon as it comes online. You may also want to to let your developers provision new development machines on the fly. .sp There is a general four step process to do this: .INDENT 0.0 .IP 1. 3 Generate the keys on the master: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C root@saltmaster# salt\-key \-\-gen\-keys=[key_name] .ft P .fi .UNINDENT .UNINDENT .sp Pick a name for the key, such as the minion\(aqs id. .INDENT 0.0 .IP 2. 3 Add the public key to the accepted minion folder: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C root@saltmaster# cp key_name.pub /etc/salt/pki/master/minions/[minion_id] .ft P .fi .UNINDENT .UNINDENT .sp It is necessary that the public key file has the same name as your minion id. This is how Salt matches minions with their keys. Also note that the pki folder could be in a different location, depending on your OS or if specified in the master config file. .INDENT 0.0 .IP 3. 3 Distribute the minion keys. .UNINDENT .sp There is no single method to get the keypair to your minion. If you are spooling up minions on EC2, you could pass them in using user_data or a cloud\-init script. If you are handing them off to a team of developers for provisioning dev machines, you will need a secure file transfer. .INDENT 0.0 .INDENT 3.5 .IP "Security Warning" .sp Since the minion key is already accepted on the master, distributing the private key poses a potential security risk. A malicious party will have access to your entire state tree and other sensitive data. .UNINDENT .UNINDENT .INDENT 0.0 .IP 4. 3 Preseed the Minion with the keys .UNINDENT .sp You will want to place the minion keys before starting the salt\-minion daemon: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /etc/salt/pki/minion/minion.pem /etc/salt/pki/minion/minion.pub .ft P .fi .UNINDENT .UNINDENT .sp Once in place, you should be able to start salt\-minion and run \fBsalt\-call state.highstate\fP or any other salt commands that require master authentication. .SS Salt Masterless Quickstart .sp Running a masterless salt\-minion lets you use salt\(aqs configuration management for a single machine. It is also useful for testing out state trees before deploying to a production setup. .sp The only real difference in using a standalone minion is that instead of issuing commands with \fBsalt\fP, we use the \fBsalt\-call\fP command, like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-call \-\-local state.highstate .ft P .fi .UNINDENT .UNINDENT .SS Bootstrap Salt Minion .sp First we need to install the salt minion. The \fI\%salt\-bootstrap\fP script makes this incredibly easy for any OS with a Bourne shell. You can use it like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C wget \-O \- http://bootstrap.saltstack.org | sudo sh .ft P .fi .UNINDENT .UNINDENT .sp Or see the \fI\%salt\-bootstrap\fP documentation for other one liners. Additionally, if you are using \fI\%Vagrant\fP to test out salt, the \fI\%salty\-vagrant\fP tool will provision the VM for you. .SS Create State Tree .sp Now we build an example state tree. This is where the configuration is defined. For more in depth directions, see the \fI\%tutorial\fP\&. .INDENT 0.0 .IP 1. 3 Create the top.sls file: .UNINDENT .sp \fB/srv/salt/top.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aq*\(aq: \- webserver .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP 2. 3 Create our webserver state tree: .UNINDENT .sp \fB/srv/salt/webserver.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: # ID declaration pkg: # state declaration \- installed # function declaration .ft P .fi .UNINDENT .UNINDENT .sp The only thing left is to provision our minion using the highstate command. Salt\-call also gives us an easy way to give us verbose output: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-call \-\-local state.highstate \-l debug .ft P .fi .UNINDENT .UNINDENT .sp The \fB\-\-local\fP flag tells the salt\-minion to look for the state tree in the local file system. Normally the minion copies the state tree from the master and executes it from there. .sp That\(aqs it, good luck! .SS Standalone Minion .sp 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: .INDENT 0.0 .IP \(bu 2 Stand up a master server via States (Salting a Salt Master) .IP \(bu 2 Use salt\-call commands on a system without connectivity to a master .IP \(bu 2 Masterless States, run states entirely from files local to the minion .UNINDENT .SS Telling Salt Call to Run Masterless .sp 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 \fBfile_client\fP configuration option needs to be set. By default the \fBfile_client\fP is set to \fBremote\fP so that the minion knows that file server and pillar data are to be gathered from the master. When setting the \fBfile_client\fP option to \fBlocal\fP the minion is configured to not gather this data from the master. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C file_client: local .ft P .fi .UNINDENT .UNINDENT .sp 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. .SS Running States Masterless .sp 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C file_roots: base: \- /srv/salt .ft P .fi .UNINDENT .UNINDENT .sp 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 \fBfile_client\fP option set to \fBlocal\fP 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. .sp 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. .sp 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. .sp Now the declared state can now be executed with: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-call state.highstate .ft P .fi .UNINDENT .UNINDENT .sp Or the salt\-call command can be executed with the \fB\-\-local\fP flag, this makes it unnecessary to change the configuration file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-call state.highstate \-\-local .ft P .fi .UNINDENT .UNINDENT .SS How Do I Use Salt States? .sp Simplicity, Simplicity, Simplicity .sp Many of the most powerful and useful engineering solutions are founded on simple principles. The Salt SLS system strives to do just that. K.I.S.S. (Keep It Stupidly Simple) .sp The core of the Salt State system is the SLS, or \fBS\fPa\fBL\fPt \fBS\fPtate file. The SLS is a representation of the state in which a system should be in, and is set up to contain this data in a simple format. This is often called configuration management. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This is just the beginning of using states, make sure to read up on pillar \fBPillar\fP next. .UNINDENT .UNINDENT .SS It is All Just Data .sp Before delving into the particulars, it will help to understand that the SLS file is just a data structure under the hood. While understanding that the SLS is just a data structure isn\(aqt critical for understanding and making use of Salt States, it should help bolster knowledge of where the real power is. .sp SLS files are therefore, in reality, just \fI\%dictionaries\fP, \fI\%lists\fP, \fI\%strings\fP, and \fI\%numbers\fP\&. By using this approach Salt can be much more flexible. As one writes more state files, it becomes clearer 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. .sp In the section titled "State Data Structures" a reference exists, explaining in depth how the data is laid out. .SS Default Data \- YAML .sp By default Salt represents the SLS data in what is one of the simplest serialization formats available \- \fI\%YAML\fP\&. .sp A typical SLS file will often look like this in YAML: .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 These demos use some generic service and package names, different distributions often use different names for packages and services. For instance \fIapache\fP should be replaced with \fIhttpd\fP on a Red Hat system. Salt uses the name of the init script, systemd name, upstart name etc. based on what the underlying service management for the platform. To get a list of the available service names on a platform execute the service.get_all salt function. .sp Information on how to make states work with multiple distributions is later in the tutorial. .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: pkg: \- installed service: \- running \- require: \- pkg: apache .ft P .fi .UNINDENT .UNINDENT .sp 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. .sp 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. .sp 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 be installed via the system\(aqs native package manager, and the service state manages a system daemon. .sp The third and fifth 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. .sp Finally, on line six, is the word \fBrequire\fP\&. This is called a Requisite Statement, and it makes sure that the Apache service is only started after a successful installation of the apache package. .SS Adding Configs and Users .sp 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. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .sp This SLS data greatly extends the first example, and includes a config file, a user, a group and new requisite statement: \fBwatch\fP\&. .sp 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 \fBrequire\fP 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. .sp Next,the \fBrequire\fP 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 \fBwatch\fP statement will run the state\(aqs watcher function for any changes to the watched states. So if the package was updated, the config file changed, or the user uid modified, then the service state\(aqs watcher will be run. The service state\(aqs watcher just restarts the service, so in this case, a change in the config file will also trigger a restart of the respective service. .SS Moving Beyond a Single SLS .sp When setting up Salt States in a scalable manner, more than one SLS will need to be used. The above examples were in a single SLS file, but two or more SLS files can be combined to build out a State Tree. The above example also references a file with a strange source \- \fBsalt://apache/httpd.conf\fP\&. That file will need to be available as well. .sp The SLS files are laid out in a directory structure on the Salt master; an SLS is just a file and files to download are just files. .sp The Apache example would be laid out in the root of the Salt file server like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache/init.sls apache/httpd.conf .ft P .fi .UNINDENT .UNINDENT .sp So the httpd.conf is just a file in the apache directory, and is referenced directly. .sp But when using more than one single SLS file, more components can be added to the toolkit. Consider this SSH example: .sp \fBssh/init.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .sp \fBssh/server.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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: file.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 .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Notice that we use two similar ways of denoting that a file is managed by Salt. In the \fI/etc/ssh/sshd_config\fP state section above, we use the \fIfile.managed\fP state declaration whereas with the \fI/etc/ssh/banner\fP state section, we use the \fIfile\fP state declaration and add a \fImanaged\fP attribute to that state declaration. Both ways produce an identical result; the first way \-\- using \fIfile.managed\fP \-\- is merely a shortcut. .UNINDENT .UNINDENT .sp Now our State Tree looks like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache/init.sls apache/httpd.conf ssh/init.sls ssh/server.sls ssh/banner ssh/ssh_config ssh/sshd_config .ft P .fi .UNINDENT .UNINDENT .sp This example now introduces the \fBinclude\fP 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. .sp 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. .sp Note that some of the SLS files are called init.sls, while others are not. More info on what this means can be found in the \fIStates Tutorial\fP\&. .SS Extending Included SLS Data .sp 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. .sp In these examples, the first will add a custom banner to ssh and the second will add more watchers to apache to include mod_python. .sp \fBssh/custom\-server.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- ssh.server extend: /etc/ssh/banner: file: \- source: salt://ssh/custom\-banner .ft P .fi .UNINDENT .UNINDENT .sp \fBpython/mod_python.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- apache extend: apache: service: \- watch: \- pkg: mod_python mod_python: pkg.installed .ft P .fi .UNINDENT .UNINDENT .sp The \fBcustom\-server.sls\fP 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. .sp 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. .INDENT 0.0 .INDENT 3.5 .IP "Using extend with require or watch" .sp The \fBextend\fP statement works differently for \fBrequire\fP or \fBwatch\fP\&. It appends to, rather than replacing the requisite component. .UNINDENT .UNINDENT .SS Understanding the Render System .sp Since SLS data is simply that (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. .sp The default rendering system is the \fByaml_jinja\fP renderer. The \fByaml_jinja\fP renderer will first pass the template through the \fI\%Jinja2\fP templating system, and then through the YAML parser. The benefit here is that full programming constructs are available when creating SLS files. .sp Other renderers available are \fByaml_mako\fP and \fByaml_wempy\fP which each use the \fI\%Mako\fP or \fI\%Wempy\fP templating system respectively rather than the jinja templating system, and more notably, the pure Python or \fBpy\fP and \fBpydsl\fP renderers. The \fBpy\fP renderer allows for SLS files to be written in pure Python, allowing for the utmost level of flexibility and power when preparing SLS data; while the \fBpydsl\fP renderer provides a flexible, domain\-specific language for authoring SLS data in Python. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The templating engines described above aren\(aqt just available in SLS files. They can also be used in \fBfile.managed\fP states, making file management much more dynamic and flexible. Some examples for using templates in managed files can be found in the documentation for the \fBfile states\fP, as well as the \fIMooseFS example\fP below. .UNINDENT .UNINDENT .SS Getting to Know the Default \- yaml_jinja .sp The default renderer \- \fByaml_jinja\fP, allows for use of the jinja templating system. A guide to the Jinja templating system can be found here: \fI\%http://jinja.pocoo.org/docs\fP .sp 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, \fBsalt\fP, \fBgrains\fP, and \fBpillar\fP\&. The \fBsalt\fP object allows for any Salt function to be called from within the template, and \fBgrains\fP allows for the Grains to be accessed from within the template. A few examples: .sp \fBapache/init.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: pkg.installed: {% if grains[\(aqos\(aq] == \(aqRedHat\(aq%} \- name: httpd {% endif %} service.running: {% if grains[\(aqos\(aq] == \(aqRedHat\(aq%} \- 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 .ft P .fi .UNINDENT .UNINDENT .sp This example is simple. If the \fBos\fP grain states that the operating system is Red Hat, then the name of the Apache package and service needs to be httpd. .sp A more aggressive way to use Jinja can be found here, in a module to set up a MooseFS distributed filesystem chunkserver: .sp \fBmoosefs/chunk.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- moosefs {% for mnt in salt[\(aqcmd.run\(aq](\(aqls /dev/data/moose*\(aq).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[\(aqcmd.run\(aq](\(aqls /dev/data/moose*\(aq) %} \- mount: /mnt/moose{{ mnt[\-1] }} \- file: /mnt/moose{{ mnt[\-1] }} {% endfor %} \- file: /etc/mfschunkserver.cfg \- file: /etc/mfshdd.cfg \- file: /var/lib/mfs .ft P .fi .UNINDENT .UNINDENT .sp This example shows much more of the available power of Jinja. Multiple for loops are used to dynamically detect available hard drives and set them up to be mounted, and the \fBsalt\fP object is used multiple times to call shell commands to gather data. .SS Introducing the Python and the PyDSL Renderers .sp 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 an SLS file set to use another renderer can be easily added to the tree. .sp This example shows a very basic Python SLS file: .sp \fBpython/django.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C #!py def run(): \(aq\(aq\(aq Install the django package \(aq\(aq\(aq return {\(aqinclude\(aq: [\(aqpython\(aq], \(aqdjango\(aq: {\(aqpkg\(aq: [\(aqinstalled\(aq]}} .ft P .fi .UNINDENT .UNINDENT .sp This is a very simple example; the first line has an SLS shebang that tells Salt to not use the default renderer, but to use the \fBpy\fP 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 \fBHighState data structure\fP\&. .sp Alternatively, using the \fBpydsl\fP renderer, the above example can be written more succinctly as: .sp \fBpython/django.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C #!pydsl include(\(aqpython\(aq, delayed=True) state(\(aqdjango\(aq).pkg.installed() .ft P .fi .UNINDENT .UNINDENT .sp This Python examples would look like this if they were written in YAML: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- python django: pkg.installed .ft P .fi .UNINDENT .UNINDENT .sp This example clearly illustrates that; one, using the YAML renderer by default is a wise decision and two, unbridled power can be obtained where needed by using a pure Python SLS. .SS Running and debugging salt states. .sp Once the rules in an SLS are ready, they should be tested to ensure they work properly. To invoke these rules, simply execute \fBsalt \(aq*\(aq state.highstate\fP on the command line. If you get back only hostnames with a \fB:\fP after, but no return, chances are there is a problem with one or more of the sls files. On the minion, use the \fBsalt\-call\fP command: \fBsalt\-call state.highstate \-l debug\fP to examine the output for errors. This should help troubleshoot the issue. The minions can also be started in the foreground in debug mode: \fBsalt\-minion \-l debug\fP\&. .SS Next Reading .sp With an understanding of states, the next recommendation is to become familiar with Salt\(aqs pillar interface: .INDENT 0.0 .INDENT 3.5 \fBPillar Walkthrough\fP .UNINDENT .UNINDENT .SS States tutorial, part 1 .sp 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 \fBstates reference\fP\&. .sp 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. .sp \fBBefore continuing\fP make sure you have a working Salt installation by following the \fBinstallation\fP and the \fBconfiguration\fP instructions. .INDENT 0.0 .INDENT 3.5 .IP "Stuck?" .sp There are many ways to \fBget help from the Salt community\fP including our \fI\%mailing list\fP and our \fI\%IRC channel\fP #salt. .UNINDENT .UNINDENT .SS Setting up the Salt State Tree .sp States are stored in text files on the master and transferred to the minions on demand via the master\(aqs File Server. The collection of state files make up the \fIState Tree\fP\&. .sp To start using a central state system in Salt, the Salt File Server must first be set up. Edit the master config file (\fBfile_roots\fP) and uncomment the following lines: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C file_roots: base: \- /srv/salt .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 If you are deploying on FreeBSD via ports, the \fBfile_roots\fP path defaults to \fB/usr/local/etc/salt/states\fP\&. .UNINDENT .UNINDENT .sp Restart the Salt master in order to pick up this change: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pkill salt\-master salt\-master \-d .ft P .fi .UNINDENT .UNINDENT .SS Preparing the Top File .sp On the master, in the directory uncommented in the previous step, (\fB/srv/salt\fP by default), create a new file called \fBtop.sls\fP and add the following: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aq*\(aq: \- webserver .ft P .fi .UNINDENT .UNINDENT .sp The \fItop file\fP is separated into environments (discussed later). The default environment is \fBbase\fP\&. Under the \fBbase\fP environment a collection of minion matches is defined; for now simply specify all hosts (\fB*\fP). .INDENT 0.0 .INDENT 3.5 .IP "Targeting minions" .sp The expressions can use any of the targeting mechanisms used by Salt — minions can be matched by glob, PCRE regular expression, or by \fBgrains\fP\&. For example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aqos:Fedora\(aq: \- match: grain \- webserver .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Create an \fBsls\fP module .sp In the same directory as the \fItop file\fP, create an empty file named \fBwebserver.sls\fP, containing the following: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: # ID declaration pkg: # state declaration \- installed # function declaration .ft P .fi .UNINDENT .UNINDENT .sp The first line, called the \fIID declaration\fP, is an arbitrary identifier. In this case it defines the name of the package to be installed. \fBNOTE:\fP the package name for the Apache httpd web server may differ depending on OS or distro — for example, on Fedora it is \fBhttpd\fP but on Debian/Ubuntu it is \fBapache2\fP\&. .sp The second line, called the \fIstate declaration\fP, defines which of the Salt States we are using. In this example, we are using the \fBpkg state\fP to ensure that a given package is installed. .sp The third line, called the \fIfunction declaration\fP, defines which function in the \fBpkg state\fP module to call. .INDENT 0.0 .INDENT 3.5 .IP "Renderers" .sp States \fIsls\fP 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 \fI\%DSLs\fP are a dime\-a\-dozen and everyone has a favorite. .sp Building the expected data structure is the job of Salt \fBrenderers\fP and they are dead\-simple to write. .sp In this tutorial we will be using YAML in Jinja2 templates, which is the default format. The default can be changed by editing \fBrenderer\fP in the master configuration file. .UNINDENT .UNINDENT .SS Install the package .sp Next, let\(aqs run the state we created. Open a terminal on the master and run: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C % salt \(aq*\(aq state.highstate .ft P .fi .UNINDENT .UNINDENT .sp Our master is instructing all targeted minions to run \fBstate.highstate\fP\&. When a minion executes a highstate call it will download the \fItop file\fP and attempt to match the expressions. When it does match an expression the modules listed for it will be downloaded, compiled, and executed. .sp Once completed, the minion will report back with a summary of all actions taken and all changes made. .INDENT 0.0 .INDENT 3.5 .IP "SLS File Namespace" .sp Note that in the \fIexample\fP above, the SLS file \fBwebserver.sls\fP was referred to simply as \fBwebserver\fP\&. The namespace for SLS files follows a few simple rules: .INDENT 0.0 .IP 1. 3 The \fB\&.sls\fP is discarded (i.e. \fBwebserver.sls\fP becomes \fBwebserver\fP). .IP 2. 3 .INDENT 3.0 .TP .B Subdirectories can be used for better organization. .INDENT 7.0 .IP a. 3 Each subdirectory is represented by a dot. .IP b. 3 \fBwebserver/dev.sls\fP is referred to as \fBwebserver.dev\fP\&. .UNINDENT .UNINDENT .IP 3. 3 A file called \fBinit.sls\fP in a subdirectory is referred to by the path of the directory. So, \fBwebserver/init.sls\fP is referred to as \fBwebserver\fP\&. .IP 4. 3 If both \fBwebserver.sls\fP and \fBwebserver/init.sls\fP happen to exist, \fBwebserver/init.sls\fP will be ignored and \fBwebserver.sls\fP will be the file referred to as \fBwebserver\fP\&. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .IP "Troubleshooting Salt" .sp If the expected output isn\(aqt seen, the following tips can help to narrow down the problem. .INDENT 0.0 .TP .B Turn up logging Salt can be quite chatty when you change the logging setting to \fBdebug\fP: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt\-minion \-l debug .ft P .fi .UNINDENT .UNINDENT .TP .B Run the minion in the foreground By not starting the minion in daemon mode (\fI\-d\fP) one can view any output from the minion as it works: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt\-minion & .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp Increase the default timeout value when running \fBsalt\fP\&. For example, to change the default timeout to 60 seconds: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-t 60 .ft P .fi .UNINDENT .UNINDENT .sp For best results, combine all three: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-minion \-l debug & # On the minion salt \(aq*\(aq state.highstate \-t 60 # On the master .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Next steps .sp This tutorial focused on getting a simple Salt States configuration working. \fBPart 2\fP will build on this example to cover more advanced \fIsls\fP syntax and will explore more of the states that ship with Salt. .SS States tutorial, part 2 .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This tutorial builds on topics covered in \fBpart 1\fP\&. It is recommended that you begin there. .UNINDENT .UNINDENT .sp In the \fBlast part\fP of the Salt States tutorial we covered the basics of installing a package. We will now modify our \fBwebserver.sls\fP file to have requirements, and use even more Salt States. .SS Call multiple States .sp You can specify multiple \fIstate declarations\fP under an \fIID declaration\fP\&. For example, a quick modification to our \fBwebserver.sls\fP to also start Apache if it is not running: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: pkg: \- installed service: \- running \- require: \- pkg: apache .ft P .fi .UNINDENT .UNINDENT .sp Try stopping Apache before running \fBstate.highstate\fP once again and observe the output. .SS Expand the SLS module .sp As you have seen, SLS modules are appended with the file extension \fB\&.sls\fP 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 \fBwebserver\fP and moving and renaming \fBwebserver.sls\fP to \fBwebserver/init.sls\fP\&. Your state directory should now look like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C |\- top.sls \(ga\- webserver/ \(ga\- init.sls .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .IP "Organizing SLS modules" .sp You can place additional \fB\&.sls\fP files in a state file directory. This affords much cleaner organization of your state tree on the filesystem. For example, if we created a \fBwebserver/django.sls\fP file that module would be referenced as \fBwebserver.django\fP\&. .sp In addition, States provide powerful includes and extending functionality which we will cover in \fBPart 3\fP\&. .UNINDENT .UNINDENT .SS Require other states .sp We now have a working installation of Apache so let\(aqs add an HTML file to customize our website. It isn\(aqt exactly useful to have a website without a webserver so we don\(aqt want Salt to install our HTML file until Apache is installed and running. Include the following at the bottom of your \fBwebserver/init.sls\fP file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: pkg: \- installed service: \- running \- require: \- pkg: apache /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 .ft P .fi .UNINDENT .UNINDENT .sp \fBline 9\fP is the \fIID declaration\fP\&. In this example it is the location we want to install our custom HTML file. (\fBNote:\fP the default location that Apache serves may differ from the above on your OS or distro. \fB/srv/www\fP could also be a likely place to look.) .sp \fBLine 10\fP the \fIstate declaration\fP\&. This example uses the Salt \fBfile state\fP\&. .sp \fBLine 11\fP is the \fIfunction declaration\fP\&. The \fBmanaged function\fP will download a file from the master and install it in the location specified. .sp \fBLine 12\fP is a \fIfunction arg declaration\fP which, in this example, passes the \fBsource\fP argument to the \fBmanaged function\fP\&. .sp \fBLine 13\fP is a \fIrequisite declaration\fP\&. .sp \fBLine 14\fP is a \fIrequisite reference\fP which refers to a state and an ID. In this example, it is referring to the \fBID declaration\fP from our example in \fBpart 1\fP\&. This declaration tells Salt not to install the HTML file until Apache is installed. .sp Next, create the \fBindex.html\fP file and save it in the \fBwebserver\fP directory: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C Salt rocks

This file brought to you by Salt

.ft P .fi .UNINDENT .UNINDENT .sp Last, call \fBstate.highstate\fP again and the minion will fetch and execute the highstate as well as our HTML file from the master using Salt\(aqs File Server: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq state.highstate .ft P .fi .UNINDENT .UNINDENT .sp Verify that Apache is now serving your custom HTML. .INDENT 0.0 .INDENT 3.5 .IP "\fBrequire\fP vs. \fBwatch\fP" .sp There are two \fIrequisite declarations\fP, “require” and “watch”. Not every state supports “watch”. The \fBservice state\fP does support “watch” and will restart a service based on the watch condition. .sp 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /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 \- require: \- pkg: apache .ft P .fi .UNINDENT .UNINDENT .sp If the pkg and service names differ on your OS or distro of choice you can specify each one separately using a \fIname declaration\fP which explained in \fBPart 3\fP\&. .UNINDENT .UNINDENT .SS Next steps .sp In \fBpart 3\fP we will discuss how to use includes, extends and templating to make a more complete State Tree configuration. .SS States tutorial, part 3 .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This tutorial builds on topics covered in \fBpart 1\fP and \fBpart 2\fP\&. It is recommended that you begin there. .UNINDENT .UNINDENT .sp This part of the tutorial will cover more advanced templating and configuration techniques for \fBsls\fP files. .SS Templating SLS modules .sp SLS modules may require programming logic or inline execution. This is accomplished with module templating. The default module templating system used is \fI\%Jinja2\fP and may be configured by changing the \fBrenderer\fP value in the master config. .sp All states are passed through a templating system when they are initially read. To make use of the templating system, simply add some templating markup. An example of an sls module with templating markup may look like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% for usr in \(aqmoe\(aq,\(aqlarry\(aq,\(aqcurly\(aq %} {{ usr }}: user.present {% endfor %} .ft P .fi .UNINDENT .UNINDENT .sp This templated sls file once generated will look like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C moe: user.present larry: user.present curly: user.present .ft P .fi .UNINDENT .UNINDENT .sp Here\(aqs a more complex example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% for usr in \(aqmoe\(aq,\(aqlarry\(aq,\(aqcurly\(aq %} {{ usr }}: group: \- present user: \- present \- gid_from_name: True \- require: \- group: {{ usr }} {% endfor %} .ft P .fi .UNINDENT .UNINDENT .SS Using Grains in SLS modules .sp Often times a state will need to behave differently on different systems. \fBSalt grains\fP objects are made available in the template context. The \fIgrains\fP can be used from within sls modules: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: pkg.installed: {% if grains[\(aqos\(aq] == \(aqRedHat\(aq %} \- name: httpd {% elif grains[\(aqos\(aq] == \(aqUbuntu\(aq %} \- name: apache2 {% endif %} .ft P .fi .UNINDENT .UNINDENT .SS Calling Salt modules from templates .sp 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. .sp The Salt module functions are also made available in the template context as \fBsalt:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C moe: user: \- present \- gid: {{ salt[\(aqfile.group_to_gid\(aq](\(aqsome_group_that_exists\(aq) }} .ft P .fi .UNINDENT .UNINDENT .sp Note that for the above example to work, \fBsome_group_that_exists\fP must exist before the state file is processed by the templating engine. .sp Below is an example that uses the \fBnetwork.hw_addr\fP function to retrieve the MAC address for eth0: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt[\(aqnetwork.hw_addr\(aq](\(aqeth0\(aq) .ft P .fi .UNINDENT .UNINDENT .SS Advanced SLS module syntax .sp Lastly, we will cover some incredibly useful techniques for more complex State trees. .SS \fIInclude declaration\fP .sp A previous example showed how to spread a Salt tree across several files. Similarly, \fBrequisites\fP span multiple files by using an \fIinclude declaration\fP\&. For example: .sp \fBpython/python\-libs.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C python\-dateutil: pkg.installed .ft P .fi .UNINDENT .UNINDENT .sp \fBpython/django.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- python.python\-libs django: pkg.installed: \- require: \- pkg: python\-dateutil .ft P .fi .UNINDENT .UNINDENT .SS \fIExtend declaration\fP .sp You can modify previous declarations by using an \fIextend declaration\fP\&. For example the following modifies the Apache tree to also restart Apache when the vhosts file is changed: .sp \fBapache/apache.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: pkg.installed .ft P .fi .UNINDENT .UNINDENT .sp \fBapache/mywebsite.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- apache.apache extend: apache: service: \- running \- watch: \- file: /etc/httpd/extra/httpd\-vhosts.conf /etc/httpd/extra/httpd\-vhosts.conf: file.managed: \- source: salt://apache/httpd\-vhosts.conf .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .IP "Using extend with require or watch" .sp The \fBextend\fP statement works differently for \fBrequire\fP or \fBwatch\fP\&. It appends to, rather than replacing the requisite component. .UNINDENT .UNINDENT .SS \fIName declaration\fP .sp You can override the \fIID declaration\fP by using a \fIname declaration\fP\&. For example, the previous example is a bit more maintainable if rewritten as follows: .sp \fBapache/mywebsite.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- apache.apache extend: apache: service: \- running \- watch: \- file: mywebsite mywebsite: file.managed: \- name: /etc/httpd/extra/httpd\-vhosts.conf \- source: salt://apache/httpd\-vhosts.conf .ft P .fi .UNINDENT .UNINDENT .SS \fINames declaration\fP .sp Even more powerful is using a \fInames declaration\fP to override the \fIID declaration\fP 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C stooges: user.present: \- names: \- moe \- larry \- curly .ft P .fi .UNINDENT .UNINDENT .SS Next steps .sp In \fBpart 4\fP we will discuss how to use salt\(aqs \fBfile_roots\fP to set up a workflow in which states can be "promoted" from dev, to QA, to production. .SS States tutorial, part 4 .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This tutorial builds on topics covered in \fBpart 1\fP, \fBpart 2\fP and \fBpart 3\fP\&. It is recommended that you begin there. .UNINDENT .UNINDENT .sp This part of the tutorial will show how to use salt\(aqs \fBfile_roots\fP to set up a workflow in which states can be "promoted" from dev, to QA, to production. .SS Salt fileserver path inheritance .sp Salt\(aqs fileserver allows for more than one root directory per environment, like in the below example, which uses both a local directory and a secondary location shared to the salt master via NFS: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # In the master config file (/etc/salt/master) file_roots: base: \- /srv/salt \- /mnt/salt\-nfs/base .ft P .fi .UNINDENT .UNINDENT .sp Salt\(aqs fileserver collapses the list of root directories into a single virtual environment containing all files from each root. If the same file exists at the same relative path in more than one root, then the top\-most match "wins". For example, if \fB/srv/salt/foo.txt\fP and \fB/mnt/salt\-nfs/base/foo.txt\fP both exist, then \fBsalt://foo.txt\fP will point to \fB/srv/salt/foo.txt\fP\&. .SS Environment configuration .sp Configure a multiple\-environment setup like so: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C file_roots: base: \- /srv/salt/prod qa: \- /srv/salt/qa \- /srv/salt/prod dev: \- /srv/salt/dev \- /srv/salt/qa \- /srv/salt/prod .ft P .fi .UNINDENT .UNINDENT .sp Given the path inheritance described above, files within \fB/srv/salt/prod\fP would be available in all environments. Files within \fB/srv/salt/qa\fP would be available in both \fBqa\fP, and \fBdev\fP\&. Finally, the files within \fB/srv/salt/dev\fP would only be available within the \fBdev\fP environment. .sp Based on the order in which the roots are defined, new files/states can be placed within \fB/srv/salt/dev\fP, and pushed out to the dev hosts for testing. .sp Those files/states can then be moved to the same relative path within \fB/srv/salt/qa\fP, and they are now available only in the \fBdev\fP and \fBqa\fP environments, allowing them to be pushed to QA hosts and tested. .sp Finally, if moved to the same relative path within \fB/srv/salt/prod\fP, the files are now available in all three environments. .SS Practical Example .sp As an example, consider a simple website, installed to \fB/var/www/foobarcom\fP\&. Below is a top.sls that can be used to deploy the website: .sp \fB/srv/salt/prod/top.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aqweb*prod*\(aq: \- webserver.foobarcom qa: \(aqweb*qa*\(aq: \- webserver.foobarcom dev: \(aqweb*dev*\(aq: \- webserver.foobarcom .ft P .fi .UNINDENT .UNINDENT .sp Using pillar, roles can be assigned to the hosts: .sp \fB/srv/pillar/top.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aqweb*prod*\(aq: \- webserver.prod \(aqweb*qa*\(aq: \- webserver.qa \(aqweb*dev*\(aq: \- webserver.dev .ft P .fi .UNINDENT .UNINDENT .sp \fB/srv/pillar/webserver/prod.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C webserver_role: prod .ft P .fi .UNINDENT .UNINDENT .sp \fB/srv/pillar/webserver/qa.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C webserver_role: qa .ft P .fi .UNINDENT .UNINDENT .sp \fB/srv/pillar/webserver/dev.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C webserver_role: dev .ft P .fi .UNINDENT .UNINDENT .sp And finally, the SLS to deploy the website: .sp \fB/srv/salt/prod/webserver/foobarcom.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if pillar.get(\(aqwebserver_role\(aq, \(aq\(aq) %} /var/www/foobarcom: file.recurse: \- source: salt://webserver/src/foobarcom \- env: {{ pillar[\(aqwebserver_role\(aq] }} \- user: www \- group: www \- dir_mode: 755 \- file_mode: 644 {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp Given the above SLS, the source for the website should initially be placed in \fB/srv/salt/dev/webserver/src/foobarcom\fP\&. .sp First, let\(aqs deploy to dev. Given the configuration in the top file, this can be done using \fBstate.highstate\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-\-pillar \(aqwebserver_role:dev\(aq state.highstate .ft P .fi .UNINDENT .UNINDENT .sp However, in the event that it is not desirable to apply all states configured in the top file (which could be likely in more complex setups), it is possible to apply just the states for the \fBfoobarcom\fP website, using \fBstate.sls\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-\-pillar \(aqwebserver_role:dev\(aq state.sls webserver.foobarcom .ft P .fi .UNINDENT .UNINDENT .sp Once the site has been tested in dev, then the files can be moved from \fB/srv/salt/dev/webserver/src/foobarcom\fP to \fB/srv/salt/qa/webserver/src/foobarcom\fP, and deployed using the following: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-\-pillar \(aqwebserver_role:qa\(aq state.sls webserver.foobarcom .ft P .fi .UNINDENT .UNINDENT .sp Finally, once the site has been tested in qa, then the files can be moved from \fB/srv/salt/qa/webserver/src/foobarcom\fP to \fB/srv/salt/prod/webserver/src/foobarcom\fP, and deployed using the following: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-\-pillar \(aqwebserver_role:prod\(aq state.sls webserver.foobarcom .ft P .fi .UNINDENT .UNINDENT .sp Thanks to Salt\(aqs fileserver inheritance, even though the files have been moved to within \fB/srv/salt/prod\fP, they are still available from the same \fBsalt://\fP URI in both the qa and dev environments. .SS Continue learning .sp The best way to continue learning about Salt States is to read through the \fBreference documentation\fP and to look through examples of existing \fIstate trees\fP\&. Many pre\-configured state trees can be found on Github in the \fI\%saltstack\-formulas\fP collection of repositories. .sp If you have any questions, suggestions, or just want to chat with other people who are using Salt, we have a very \fBactive community\fP and we\(aqd love to hear from you. .SS Salt Stack Walkthrough .SS Welcome! .sp Welcome to Salt Stack! I am excited that you are interested in Salt and starting down the path to better infrastructure management. I developed (and am continuing to develop) Salt with the goal of making the best software available to manage computers of almost any kind. I hope you enjoy working with Salt and that the software can solve your real world needs! .INDENT 0.0 .IP \(bu 2 Thomas S Hatch .IP \(bu 2 Salt creator and chief developer .IP \(bu 2 CTO of Salt Stack, Inc. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 This is the first of a series of walkthroughs and serves as the best entry point for people new to Salt, after this be sure to read up on pillar and more on states: .sp \fBStarting States\fP .sp \fBPillar Walkthrough\fP .UNINDENT .UNINDENT .SS Getting Started .SS What is Salt? .sp Salt is a different approach to infrastructure management, it is founded on the idea that high speed communication with large numbers of systems can open up new capabilities. This approach makes Salt a powerful multitasking system that can solve many specific problems in an infrastructure. The backbone of Salt is the remote execution engine, which creates a high speed, secure and bi\-directional communication net for groups of systems. On top of this communication system Salt provides an extremely fast, flexible and easy to use configuration management system called \fBSalt States\fP\&. .sp This unique approach to management makes for a transparent control system that is not only amazingly easy to set up and use, but also capable of solving very complex problems in infrastructures; as will be explored in this walk through. .sp Salt is being used today by some of the largest infrastructures in the world and has a proven ability to scale to astounding proportions without modification. With the proven ability to scale out well beyond many tens of thousands of servers, Salt has also proven to be an excellent choice for small deployments as well, lowering compute and management overhead for infrastructures as small as just a few systems. .SS Installing Salt .sp Salt Stack has been made to be very easy to install and get started. Setting up Salt should be as easy as installing Salt via distribution packages on Linux or via the Windows installer. The \fBinstallation documents\fP cover specific platform installation in depth. .SS Starting Salt .sp Salt functions on a master/minion topology. A master server acts as a central control bus for the clients (called minions), and the minions connect back to the master. .SS Setting Up the Salt Master .sp Turning on the Salt Master is easy, just turn it on! The default configuration is suitable for the vast majority of installations. The Salt master can be controlled by the local Linux/Unix service manager: .sp On Systemd based platforms (OpenSuse, Fedora): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C systemctl start salt\-master .ft P .fi .UNINDENT .UNINDENT .sp On Upstart based systems (Ubuntu, older Fedora/RHEL): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C service salt\-master start .ft P .fi .UNINDENT .UNINDENT .sp On SysV Init systems (Debian, Gentoo etc.): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /etc/init.d/salt\-master start .ft P .fi .UNINDENT .UNINDENT .sp Or the master can be started directly on the command line: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-master \-d .ft P .fi .UNINDENT .UNINDENT .sp The Salt Master can also be started in the foreground in debug mode, thus greatly increasing the command output: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-master \-l debug .ft P .fi .UNINDENT .UNINDENT .sp The Salt Master needs to bind to 2 TCP network ports on the system, these ports are 4505 and 4506. For more in depth information on firewalling these ports, the firewall tutorial is available \fBhere\fP\&. .SS Setting up a Salt Minion .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The Salt Minion can operate with or without a Salt Master. This walkthrough assumes that the minion will be connected to the master, for information on how to run a master\-less minion please see the masterless quickstart guide: .sp \fBMasterless Minion Quickstart\fP .UNINDENT .UNINDENT .sp The Salt Minion only needs to be aware of one piece of information to run, the network location of the master. By default the minion will look for the DNS name \fBsalt\fP for the master, making the easiest approach to set internal DNS to resolve the name \fBsalt\fP back to the Salt Master IP. Otherwise the minion configuration file will need to be edited, edit the configuration option \fBmaster\fP to point to the DNS name or the IP of the Salt Master: .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The default location of the configuration files is \fB/etc/salt\fP\&. Most platforms adhere to this convention, but platforms such as FreeBSD and Microsoft Windows place this file in different locations. .UNINDENT .UNINDENT .sp \fB/etc/salt/minion:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C master: saltmaster.example.com .ft P .fi .UNINDENT .UNINDENT .sp Now that the master can be found, start the minion in the same way as the master; with the platform init system, or via the command line directly: .sp As a daemon: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-minion \-d .ft P .fi .UNINDENT .UNINDENT .sp In the foreground in debug mode: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-minion \-l debug .ft P .fi .UNINDENT .UNINDENT .sp Now that the minion is started it will generate cryptographic keys and attempt to connect to the master. The next step is to venture back to the master server and accept the new minion\(aqs public key. .sp When the minion is started, it will generate an \fBid\fP value. This is the name by which the minion will attempt to authenticate to the master. The following steps are attempted, in order to try to find a value that is not \fBlocalhost\fP: .INDENT 0.0 .IP 1. 3 \fB/etc/hostname\fP is checked (non\-Windows only) \fBNote: Not used currently, will be as of version 0.17.0.\fP .IP 2. 3 The Python function \fBsocket.getfqdn()\fP is run .IP 3. 3 \fB/etc/hosts\fP (\fB%WINDIR%\esystem32\edrivers\eetc\ehosts\fP on Windows hosts) is checked for hostnames that map to anything within \fB127.0.0.0/8\fP\&. .UNINDENT .sp If none of the above are able to produce an id which is not \fBlocalhost\fP, then a sorted list of IP addresses on the minion (excluding any within \fB127.0.0.0/8\fP) is inspected. The first publicly\-routable IP address is used, if there is one. Otherwise, the first privately\-routable IP address is used. .sp If all else fails, then \fBlocalhost\fP is used as a fallback. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Overriding the \fBid\fP .sp The minion id can be manually specified using the \fBid\fP parameter in the minion config file. .UNINDENT .UNINDENT .SS Using salt\-key .sp Salt authenticates minions using public key encryption and authentication. For a minion to start accepting commands from the master the minion keys need to be accepted. The \fBsalt\-key\fP command is used to manage all of the keys on the master. To list the keys that are on the master run a salt\-key list command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-key \-L .ft P .fi .UNINDENT .UNINDENT .sp The keys that have been rejected, accepted and pending acceptance are listed. The easiest way to accept the minion key is to accept all pending keys: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-key \-A .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Keys should be verified! The secure thing to do before accepting a key is to run \fBsalt\-key \-p minion\-id\fP to print the public key for the minion. This can then be compared against the minion\(aqs public key file, which is located (on the minion, of course) at \fB/etc/salt/pki/minion/minion.pub\fP\&. .sp On the master: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # salt\-key \-p foo.domain.com Accepted Keys: foo.domain.com: \-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0JcA0IEp/yqghK5V2VLM jbG7FWV6qtw/ubTDBnpDGQgrvSNOtd0QcJsAzAtDcHwrudQgyxTZGVJqPY7gLc7P 5b4EFWt5E1w3+KZ+XXy4YtW5oOzVN5BvsJ85g7c0TUnmjL7p3MUUXE4049Ue/zgX jtbFJ0aa1HB8bnlQdWWOeflYRNEQL8482ZCmXXATFP1l5uJA9Pr6/ltdWtQTsXUA bEseUGEpmq83vAkwtZIyJRG2cJh8ZRlJ6whSMg6wr7lFvStHQQzKHt9pRPml3lLK ba2X07myAEJq/lpJNXJm5bkKV0+o8hqYQZ1ndh9HblHb2EoDBNbuIlhYft1uv8Tp 8beaEbq8ZST082sS/NjeL7W1T9JS6w2rw4GlUFuQlbqW8FSl1VDo+Alxu0VAr4GZ gZpl2DgVoL59YDEVrlB464goly2c+eY4XkNT+JdwQ9LwMr83/yAAG6EGNpjT3pZg Wey7WRnNTIF7H7ISwEzvik1GrhyBkn6K1RX3uAf760ZsQdhxwHmop+krgVcC0S93 xFjbBFF3+53mNv7BNPPgl0iwgA9/WuPE3aoE0A8Cm+Q6asZjf8P/h7KS67rIBEKV zrQtgf3aZBbW38CT4fTzyWAP138yrU7VSGhPMm5KfTLywNsmXeaR5DnZl6GGNdL1 fZDM+J9FIGb/50Ee77saAlUCAwEAAQ== \-\-\-\-\-END PUBLIC KEY\-\-\-\-\- .ft P .fi .UNINDENT .UNINDENT .sp On the minion: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # cat /etc/salt/pki/minion/minion.pub \-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0JcA0IEp/yqghK5V2VLM jbG7FWV6qtw/ubTDBnpDGQgrvSNOtd0QcJsAzAtDcHwrudQgyxTZGVJqPY7gLc7P 5b4EFWt5E1w3+KZ+XXy4YtW5oOzVN5BvsJ85g7c0TUnmjL7p3MUUXE4049Ue/zgX jtbFJ0aa1HB8bnlQdWWOeflYRNEQL8482ZCmXXATFP1l5uJA9Pr6/ltdWtQTsXUA bEseUGEpmq83vAkwtZIyJRG2cJh8ZRlJ6whSMg6wr7lFvStHQQzKHt9pRPml3lLK ba2X07myAEJq/lpJNXJm5bkKV0+o8hqYQZ1ndh9HblHb2EoDBNbuIlhYft1uv8Tp 8beaEbq8ZST082sS/NjeL7W1T9JS6w2rw4GlUFuQlbqW8FSl1VDo+Alxu0VAr4GZ gZpl2DgVoL59YDEVrlB464goly2c+eY4XkNT+JdwQ9LwMr83/yAAG6EGNpjT3pZg Wey7WRnNTIF7H7ISwEzvik1GrhyBkn6K1RX3uAf760ZsQdhxwHmop+krgVcC0S93 xFjbBFF3+53mNv7BNPPgl0iwgA9/WuPE3aoE0A8Cm+Q6asZjf8P/h7KS67rIBEKV zrQtgf3aZBbW38CT4fTzyWAP138yrU7VSGhPMm5KfTLywNsmXeaR5DnZl6GGNdL1 fZDM+J9FIGb/50Ee77saAlUCAwEAAQ== \-\-\-\-\-END PUBLIC KEY\-\-\-\-\- .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .SS Sending the First Commands .sp Now that the minion is connected to the master and authenticated, the master can start to command the minion. Salt commands allow for a vast set of functions to be executed and for specific minions and groups of minions to be targeted for execution. This makes the \fBsalt\fP command very powerful, but the command is also very usable, and easy to understand. .sp The \fBsalt\fP command is comprised of command options, target specification, the function to execute, and arguments to the function. A simple command to start with looks like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp The \fB*\fP is the target, which specifies all minions, and \fBtest.ping\fP tells the minion to run the \fBtest.ping\fP function. The result of running this command will be the master instructing all of the minions to execute \fBtest.ping\fP in parallel and return the result. This is not an actual ICMP ping, but rather a simple function which returns \fBTrue\fP\&. Using \fBtest.ping\fP is a good way of confirming that a minion is connected. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Each minion registers itself with a unique minion id. This id defaults to the minion\(aqs hostname, but can be explicitly defined in the minion config as well by using the \fBid\fP parameter. .UNINDENT .UNINDENT .SS Getting to Know the Functions .sp Salt comes with a vast library of functions available for execution, and Salt functions are self documenting. To see what functions are available on the minions execute the \fBsys.doc\fP function: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sys.doc .ft P .fi .UNINDENT .UNINDENT .sp This will display a very large list of available functions and documentation on them, this documentation is also available \fBhere\fP\&. .sp These functions cover everything from shelling out to package management to manipulating database servers. They comprise a powerful system management API which is the backbone to Salt configuration management and many other aspects of Salt. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Salt comes with many plugin systems. The functions that are available via the \fBsalt\fP command are called \fBExecution Modules\fP\&. .UNINDENT .UNINDENT .SS Helpful Functions to Know .sp The \fBcmd\fP module contains functions to shell out on minions, such as \fBcmd.run\fP and \fBcmd.run_all\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run \(aqls \-l /etc\(aq .ft P .fi .UNINDENT .UNINDENT .sp The \fBpkg\fP functions automatically map local system package managers to the same salt functions. This means that \fBpkg.install\fP will install packages via yum on Red Hat based systems, apt on Debian systems, etc.: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install vim .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Some custom Linux spins and derivatives of other distros are not properly detected by Salt. If the above command returns an error message saying that \fBpkg.install\fP is not available, then you may need to override the pkg provider. This process is explained \fBhere\fP\&. .UNINDENT .UNINDENT .sp The \fBnetwork.interfaces\fP function will list all interfaces on a minion, along with their IP addresses, netmasks, MAC addresses, etc: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq network.interfaces .ft P .fi .UNINDENT .UNINDENT .SS \fBsalt\-call\fP .sp The examples so far have described running commands from the Master using the \fBsalt\fP command, but when troubleshooting it can be more beneficial to login to the minion directly and use \fBsalt\-call\fP\&. Doing so allows you to see the minion log messages specific to the command you are running (which are \fInot\fP part of the return data you see when running the command from the Master using \fBsalt\fP), making it unnecessary to tail the minion log. More information on \fBsalt\-call\fP and how to use it can be found \fIhere\fP\&. .SS Grains .sp Salt uses a system called \fBGrains\fP to build up static data about minions. This data includes information about the operating system that is running, CPU architecture and much more. The grains system is used throughout Salt to deliver platform data to many components and to users. .sp Grains can also be statically set, this makes it easy to assign values to minions for grouping and managing. A common practice is to assign grains to minions to specify what the role or roles a minion might be. These static grains can be set in the minion configuration file or via the \fBgrains.setval\fP function. .SS Targeting .sp Salt allows for minions to be targeted based on a wide range of criteria. The default targeting system uses globular expressions to match minions, hence if there are minions named \fBlarry1\fP, \fBlarry2\fP, \fBcurly1\fP and \fBcurly2\fP, a glob of \fBlarry*\fP will match \fBlarry1\fP and \fBlarry2\fP, and a glob of \fB*1\fP will match \fBlarry1\fP and \fBcurly1\fP\&. .sp Many other targeting systems can be used other than globs, these systems include: .INDENT 0.0 .TP .B Regular Expressions Target using PCRE compliant regular expressions .TP .B Grains Target based on grains data: \fBTargeting with Grains\fP .TP .B Pillar Target based on pillar data: \fBTargeting with Pillar\fP .TP .B IP Target based on IP addr/subnet/range .TP .B Compound Create logic to target based on multiple targets: \fBTargeting with Compound\fP .TP .B Nodegroup Target with nodegroups: \fBTargeting with Nodegroup\fP .UNINDENT .sp The concepts of targets are used on the command line with salt, but also function in many other areas as well, including the state system and the systems used for ACLs and user permissions. .SS Passing in Arguments .sp Many of the functions available accept arguments, these arguments can be passed in on the command line: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install vim .ft P .fi .UNINDENT .UNINDENT .sp This example passes the argument \fBvim\fP to the pkg.install function, since many functions can accept more complex input then just a string the arguments are parsed through YAML, allowing for more complex data to be sent on the command line: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq test.echo \(aqfoo: bar\(aq .ft P .fi .UNINDENT .UNINDENT .sp In this case Salt translates the string \(aqfoo: bar\(aq into the dictionary "{\(aqfoo\(aq: \(aqbar\(aq}" .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Any line that contains a newline will not be parsed by yaml. .UNINDENT .UNINDENT .SS Salt States .sp Now that the basics are covered the time has come to evaluate \fBStates\fP\&. Salt \fBStates\fP, or the \fBState System\fP is the component of Salt made for configuration management. The State system is a fully functional configuration management system which has been designed to be exceptionally powerful while still being simple to use, fast, lightweight, deterministic and with salty levels of flexibility. .sp The state system is already available with a basic salt setup, no additional configuration is required, states can be set up immediately. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Before diving into the state system, a brief overview of how states are constructed will make many of the concepts clearer. Salt states are based on data modeling, and build on a low level data structure that is used to execute each state function. Then more logical layers are built on top of each other. The high layers of the state system which this tutorial will cover consists of everything that needs to be known to use states, the two high layers covered here are the \fIsls\fP layer and the highest layer \fIhighstate\fP\&. .sp Again, knowing that there are many layers of data management, will help with understanding states, but they never need to be used. Just as understanding how a compiler functions when learning a programming language, understanding what is going on under the hood of a configuration management system will also prove to be a valuable asset. .UNINDENT .UNINDENT .SS The First SLS Formula .sp The state system is built on sls formulas, these formulas are built out in files on Salt\(aqs file server. To make a very basic sls formula open up a file under /srv/salt named vim.sls and get vim installed: .sp \fB/srv/salt/vim.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C vim: pkg.installed .ft P .fi .UNINDENT .UNINDENT .sp Now install vim on the minions by calling the sls directly: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq state.sls vim .ft P .fi .UNINDENT .UNINDENT .sp This command will invoke the state system and run the named sls which was just created, \fBvim\fP\&. .sp Now, to beef up the vim sls formula, a vimrc can be added: .sp \fB/srv/salt/vim.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C vim: pkg.installed /etc/vimrc: file.managed: \- source: salt://vimrc \- mode: 644 \- user: root \- group: root .ft P .fi .UNINDENT .UNINDENT .sp Now the desired vimrc needs to be copied into the Salt file server to /srv/salt/vimrc, in Salt everything is a file, so no path redirection needs to be accounted for. The vimrc file is placed right next to the vim.sls file. The same command as above can be executed to all the vim sls formulas and now include managing the file. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Salt does not need to be restarted/reloaded or have the master manipulated in any way when changing sls formulas, they are instantly available. .UNINDENT .UNINDENT .SS Adding Some Depth .sp Obviously maintaining sls formulas right in the root of the file server will not scale out to reasonably sized deployments. This is why more depth is required. Start by making an nginx formula a better way, make an nginx subdirectory and add an init.sls file: .sp \fB/srv/salt/nginx/init.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C nginx: pkg: \- installed service: \- running \- require: \- pkg: nginx .ft P .fi .UNINDENT .UNINDENT .sp A few things are introduced in this sls formula, first is the service statement which ensures that the nginx service is running, but the nginx service can\(aqt be started unless the package is installed, hence the \fBrequire\fP\&. The \fBrequire\fP statement makes sure that the required component is executed before and that it results in success. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The \fIrequire\fP option belongs to a family of options called \fIrequisites\fP\&. Requisites are a powerful component of Salt States, for more information on how requisites work and what is available see: \fBRequisites\fP Also evaluation ordering is available in Salt as well: \fBOrdering States\fP .UNINDENT .UNINDENT .sp Now this new sls formula has a special name, \fBinit.sls\fP, when an sls formula is named \fBinit.sls\fP it inherits the name of the directory path that contains it, so this formula can be referenced via the following command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq state.sls nginx .ft P .fi .UNINDENT .UNINDENT .sp Now that subdirectories can be used the vim.sls formula can be cleaned up, but to make things more flexible (and to illustrate another point of course), move the vim.sls and vimrc into a new subdirectory called \fBedit\fP and change the vim.sls file to reflect the change: .sp \fB/srv/salt/edit/vim.sls:\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C vim: pkg.installed /etc/vimrc: file.managed: \- source: salt://edit/vimrc \- mode: 644 \- user: root \- group: root .ft P .fi .UNINDENT .UNINDENT .sp The only change in the file is fixing the source path for the vimrc file. Now the formula is referenced as \fBedit.vim\fP because it resides in the edit subdirectory. Now the edit subdirectory can contain formulas for emacs, nano, joe or any other editor that may need to be deployed. .SS Next Reading .sp Two walkthroughs are specifically recommended at this point. First, a deeper run through States, followed by an explanation of Pillar. .INDENT 0.0 .IP 1. 3 \fBStarting States\fP .IP 2. 3 \fBPillar Walkthrough\fP .UNINDENT .sp An understanding of Pillar is extremely helpful in using States. .SS Getting Deeper Into States .sp Two more in\-depth States tutorials exist, which delve much more deeply into States functionality. .INDENT 0.0 .IP 1. 3 Thomas\(aq original states tutorial, \fBHow Do I Use Salt States?\fP, covers much more to get off the ground with States. .IP 2. 3 The \fBStates Tutorial\fP also provides a fantastic introduction. .UNINDENT .sp These tutorials include much more in depth information including templating sls formulas etc. .SS So Much More! .sp This concludes the initial Salt walkthrough, but there are many more things to learn still! These documents will cover important core aspects of Salt: .INDENT 0.0 .IP \(bu 2 \fBPillar\fP .IP \(bu 2 \fBJob Management\fP .UNINDENT .sp A few more tutorials are also available: .INDENT 0.0 .IP \(bu 2 \fBRemote Execution Tutorial\fP .IP \(bu 2 \fBStandalone Minion\fP .UNINDENT .sp This still is only scratching the surface, many components such as the reactor and event systems, extending Salt, modular components and more are not covered here. For an overview of all Salt features and documentation, look at the \fBTable of Contents\fP\&. .SH ACCESS CONTROL SYSTEM .sp New in version 0.10.4. .sp Salt maintains a standard system used to open granular control to non administrative users to execute Salt commands. The access control system has been applied to all systems used to configure access to non administrative control interfaces in Salt.These interfaces include, the \fBpeer\fP system, the \fBexternal auth\fP system and the \fBclient acl\fP system. .sp The access control system mandated a standard configuration syntax used in all of the three aforementioned systems. While this adds functionality to the configuration in 0.10.4, it does not negate the old configuration. .sp Now specific functions can be opened up to specific minions from specific users in the case of external auth and client ACLs, and for specific minions in the case of the peer system. .sp The access controls are manifested using matchers in these configurations: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C client_acl: fred: \- web\e*: \- pkg.list_pkgs \- test.* \- apache.* .ft P .fi .UNINDENT .UNINDENT .sp In the above example, fred is able to send commands only to minions which match the specified glob target. This can be expanded to include other functions for other minions based on standard targets. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C external_auth: pam: dave: \- test.ping \- mongo\e*: \- network.* \- log\e*: \- network.* \- pkg.* \- \(aqG@os:RedHat\(aq: \- kmod.* steve: \- .* .ft P .fi .UNINDENT .UNINDENT .sp The above allows for all minions to be hit by test.ping by dave, and adds a few functions that dave can execute on other minions. It also allows steve unrestricted access to salt commands. .SH EXTERNAL AUTHENTICATION SYSTEM .sp Salt 0.10.4 comes with a fantastic new way to open up running Salt commands to users. This system allows for Salt itself to pass through authentication to any authentication system (The Unix PAM system was the first) to determine if a user has permission to execute a Salt command. .sp The external authentication system allows for specific users to be granted access to execute specific functions on specific minions. Access is configured in the master configuration file, and uses the new access control system: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C external_auth: pam: thatch: \- \(aqweb*\(aq: \- test.* \- network.* steve: \- .* .ft P .fi .UNINDENT .UNINDENT .sp So, the above allows the user thatch to execute functions in the test and network modules on the minions that match the web* target. User steve is given unrestricted access to minion commands. .sp The external authentication system can then be used from the command line by any user on the same system as the master with the \fI\-a\fP option: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ salt \-a pam web\e* test.ping .ft P .fi .UNINDENT .UNINDENT .sp The system will ask the user for the credentials required by the authentication system and then publish the command. .SS Tokens .sp With external authentication alone the authentication credentials will be required with every call to Salt. This can be alleviated with Salt tokens. .sp The tokens are short term authorizations and can be easily created by just adding a \fB\-T\fP option when authenticating: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C $ salt \-T \-a pam web\e* test.ping .ft P .fi .UNINDENT .UNINDENT .sp Now a token will be created that has a expiration of, by default, 12 hours. This token is stored in a file named \fB\&.salt_token\fP in the active user\(aqs home directory. Once the token is created, it is sent with all subsequent communications. The user authentication does not need to be entered again until the token expires. The token expiration time can be set in the Salt master config file. .SH PILLAR OF SALT .sp 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 as the Salt State Tree. .sp Pillar was added to Salt in version 0.9.8 .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Storing sensitive data .sp Unlike state tree, pillar data is only available for the targeted minion specified by the matcher type. This makes it useful for storing sensitive data specific to a particular minion. .UNINDENT .UNINDENT .SS Declaring the Master Pillar .sp 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 \fBpillar_roots\fP 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. Salt pillars can use the same matcher types as the standard top file. .sp The configuration for the \fBpillar_roots\fP in the master config file is identical in behavior and function as \fBfile_roots\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pillar_roots: base: \- /srv/pillar .ft P .fi .UNINDENT .UNINDENT .sp This example configuration declares that the base environment will be located in the \fB/srv/pillar\fP directory. The top file used matches the name of the top file used for States, and has the same structure: .sp \fB/srv/pillar/top.sls\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aq*\(aq: \- packages .ft P .fi .UNINDENT .UNINDENT .sp This further example shows how to use other standard top matching types (grain matching is used in this example) to deliver specific salt pillar data to minions with different \fBos\fP grains: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C dev: \(aqos:Debian\(aq: \- match: grain \- servers .ft P .fi .UNINDENT .UNINDENT .sp \fB/srv/pillar/packages.sls\fP .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if grains[\(aqos\(aq] == \(aqRedHat\(aq %} apache: httpd git: git {% elif grains[\(aqos\(aq] == \(aqDebian\(aq %} apache: apache2 git: git\-core {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp Now this data can be used from within modules, renderers, State SLS files, and more via the shared pillar \fI\%dict\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apache: pkg: \- installed \- name: {{ pillar[\(aqapache\(aq] }} .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git: pkg: \- installed \- name: {{ pillar[\(aqgit\(aq] }} .ft P .fi .UNINDENT .UNINDENT .sp Note that you cannot just list key/value\-information in \fBtop.sls\fP\&. .SS Pillar namespace flattened .sp The separate pillar files all share the same namespace. Given a \fBtop.sls\fP of: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aq*\(aq: \- packages \- services .ft P .fi .UNINDENT .UNINDENT .sp a \fBpackages.sls\fP file of: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C bind: bind9 .ft P .fi .UNINDENT .UNINDENT .sp and a \fBservices.sls\fP file of: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C bind: named .ft P .fi .UNINDENT .UNINDENT .sp Then a request for the \fBbind\fP pillar will only return \(aqnamed\(aq; the \(aqbind9\(aq value is not available. It is better to structure your pillar files with more hierarchy. For example your \fBpackage.sls\fP file could look like: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C packages: bind: bind9 .ft P .fi .UNINDENT .UNINDENT .SS Including Other Pillars .sp New in version 0.16.0. .sp Pillar SLS files may include other pillar files, similar to State files. Two syntaxes are available for this purpose. The simple form simply includes the additional pillar as if it were part of the same file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- users .ft P .fi .UNINDENT .UNINDENT .sp The full include form allows two additional options \-\- passing default values to the templating engine for the included pillar file as well as an optional key under which to nest the results of the included pillar: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- users: defaults: \- sudo: [\(aqbob\(aq, \(aqpaul\(aq] key: users .ft P .fi .UNINDENT .UNINDENT .sp With this form, the included file (users.sls) will be nested within the \(aqusers\(aq key of the compiled pillar. Additionally, the \(aqsudo\(aq value will be available as a template variable to users.sls. .SS Viewing Minion Pillar .sp Once the pillar is set up the data can be viewed on the minion via the \fBpillar\fP module, the pillar module comes with two functions, \fBpillar.items\fP and and \fBpillar.raw\fP\&. \fBpillar.items\fP will return a freshly reloaded pillar and \fBpillar.raw\fP will return the current pillar without a refresh: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pillar.items .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Prior to version 0.16.2, this function is named \fBpillar.data\fP\&. This function name is still supported for backwards compatibility. .UNINDENT .UNINDENT .SS Pillar "get" Function .sp New in version 0.14.0. .sp The \fBpillar.get\fP function works much in the same way as the \fBget\fP method in a python dict, but with an enhancement: nested dict components can be extracted using a \fI:\fP delimiter. .sp If a structure like this is in pillar: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C foo: bar: baz: qux .ft P .fi .UNINDENT .UNINDENT .sp Extracting it from the raw pillar in an sls formula or file template is done this way: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {{ pillar[\(aqfoo\(aq][\(aqbar\(aq][\(aqbaz\(aq] }} .ft P .fi .UNINDENT .UNINDENT .sp Now, with the new \fBpillar.get\fP function the data can be safely gathered and a default can be set, allowing the template to fall back if the value is not available: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {{ salt[\(aqpillar.get\(aq](\(aqfoo:bar:baz\(aq, \(aqqux\(aq) }} .ft P .fi .UNINDENT .UNINDENT .sp This makes handling nested structures much easier. .SS Refreshing Pillar Data .sp When pillar data is changed on the master the minions need to refresh the data locally. This is done with the \fBsaltutil.refresh_pillar\fP function. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq saltutil.refresh_pillar .ft P .fi .UNINDENT .UNINDENT .sp This function triggers the minion to asynchronously refresh the pillar and will always return \fBNone\fP\&. .SS Targeting with Pillar .sp Pillar data can be used when targeting minions. This allows for ultimate control and flexibility when targeting minions. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-I \(aqsomekey:specialvalue\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Like with \fBGrains\fP, it is possible to use globbing as well as match nested values in Pillar, by adding colons for each level that is being traversed. The below example would match minions with a pillar named \fBfoo\fP, which is a dict containing a key \fBbar\fP, with a value beginning with \fBbaz\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \-I \(aqfoo:bar:baz*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .SS Master Config In Pillar .sp For convenience the data stored in the master configuration file is made available in all minion\(aqs pillars. This makes global configuration of services and systems very easy but may not be desired if sensitive data is stored in the master configuration. .sp To disable the master config from being added to the pillar set \fIpillar_opts\fP to \fIFalse\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pillar_opts: False .ft P .fi .UNINDENT .UNINDENT .SH MASTER TOPS SYSTEM .sp In 0.10.4 the \fIexternal_nodes\fP system was upgraded to allow for modular subsystems to be used to generate the top file data for a highstate run on the master. .sp The old \fIexternal_nodes\fP option still works, but will be removed in the future in favor of the new \fImaster_tops\fP option which uses the modular system instead. The master tops system contains a number of subsystems that are loaded via the Salt loader interfaces like modules, states, returners, runners, etc. .sp Using the new \fImaster_tops\fP option is simple: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C master_tops: ext_nodes: cobbler\-external\-nodes .ft P .fi .UNINDENT .UNINDENT .sp for \fBCobbler\fP or: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C master_tops: reclass: inventory_base_uri: /etc/reclass classes_uri: roles .ft P .fi .UNINDENT .UNINDENT .sp for \fBReclass\fP\&. .SH JOB MANAGEMENT .sp New in version 0.9.7. .sp 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. .SS The Minion proc System .sp The Salt Minions now maintain a \fIproc\fP directory in the Salt cachedir, the \fIproc\fP 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 \fIproc\fP directory under the cachedir, with a default configuration it is under \fI/var/cache/salt/proc\fP\&. .SS Functions in the saltutil Module .sp Salt 0.9.7 introduced a few new functions to the \fBsaltutil\fP module for managing jobs. These functions are: .INDENT 0.0 .IP 1. 3 \fBrunning\fP Returns the data of all running jobs that are found in the \fIproc\fP directory. .IP 2. 3 \fBfind_job\fP Returns specific data about a certain job based on job id. .IP 3. 3 \fBsignal_job\fP Allows for a given jid to be sent a signal. .IP 4. 3 \fBterm_job\fP Sends a termination signal (SIGTERM, 15) to the process controlling the specified job. .IP 5. 3 \fBkill_job\fP Sends a kill signal (SIGKILL, 9) to the process controlling the specified job. .UNINDENT .sp These functions make up the core of the back end used to manage jobs at the minion level. .SS The jobs Runner .sp 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. .sp The jobs runner contains a number of functions... .SS active .sp 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. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # salt\-run jobs.active .ft P .fi .UNINDENT .UNINDENT .SS lookup_jid .sp 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 \fBkeep_jobs\fP 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. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # salt\-run jobs.lookup_jid .ft P .fi .UNINDENT .UNINDENT .SS list_jobs .sp 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. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # salt\-run jobs.list_jobs .ft P .fi .UNINDENT .UNINDENT .SH SALT SCHEDULING .sp In Salt versions greater than 0.12.0, the scheduling system allows incremental executions on minions or the master. The schedule system exposes the execution of any execution function on minions or any runner on the master. .sp To set up the scheduler on the master add the schedule option to the master config file. .sp To set up the scheduler on the minion add the schedule option to the minion config file or to the minion\(aqs pillar. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The scheduler executes different functions on the master and minions. When running on the master the functions reference runner functions, when running on the minion the functions specify execution functions. .UNINDENT .UNINDENT .sp The schedule option defines jobs which execute at certain intervals. To set up a highstate to run on a minion every 60 minutes set this in the minion config or pillar: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C schedule: highstate: function: state.highstate minutes: 60 .ft P .fi .UNINDENT .UNINDENT .sp Time intervals can be specified as seconds, minutes, hours, or days. Runner executions can also be specified on the master within the master configuration file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C schedule: overstate: function: state.over seconds: 35 minutes: 30 hours: 3 .ft P .fi .UNINDENT .UNINDENT .sp The above configuration will execute the state.over runner every 3 hours, 30 minutes and 35 seconds, or every 12,635 seconds. .SS Scheduler With Returner .sp The scheduler is also useful for tasks like gathering monitoring data about a minion, this schedule option will gather status data and send it to a mysql returner database: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C schedule: uptime: function: status.uptime seconds: 60 returner: mysql meminfo: function: status.meminfo minutes: 5 returner: mysql .ft P .fi .UNINDENT .UNINDENT .sp Since specifying the returner repeatedly can be tiresome, the \fIschedule_returner\fP option is available to specify one or a list of global returners to be used by the minions when scheduling. .SH RUNNING THE SALT MASTER AS UNPRIVILEGED USER .sp 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 \fBuser\fP in the master configuration file and all salt system components will be updated to function under the new user when the master is started. .sp 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # chown \-R /var/cache/salt # chown \-R /var/log/salt # chown \-R /etc/salt/pki .ft P .fi .UNINDENT .UNINDENT .SH TROUBLESHOOTING .sp 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. .SS Running in the Foreground .sp 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-master \-l debug salt\-minion \-l debug .ft P .fi .UNINDENT .UNINDENT .sp Anyone wanting to run Salt daemons via a process supervisor such as \fI\%monit\fP, \fI\%runit\fP, or \fI\%supervisord\fP, should omit the \fB\-d\fP argument to the daemons and run them in the foreground. .SS What Ports do the Master and Minion Need Open? .sp No ports need to be opened up on each minion. For the master, TCP ports 4505 and 4506 need to be open. If you\(aqve put both your Salt master and minion in debug mode and don\(aqt see an acknowledgment that your minion has connected, it could very well be a firewall. .sp You can check port connectivity from the minion with the nc command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C nc \-v \-z salt.master.ip 4505 nc \-v \-z salt.master.ip 4506 .ft P .fi .UNINDENT .UNINDENT .sp There is also a \fBfirewall configuration\fP document that might help as well. .sp If you\(aqve enabled the right TCP ports on your operating system or Linux distribution\(aqs firewall and still aren\(aqt seeing connections, check that no additional access control system such as \fI\%SELinux\fP or \fI\%AppArmor\fP is blocking Salt. .SS Using salt\-call .sp The \fBsalt\-call\fP 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 \fBstate.highstate\fP\&. .sp When creating your state tree, it is generally recommended to invoke \fBstate.highstate\fP with \fBsalt\-call\fP\&. 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 \fBsalt\-minion\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-call \-l debug state.highstate .ft P .fi .UNINDENT .UNINDENT .sp The main difference between using \fBsalt\fP and using \fBsalt\-call\fP is that \fBsalt\-call\fP is run from the minion, and it only runs the selected function on that minion. By contrast, \fBsalt\fP is run from the master, and requires you to specify the minions on which to run the command using salt\(aqs \fBtargeting system\fP\&. .SS Too many open files .sp 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 12:45:29,289 [salt.master ][INFO ] Starting Salt worker process 38 Too many open files sock != \-1 (tcp_listener.cpp:335) .ft P .fi .UNINDENT .UNINDENT .sp 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): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C [root@salt\-master ~]# ulimit \-n 1024 .ft P .fi .UNINDENT .UNINDENT .sp 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. .sp So, an environment with 1800 minions, would need 1800 x 2 = 3600 as a minimum. .SS Salt Master Stops Responding .sp There are known bugs with ZeroMQ versions less than 2.1.11 which can cause the Salt master to not respond properly. If you\(aqre running a ZeroMQ version greater than or equal to 2.1.9, you can work around the bug by setting the sysctls \fBnet.core.rmem_max\fP and \fBnet.core.wmem_max\fP to 16777216. Next, set the third field in \fBnet.ipv4.tcp_rmem\fP and \fBnet.ipv4.tcp_wmem\fP to at least 16777216. .sp You can do it manually with something like: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # 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 .ft P .fi .UNINDENT .UNINDENT .sp Or with the following Salt state: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .SS Salt and SELinux .sp 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 \fBinitrc_t\fP\&. The problem with SELinux arises when using salt\-call or running the minion in the foreground, since the type context stays \fBunconfined_t\fP\&. .sp 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 \fBsalt\-call\fP and \fBsalt\-minion\fP to rpm_exec_t: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # CentOS 5 and RHEL 5: 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 # CentOS 6 and RHEL 6: chcon system_u:object_r:rpm_exec_t:s0 /usr/bin/salt\-minion chcon system_u:object_r:rpm_exec_t:s0 /usr/bin/salt\-call .ft P .fi .UNINDENT .UNINDENT .sp This works well, because the \fBrpm_exec_t\fP context has very broad control over other types. .SS Red Hat Enterprise Linux 5 .sp 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 \fI\%EPEL repository\fP 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 \fBpython26\fP executable. .SS Common YAML Gotchas .sp An extensive list of \fBYAML idiosyncrasies\fP has been compiled. .SS Live Python Debug Output .sp If the minion or master seems to be unresponsive, a SIGUSR1 can be passed to the processes to display where in the code they are running. If encountering a situation like this, this debug information can be invaluable. First make sure the master of minion are running in the foreground: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-master \-l debug salt\-minion \-l debug .ft P .fi .UNINDENT .UNINDENT .sp The pass the signal to the master or minion when it seems to be unresponsive: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C killall \-SIGUSR1 salt\-master killall \-SIGUSR1 salt\-minion .ft P .fi .UNINDENT .UNINDENT .sp When filing an issue or sending questions to the mailing list for a problem with an unresponsive daemon this information can be invaluable. .SH YAML IDIOSYNCRASIES .sp One of Salt\(aqs strengths, the use of existing serialization systems for representing SLS data, can also backfire. \fI\%YAML\fP 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. .SS Spaces vs Tabs .sp \fI\%YAML uses spaces\fP, 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 Vim, after enabling search highlighting with: \fB:set hlsearch\fP, you can check with the following key sequence in normal mode(you can hit \fIESC\fP twice to be sure): \fB/\fP, \fICtrl\-v\fP, \fITab\fP, then hit \fIEnter\fP\&. Also, you can convert tabs to 2 spaces by these commands in Vim: \fB:set tabstop=2 expandtab\fP and then \fB:retab\fP\&. .SS Indentation .sp 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. .SS Nested Dicts (key=value) .sp When \fI\%dicts\fP 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 \fBfile.managed\fP state: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /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 .ft P .fi .UNINDENT .UNINDENT .sp 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /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 } .ft P .fi .UNINDENT .UNINDENT .SS True/False, Yes/No, On/Off .sp PyYAML will load these values as boolean \fBTrue\fP or \fBFalse\fP\&. Un\-capitalized versions will also be loaded as booleans (\fBtrue\fP, \fBfalse\fP, \fByes\fP, \fBno\fP, \fBon\fP, and \fBoff\fP). This can be especially problematic when constructing Pillar data. Make sure that your Pillars which need to use the string versions of these values are enclosed in quotes. .SS Integers are Parsed as Integers .sp NOTE: This has been fixed in salt 0.10.0, as of this release passing an integer that is preceded by a 0 will be correctly parsed .sp When passing \fI\%integers\fP 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. .sp This is best explained when setting the mode for a file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /etc/vimrc: file: \- managed \- source: salt://edit/vimrc \- user: root \- group: root \- mode: 644 .ft P .fi .UNINDENT .UNINDENT .sp 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 an octal value, 0644 becomes 420. Therefore, if the file mode is preceded by a 0 then it needs to be passed as a string: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C /etc/vimrc: file: \- managed \- source: salt://edit/vimrc \- user: root \- group: root \- mode: \(aq0644\(aq .ft P .fi .UNINDENT .UNINDENT .SS YAML does not like "Double Short Decs" .sp 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: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C vim: pkg.installed .ft P .fi .UNINDENT .UNINDENT .sp 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. .sp YAML though, gets upset when declaring multiple short decs, for the record... .sp THIS DOES NOT WORK: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C vim: pkg.installed user.present .ft P .fi .UNINDENT .UNINDENT .sp Similarly declaring a short dec in the same ID dec as a standard dec does not work either... .sp ALSO DOES NOT WORK: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C fred: user.present ssh_auth.present: \- name: AAAAB3NzaC... \- user: fred \- enc: ssh\-dss \- require: \- user: fred .ft P .fi .UNINDENT .UNINDENT .sp The correct way is to define them like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C vim: pkg.installed: [] user.present: [] fred: user.present: [] ssh_auth.present: \- name: AAAAB3NzaC... \- user: fred \- enc: ssh\-dss \- require: \- user: fred .ft P .fi .UNINDENT .UNINDENT .sp Alternatively, they can be defined the "old way", or with multiple "full decs": .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C vim: pkg: \- installed user: \- present fred: user: \- present ssh_auth: \- present \- name: AAAAB3NzaC... \- user: fred \- enc: ssh\-dss \- require: \- user: fred .ft P .fi .UNINDENT .UNINDENT .SS YAML support only plain ASCII .sp According to YAML specification, only ASCII characters can be used. .sp Within double\-quotes, special characters may be represented with C\-style escape sequences starting with a backslash ( \e ). .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \- micro: "\eu00b5" \- copyright: "\eu00A9" \- A: "\ex41" \- alpha: "\eu0251" \- Alef: "\eu05d0" .ft P .fi .UNINDENT .UNINDENT .sp List of usable \fI\%Unicode characters\fP will help you to identify correct numbers. .sp Python can also be used to discover the Unicode number for a character: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C repr(u"Text with wrong characters i need to figure out") .ft P .fi .UNINDENT .UNINDENT .sp This shell command can find wrong characters in your SLS files: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C find . \-name \(aq*.sls\(aq \-exec grep \-\-color=\(aqauto\(aq \-P \-n \(aq[^\ex00\-\ex7F]\(aq \e{} \e; .ft P .fi .UNINDENT .UNINDENT .SS Underscores stripped in Integer Definitions .sp If a definition only includes numbers and underscores, it is parsed by YAML as an integer and all underscores are stripped. To ensure the object becomes a string, it should be surrounded by quotes. \fI\%More information here\fP\&. .sp Here\(aqs an example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C >>> import yaml >>> yaml.safe_load(\(aq2013_05_10\(aq) 20130510 >>> yaml.safe_load(\(aq"2013_05_10"\(aq) \(aq2013_05_10\(aq .ft P .fi .UNINDENT .UNINDENT .SH COMMUNITY .sp Join the Salt! .sp There are many ways to participate in and communicate with the Salt community. .sp Salt has an active IRC channel and a mailing list. .SS Mailing List .sp Join the \fI\%salt\-users mailing list\fP\&. 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. .sp \fI\%https://groups.google.com/forum/#!forum/salt\-users\fP .SS IRC .sp The \fB#salt\fP IRC channel is hosted on the popular \fI\%Freenode\fP network. You can use the \fI\%Freenode webchat client\fP right from your browser. .sp \fI\%Logs of the IRC channel activity\fP are being collected courtesy of Moritz Lenz. .SS Salt development .sp If you wish to discuss the development of Salt itself join us in \fB#salt\-devel\fP\&. .SS Follow on Github .sp The Salt code is developed via Github. Follow Salt for constant updates on what is happening in Salt development: .sp \fI\%https://github.com/saltstack/salt\fP .SS The Red45 Blog .sp News and thoughts on Salt and related projects is often posted on Thomas\(aq blog \fI\%The Red45\fP: .sp \fI\%http://red45.wordpress.com/\fP .SS Example Salt States .sp The official \fBsalt\-states\fP repository is: \fI\%https://github.com/saltstack/salt\-states\fP .sp A few examples of salt states from the community: .INDENT 0.0 .IP \(bu 2 \fI\%https://github.com/blast\-hardcheese/blast\-salt\-states\fP .IP \(bu 2 \fI\%https://github.com/kevingranade/kevingranade\-salt\-state\fP .IP \(bu 2 \fI\%https://github.com/uggedal/states\fP .IP \(bu 2 \fI\%https://github.com/mattmcclean/salt\-openstack/tree/master/salt\fP .IP \(bu 2 \fI\%https://github.com/rentalita/ubuntu\-setup/\fP .IP \(bu 2 \fI\%https://github.com/brutasse/states\fP .IP \(bu 2 \fI\%https://github.com/bclermont/states\fP .IP \(bu 2 \fI\%https://github.com/pcrews/salt\-data\fP .UNINDENT .SS Follow on ohloh .sp \fI\%https://www.ohloh.net/p/salt\fP .SS Other community links .INDENT 0.0 .IP \(bu 2 \fI\%Salt Stack Inc.\fP .IP \(bu 2 \fI\%Subreddit\fP .IP \(bu 2 \fI\%Google+\fP .IP \(bu 2 \fI\%YouTube\fP .IP \(bu 2 \fI\%Facebook\fP .IP \(bu 2 \fI\%Twitter\fP .IP \(bu 2 \fI\%Wikipedia page\fP .UNINDENT .SS Developing Salt .sp There is a great need for contributions to salt and patches are welcome! The goal here is to make contributions clear, make sure there is a trail for where the code has come from, and most importantly, to give credit where credit is due! .sp There are a number of ways to contribute to salt development. .SS Sending a GitHub pull request .sp This is the preferred method for contributions. Simply create a GitHub fork, commit changes to the fork, and then open up a pull request. .sp The following is an example (from \fI\%Open Comparison Contributing Docs\fP ) of an efficient workflow for forking, cloning, branching, committing, and sending a pull request for a GitHub repository. .sp First, make a local clone of your GitHub fork of the salt GitHub repo and make edits and changes locally. .sp Then, create a new branch on your clone by entering the following commands: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git checkout \-b fixed\-broken\-thing Switched to a new branch \(aqfixed\-broken\-thing\(aq .ft P .fi .UNINDENT .UNINDENT .sp Choose a name for your branch that describes its purpose. .sp Now commit your changes to this new branch with the following command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git commit \-am \(aqdescription of my fixes for the broken thing\(aq .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Using \fBgit commit \-am\fP, followed by a quoted string, both stages and commits all modified files in a single command. Depending on the nature of your changes, you may wish to stage and commit them separately. Also, note that if you wish to add newly\-tracked files as part of your commit, they will not be caught using \fBgit commit \-am\fP and will need to be added using \fBgit add\fP before committing. .UNINDENT .UNINDENT .sp Push your locally\-committed changes back up to GitHub: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git push \-\-set\-upstream origin fixed\-broken\-thing .ft P .fi .UNINDENT .UNINDENT .sp Now go look at your fork of the salt repo on the GitHub website. The new branch will now be listed under the "Source" tab where it says "Switch Branches". Select the new branch from this list, and then click the "Pull request" button. .sp Put in a descriptive comment, and include links to any project issues related to the pull request. .sp The repo managers will be notified of your pull request and it will be reviewed. If a reviewer asks for changes, just make the changes locally in the same local feature branch, push them to GitHub, then add a comment to the discussion section of the pull request. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Travis\-CI .sp To make reviewing pull requests easier for the maintainers, please enable Travis\-CI on your fork. Salt is already configured, so simply follow the first 2 steps on the Travis\-CI \fI\%Getting Started Doc\fP\&. .UNINDENT .UNINDENT .SS Keeping Salt Forks in Sync .sp Salt is advancing quickly. It is therefore critical to pull upstream changes from master into forks on a regular basis. Nothing is worse than putting in a days of hard work into a pull request only to have it rejected because it has diverged too far from master. .sp To pull in upstream changes: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # For ssh github git remote add upstream git@github.com:saltstack/salt.git git fetch upstream # For https github git remote add upstream https://github.com/saltstack/salt.git git fetch upstream .ft P .fi .UNINDENT .UNINDENT .sp To check the log to be sure that you actually want the changes, run the following before merging: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git log upstream/develop .ft P .fi .UNINDENT .UNINDENT .sp Then to accept the changes and merge into the current branch: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git merge upstream/develop .ft P .fi .UNINDENT .UNINDENT .sp For more info, see \fI\%GitHub Fork a Repo Guide\fP or \fI\%Open Comparison Contributing Docs\fP .SS Posting patches to the mailing list .sp Patches will also be accepted by email. Format patches using \fI\%git format\-patch\fP and send them to the Salt users mailing list. The contributor will then get credit for the patch, and the Salt community will have an archive of the patch and a place for discussion. .SS Installing Salt for development .sp Clone the repository using: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git clone https://github.com/saltstack/salt .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 tags .sp Just cloning the repository is enough to work with Salt and make contributions. However, fetching additional tags from git is required to have Salt report the correct version for itself. To do this, first add the git repository as an upstream source: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git remote add upstream http://github.com/saltstack/salt .ft P .fi .UNINDENT .UNINDENT .sp Fetching tags is done with the git \(aqfetch\(aq utility: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C git fetch \-\-tags upstream .ft P .fi .UNINDENT .UNINDENT .UNINDENT .UNINDENT .sp Create a new \fI\%virtualenv\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C virtualenv /path/to/your/virtualenv .ft P .fi .UNINDENT .UNINDENT .sp On Arch Linux, where Python 3 is the default installation of Python, use the \fBvirtualenv2\fP command instead of \fBvirtualenv\fP\&. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Using system Python modules in the virtualenv .sp To use already\-installed python modules in virtualenv (instead of having pip download and compile new ones), run \fBvirtualenv \-\-system\-site\-packages\fP Using this method eliminates the requirement to install the salt dependencies again, although it does assume that the listed modules are all installed in the system PYTHONPATH at the time of virtualenv creation. .UNINDENT .UNINDENT .sp Activate the virtualenv: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C source /path/to/your/virtualenv/bin/activate .ft P .fi .UNINDENT .UNINDENT .sp Install Salt (and dependencies) into the virtualenv: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install M2Crypto # Don\(aqt install on Debian/Ubuntu (see below) pip install pyzmq PyYAML pycrypto msgpack\-python jinja2 psutil pip install \-e ./salt # the path to the salt git clone from above .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Installing M2Crypto .sp \fBswig\fP and \fBlibssl\-dev\fP are required to build M2Crypto. To fix the error \fBcommand \(aqswig\(aq failed with exit status 1\fP while installing M2Crypto, try installing it with the following command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C env SWIG_FEATURES="\-cpperraswarn \-includeall \-D__\(gauname \-m\(ga__ \-I/usr/include/openssl" pip install M2Crypto .ft P .fi .UNINDENT .UNINDENT .sp Debian and Ubuntu systems have modified openssl libraries and mandate that a patched version of M2Crypto be installed. This means that M2Crypto needs to be installed via apt: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C apt\-get install python\-m2crypto .ft P .fi .UNINDENT .UNINDENT .sp This also means that pulling in the M2Crypto installed using apt requires using \fB\-\-system\-site\-packages\fP when creating the virtualenv. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Installing psutil .sp Python header files are required to build this module, otherwise the pip install will fail. If your distribution separates binaries and headers into separate packages, make sure that you have the headers installed. In most Linux distributions which split the headers into their own package, this can be done by installing the \fBpython\-dev\fP or \fBpython\-devel\fP package. For other platforms, the package will likely be similarly named. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Important note for those developing using RedHat variants .sp For developers using a RedHat variant, be advised that the package provider for newer Redhat\-based systems (\fByumpkg.py\fP) relies on RedHat\(aqs python interface for yum. The variants that use this module to provide package support include the following: .INDENT 0.0 .IP \(bu 2 \fI\%RHEL\fP and \fI\%CentOS\fP releases 6 and later .IP \(bu 2 \fI\%Fedora Linux\fP releases 11 and later .IP \(bu 2 \fI\%Amazon Linux\fP .UNINDENT .sp Developers using one of these systems should create the salt virtualenv using the \fB\-\-system\-site\-packages\fP option to ensure that the correct modules are available. .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Installing dependencies on OS X. .sp You can install needed dependencies on OS X using homebrew or macports. See \fBOS X Installation\fP .UNINDENT .UNINDENT .SS Running a self\-contained development version .sp During development it is easiest to be able to run the Salt master and minion that are installed in the virtualenv you created above, and also to have all the configuration, log, and cache files contained in the virtualenv as well. .sp Copy the master and minion config files into your virtualenv: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C mkdir \-p /path/to/your/virtualenv/etc/salt cp ./salt/conf/master /path/to/your/virtualenv/etc/salt/master cp ./salt/conf/minion /path/to/your/virtualenv/etc/salt/minion .ft P .fi .UNINDENT .UNINDENT .sp Edit the master config file: .INDENT 0.0 .IP 1. 3 Uncomment and change the \fBuser: root\fP value to your own user. .IP 2. 3 Uncomment and change the \fBroot_dir: /\fP value to point to \fB/path/to/your/virtualenv\fP\&. .IP 3. 3 If you are running version 0.11.1 or older, uncomment and change the \fBpidfile: /var/run/salt\-master.pid\fP value to point to \fB/path/to/your/virtualenv/salt\-master.pid\fP\&. .IP 4. 3 If you are also running a non\-development version of Salt you will have to change the \fBpublish_port\fP and \fBret_port\fP values as well. .UNINDENT .sp Edit the minion config file: .INDENT 0.0 .IP 1. 3 Repeat the edits you made in the master config for the \fBuser\fP and \fBroot_dir\fP values as well as any port changes. .IP 2. 3 If you are running version 0.11.1 or older, uncomment and change the \fBpidfile: /var/run/salt\-minion.pid\fP value to point to \fB/path/to/your/virtualenv/salt\-minion.pid\fP\&. .IP 3. 3 Uncomment and change the \fBmaster: salt\fP value to point at \fBlocalhost\fP\&. .IP 4. 3 Uncomment and change the \fBid:\fP value to something descriptive like "saltdev". This isn\(aqt strictly necessary but it will serve as a reminder of which Salt installation you are working with. .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Using \fIsalt\-call\fP with a \fBStandalone Minion\fP .sp If you plan to run \fIsalt\-call\fP with this self\-contained development environment in a masterless setup, you should invoke \fIsalt\-call\fP with \fB\-c /path/to/your/virtualenv/etc/salt\fP so that salt can find the minion config file. Without the \fB\-c\fP option, Salt finds its config files in \fI/etc/salt\fP\&. .UNINDENT .UNINDENT .sp Start the master and minion, accept the minion\(aqs key, and verify your local Salt installation is working: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cd /path/to/your/virtualenv salt\-master \-c ./etc/salt \-d salt\-minion \-c ./etc/salt \-d salt\-key \-c ./etc/salt \-L salt\-key \-c ./etc/salt \-A salt \-c ./etc/salt \(aq*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Running the master and minion in debug mode can be helpful when developing. To do this, add \fB\-l debug\fP to the calls to \fBsalt\-master\fP and \fBsalt\-minion\fP\&. If you would like to log to the console instead of to the log file, remove the \fB\-d\fP\&. .sp Once the minion starts, you may see an error like the following: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C zmq.core.error.ZMQError: ipc path "/path/to/your/virtualenv/var/run/salt/minion/minion_event_7824dcbcfd7a8f6755939af70b96249f_pub.ipc" is longer than 107 characters (sizeof(sockaddr_un.sun_path)). .ft P .fi .UNINDENT .UNINDENT .sp This means the the path to the socket the minion is using is too long. This is a system limitation, so the only workaround is to reduce the length of this path. This can be done in a couple different ways: .INDENT 0.0 .IP 1. 3 Create your virtualenv in a path that is short enough. .IP 2. 3 Edit the \fBsock_dir\fP minion config variable and reduce its length. Remember that this path is relative to the value you set in \fBroot_dir\fP\&. .UNINDENT .sp \fBNOTE:\fP The socket path is limited to 107 characters on Solaris and Linux, and 103 characters on BSD\-based systems. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 File descriptor limits .sp Ensure that the system open file limit is raised to at least 2047: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # check your current limit ulimit \-n # raise the limit. persists only until reboot # use \(aqlimit descriptors 2047\(aq for c\-shell ulimit \-n 2047 .ft P .fi .UNINDENT .UNINDENT .sp To set file descriptors on OSX, refer to the \fBOS X Installation\fP instructions. .UNINDENT .UNINDENT .SS Using easy_install to Install Salt .sp If you are installing using \fBeasy_install\fP, you will need to define a \fBUSE_SETUPTOOLS\fP environment variable, otherwise dependencies will not be installed: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C USE_SETUPTOOLS=1 easy_install salt .ft P .fi .UNINDENT .UNINDENT .SS Running the tests .sp You will need \fBmock\fP to run the tests: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install mock .ft P .fi .UNINDENT .UNINDENT .sp If you are on Python < 2.7 then you will also need unittest2: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install unittest2 .ft P .fi .UNINDENT .UNINDENT .sp Finally you use setup.py to run the tests with the following command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \&./setup.py test .ft P .fi .UNINDENT .UNINDENT .sp For greater control while running the tests, please try: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C \&./tests/runtests.py \-h .ft P .fi .UNINDENT .UNINDENT .SS Editing and previewing the documentation .sp You need \fBsphinx\-build\fP command to build the docs. In Debian/Ubuntu this is provided in the \fBpython\-sphinx\fP package. Sphinx can also be installed to a virtualenv using pip: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pip install Sphinx .ft P .fi .UNINDENT .UNINDENT .sp Change to salt documentation directory, then: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C cd doc; make html .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 This will build the HTML docs. Run \fBmake\fP without any arguments to see the available make targets, which include \fBhtml\fP, \fBman\fP, and \fBtext\fP\&. .IP \(bu 2 The docs then are built within the \fBdocs/_build/\fP folder. To update the docs after making changes, run \fBmake\fP again. .IP \(bu 2 The docs use \fI\%reStructuredText\fP for markup. See a live demo at \fI\%http://rst.ninjs.org/\fP\&. .IP \(bu 2 The help information on each module or state is culled from the python code that runs for that piece. Find them in \fBsalt/modules/\fP or \fBsalt/states/\fP\&. .IP \(bu 2 To build the docs on Arch Linux, the \fBpython2\-sphinx\fP package is required. Additionally, it is necessary to tell \fBmake\fP where to find the proper \fBsphinx\-build\fP binary, like so: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C make SPHINXBUILD=sphinx\-build2 html .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .IP \(bu 2 To build the docs on RHEL/CentOS 6, the \fBpython\-sphinx10\fP package must be installed from EPEL, and the following make command must be used: .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C make SPHINXBUILD=sphinx\-1.0\-build html .ft P .fi .UNINDENT .UNINDENT .SH SALT BASED PROJECTS .sp A number of unofficial open source projects, based on Salt, or written to enhance Salt have been created. .SS Salt Sandbox .sp Created by Aaron Bull Schaefer, aka "elasticdog". .sp \fI\%https://github.com/elasticdog/salt\-sandbox\fP .sp 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\(aqs also a great way to learn firsthand about Salt and its remote execution capabilities. .sp Salt Sandbox will set up three separate virtual machines: .INDENT 0.0 .IP \(bu 2 salt.example.com \- the Salt master server .IP \(bu 2 minion1.example.com \- the first Salt minion machine .IP \(bu 2 minion2.example.com \- the second Salt minion machine .UNINDENT .sp 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. .SH SALT EVENT SYSTEM .sp 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. .sp 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. .SS Listening for Events .sp 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 \fBsock_dir\fP option. The \fBsock_dir\fP option defaults to "/var/run/salt/master" on most systems. .sp The following code will check for a single event: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import salt.utils.event event = salt.utils.event.MasterEvent(\(aq/var/run/salt/master\(aq) data = event.get_event() .ft P .fi .UNINDENT .UNINDENT .sp 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. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import salt.utils.event event = salt.utils.event.MasterEvent(\(aq/var/run/salt/master\(aq) data = event.get_event(wait=10, tag=\(aqauth\(aq) .ft P .fi .UNINDENT .UNINDENT .sp Instead of looking for a single event, the iter_events method can be used to make a generator which will continually yield salt events. The iter_events method also accepts a tag, but not a wait time: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import salt.utils.event event = salt.utils.event.MasterEvent(\(aq/var/run/salt/master\(aq) for data in event.iter_events(tag=\(aqauth\(aq): print(data) .ft P .fi .UNINDENT .UNINDENT .SS Firing Events .sp It is possible to fire events on either the minion\(aqs local bus, or to fire events intended for the master. To fire a local event from the minion, on the command line: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-call event.fire \(aqmessage to be sent in the event\(aq \(aqtag\(aq .ft P .fi .UNINDENT .UNINDENT .sp To fire an event to be sent to the master, from the minion: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-call event.fire_master \(aqmessage for the master\(aq \(aqtag\(aq .ft P .fi .UNINDENT .UNINDENT .sp If a process is listening on the minion, it may be useful for a user on the master to fire an event to it: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt minionname event.fire \(aqmessage for the minion\(aq \(aqtag\(aq .ft P .fi .UNINDENT .UNINDENT .SS Firing Events From Code .sp Events can be very useful when writing execution modules, in order to inform various processes on the master when a certain task has taken place. In Salt versions previous to 0.17.0, the basic code looks like: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Import the proper library import salt.utils.event # Fire deploy action sock_dir = \(aq/var/run/salt/minion\(aq event = salt.utils.event.SaltEvent(\(aqmaster\(aq, sock_dir) event.fire_event(\(aqMessage to be sent\(aq, \(aqtag\(aq) .ft P .fi .UNINDENT .UNINDENT .sp In Salt version 0.17.0, the ability to send a payload with a more complex data structure than a string was added. When using this interface, a Python dictionary should be sent instead. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # Import the proper library import salt.utils.event # Fire deploy action sock_dir = \(aq/var/run/salt/minion\(aq payload = {\(aqsample\-msg\(aq: \(aqthis is a test\(aq, \(aqexample\(aq: \(aqthis is the same test\(aq} event = salt.utils.event.SaltEvent(\(aqmaster\(aq, sock_dir) event.fire_event(payload, \(aqtag\(aq) .ft P .fi .UNINDENT .UNINDENT .sp It should be noted that this code can be used in 3rd party applications as well. So long as the salt\-minion process is running, the minion socket can be used: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sock_dir = \(aq/var/run/salt/minion\(aq .ft P .fi .UNINDENT .UNINDENT .sp So long as the salt\-master process is running, the master socket can be used: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sock_dir = \(aq/var/run/salt/master\(aq .ft P .fi .UNINDENT .UNINDENT .sp This allows 3rd party applications to harness the power of the Salt event bus programmatically, without having to make other calls to Salt. A 3rd party process can listen to the event bus on the master, and another 3rd party process can fire events to the process on the master, which Salt will happily pass along. .SH THE SALT MINE .sp Granted, it took a while for this name to be used in Salt, but version 0.15.0 introduces a new system to Salt called the Salt Mine. .sp The Salt Mine is used to bridge the gap between setting static variables and gathering live data. The Salt mine is used to collect arbitrary data from minions and store it on the master. This data is then made available to all minions via the \fBmine\fP module. .sp The data is gathered on the minion and sent back to the master where only the most recent data is maintained (if long term data is required use returners or the external job cache). .SS Mine Functions .sp To enable the Salt Mine the \fImine_functions\fP option needs to be applied to a minion. This option can be applied via the minion\(aqs configuration file, or the minion\(aqs pillar. The \fImine_functions\fP option dictates what functions are being executed and allows for arguments to be passed in: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C mine_functions: network.interfaces: [] test.ping: [] .ft P .fi .UNINDENT .UNINDENT .SS Mine Interval .sp The Salt Mine functions are executed when the minion starts and at a given interval by the scheduler. The default interval is every 60 minutes and can be adjusted for the minion via the \fImine_interval\fP option: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C mine_interval: 60 .ft P .fi .UNINDENT .UNINDENT .SH SALT VIRT - THE SALT STACK CLOUD CONTROLLER .sp The Salt Virt cloud controller capability was initial added to Salt in version 0.14.0 as an alpha technology. .sp The initial Salt Virt system supports core cloud operations: .INDENT 0.0 .IP \(bu 2 Virtual machine deployment .IP \(bu 2 Inspection of deployed VMs .IP \(bu 2 Virtual machine migration .IP \(bu 2 Network profiling .IP \(bu 2 Automatic VM integration with all aspects of Salt .IP \(bu 2 Image Pre\-seeding .UNINDENT .sp Many features are currently under development to enhance the capabilities of the Salt Virt systems. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 It is noteworthy that Salt was originally developed with the intent of using the Salt communication system as the backbone to a cloud controller. This means that the Salt Virt system is not an afterthought, simply a system that took the back seat to other development. The original attempt to develop the cloud control aspects of Salt was a project called butter. This project never took off, but was functional and proves the early viability of Salt to be a cloud controller. .UNINDENT .UNINDENT .SS Salt Virt Tutorial .sp A tutorial about how to get Salt Virt up and running has been added to the tutorial section: .sp \fBCloud Controller Tutorial\fP .SS The Salt Virt Runner .sp The point of interaction with the cloud controller is the \fBvirt\fP runner. The \fBvirt\fP runner comes with routines to execute specific virtual machine routines. .sp Reference documentation for the virt runner is available with the runner module documentation: .sp \fBVirt Runner Reference\fP .SS Based on Live State Data .sp The Salt Virt system is based on using Salt to query live data about hypervisors and then using the data gathered to make decisions about cloud operations. This means that no external resources are required to run Salt Virt, and that the information gathered about the cloud is live and accurate. .SH VIRTUAL MACHINE NETWORK PROFILES .sp Salt Virt allows for the network devices created for deployed virtual machines to be finely configured. The configuration is a simple data structure which is read from the \fBconfig.option\fP function, meaning that the configuration can be stored in the minion config file, the master config file, or the minion\(aqs pillar. .sp This configuration option is called \fBvirt.nic\fP\&. By default the \fBvirt.nic\fP option is empty but defaults to a data structure which looks like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C virt.nic: default: eth0: bridge: br0 model: virtio .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The model does not need to be defined, Salt will default to the optimal model used by the underlying hypervisor, in the case of kvm this model is \fBvirtio\fP .UNINDENT .UNINDENT .sp This configuration sets up a network profile called default. The default profile creates a single Ethernet device on the virtual machine that is bridged to the hypervisor\(aqs \fBbr0\fP interface. This default setup does not require setting up the \fBvirt.nic\fP configuration, and is the reason why a default install only requires setting up the \fBbr0\fP bridge device on the hypervisor. .SS Define More Profiles .sp Many environments will require more complex network profiles and may require more than one profile, this can be easily accomplished: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C virt.nic: dual: eth0: bridge: service_br eth1: bridge: storage_br single: eth0: bridge: service_br triple: eth0: bridge: service_br eth1: bridge: storage_br eth2: bridge: dmz_br all: eth0: bridge: service_br eth1: bridge: storage_br eth2: bridge: dmz_br eth3: bridge: database_br dmz: eth0: bridge: service_br eth1: bridge: dmz_br database: eth0: bridge: service_br eth1: bridge: database_br .ft P .fi .UNINDENT .UNINDENT .sp This configuration allows for one of six profiles to be selected, allowing virtual machines to be created which attach to different network depending on the needs of the deployed vm. .SH SALT SSH .sp In version 0.17.0 of Salt a new transport system was introduced, the ability to use SSH for Salt communication. This addition allows for Salt routines to be executed on remote systems entirely through ssh, bypassing the need for a Salt Minion to be running on the remote systems and the need for a Salt Master. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The Salt SSH system does not supercede the standard Salt communication systems, it simply offers an SSH based alternative that does not require ZeroMQ and a remote agent. Be aware that since all communication with Salt SSH is executed via SSH it is substantially slower than standard Salt with ZeroMQ. .UNINDENT .UNINDENT .sp Salt SSH is very easy to use, simply set up a basic \fIroster\fP file of the systems to connect to and run \fBsalt\-ssh\fP commands in a similar way as standard \fBsalt\fP commands. .SS Salt SSH Roster .sp The roster system in Salt allows for remote minions to be easily defined. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 See the \fBRoster documentation\fP for more details. .UNINDENT .UNINDENT .sp Simply create the roster file, the default location is \fI/etc/salt/roster\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C web1: 192.168.42.1 .ft P .fi .UNINDENT .UNINDENT .sp This is a very basic roster file where a Salt ID is being assigned to an IP address. A more elaborate roster can be created: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C web1: host: 192.168.42.1 # The IP addr or DNS hostname user: fred # Remote executions will be executed as user fred passwd: foobarbaz # The password to use for login, if omitted, keys are used sudo: True # Whether to sudo to root, not enabled by default web2: host: 192.168.42.2 .ft P .fi .UNINDENT .UNINDENT .SS Calling Salt SSH .sp The \fBsalt\-ssh\fP command can be easily executed in the same was as a salt command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-ssh \(aq*\(aq test.ping .ft P .fi .UNINDENT .UNINDENT .sp Commands with \fBsalt\-ssh\fP follow the same syntax as the \fBsalt\fP command. .sp The standard salt functions are available! The output is the same as \fBsalt\fP and many of the same flags are available. .SS Raw Shell Calls .sp By default \fBsalt\-ssh\fP runs Salt execution modules on the remote system, but \fBsalt\-ssh\fP can also execute raw shell commands: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-ssh \(aq*\(aq \-r \(aqifconfig\(aq .ft P .fi .UNINDENT .UNINDENT .SS States Via Salt SSH .sp The Salt State system can also be used with \fBsalt\-ssh\fP\&. The state system abstracts the same interface to the user in \fBsalt\-ssh\fP as it does when using standard \fBsalt\fP\&. The intent is that Salt Formulas defined for standard \fBsalt\fP will work seamlessly with \fBsalt\-ssh\fP as vis\-versa. .sp The standard Salt States walkthroughs function by simply replacing \fBsalt\fP commands with \fBsalt\-ssh\fP\&. .SS Targetting with Salt SSH .sp Due to the fact that the targeting approach differs in salt\-ssh, only glob and regex targets are supported as of this writing, the remaining target systems still need to be implemented. .SH SALT ROSTERS .sp Salt rosters are plugable systems added in Salt 0.17.0 to facilitate the \fBsalt\-ssh\fP system. The roster system was created because \fBsalt\-ssh\fP needs a means to identify which systems need to be targetted for execution. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 The Roster System is not needed or used in standard Salt because the master does not need to be initially aware of target systems, since the Salt Minion checks itself into the master. .UNINDENT .UNINDENT .sp Since the roster system is pluggable, it can be easily augmented to attach to any existing systems to gather information about what servers are presently available and should be attached to by \fBsalt\-ssh\fP\&. .SS How Rosters Work .sp The roster system compiles a data structure internally refered to as \fItargets\fP\&. The \fItargets\fP is a list of target systems and attributes about how to connect to said systems. The only requirement for a roster module in Salt is to return the \fItargets\fP data structure. .SS Targets Data .sp The information which can be stored in a roster \fItarget\fP is the following: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C : # The id to reference the target system with host: # The IP address or DNS name of the remote host user: # The user to log in as passwd: # The password to log in with .ft P .fi .UNINDENT .UNINDENT .SH RUNNING THE TESTS .sp To run the tests, use \fBtests/runtests.py\fP, see \fB\-\-help\fP for more info. .sp Examples: .INDENT 0.0 .IP \(bu 2 To run all tests: \fBsudo ./tests/runtests.py\fP .IP \(bu 2 Run unit tests only: \fBsudo ./tests/runtests.py \-\-unit\-tests\fP .UNINDENT .sp You will need \(aqmock\(aq (\fI\%https://pypi.python.org/pypi/mock\fP) in addition to salt requirements in order to run the tests. .SS Writing Tests .sp Salt uses a test platform to verify functionality of components in a simple way. Two testing systems exist to enable testing salt functions in somewhat real environments. The two subsystems available are integration tests and unit tests. .sp Salt uses the python standard library unittest2 system for testing. .SH INTEGRATION TESTS .sp The integration tests start up a number of salt daemons to test functionality in a live environment. These daemons include 2 salt masters, 1 syndic and 2 minions. This allows for the syndic interface to be tested and master/minion communication to be verified. All of the integration tests are executed as live salt commands sent through the started daemons. .INDENT 0.0 .IP \(bu 2 \fBWriting integration tests\fP .UNINDENT .sp Integration tests are particularly good at testing modules, states and shell commands. .SH UNIT TESTS .sp Direct unit tests are also available, these tests are good for internal functions. .SH INTEGRATION TESTS .sp The Salt integration tests come with a number of classes and methods which allow for components to be easily tested. These classes are generally inherited from and provide specific methods for hooking into the running integration test environment created by the integration tests. .sp It is noteworthy that since integration tests validate against a running environment that they are generally the preferred means to write tests. .sp The integration system is all located under tests/integration in the Salt source tree. .SS Integration Classes .sp The integration classes are located in tests/integration/__init__.py and can be extended therein. There are three classes available to extend: .SS ModuleCase .sp Used to define executions run via the master to minions and to call single modules and states. .sp The available methods are as follows: .INDENT 0.0 .TP .B run_function: Run a single salt function and condition the return down to match the behavior of the raw function call. This will run the command and only return the results from a single minion to verify. .TP .B state_result: Return the result data from a single state return .TP .B run_state: Run the state.single command and return the state return structure .UNINDENT .SS SyndicCase .sp Used to execute remote commands via a syndic, only used to verify the capabilities of the Syndic. .sp The available methods are as follows: .INDENT 0.0 .TP .B run_function: Run a single salt function and condition the return down to match the behavior of the raw function call. This will run the command and only return the results from a single minion to verify. .UNINDENT .SS ShellCase .sp Shell out to the scripts which ship with Salt. .sp The available methods are as follows: .INDENT 0.0 .TP .B run_script: Execute a salt script with the given argument string .TP .B run_salt: Execute the salt command, pass in the argument string as it would be passed on the command line. .TP .B run_run: Execute the salt\-run command, pass in the argument string as it would be passed on the command line. .TP .B run_run_plus: Execute Salt run and the salt run function and return the data from each in a dict .TP .B run_key: Execute the salt\-key command, pass in the argument string as it would be passed on the command line. .TP .B run_cp: Execute salt\-cp, pass in the argument string as it would be passed on the command line. .TP .B run_call: Execute salt\-call, pass in the argument string as it would be passed on the command line. .UNINDENT .SS Examples .SS Module Example via ModuleCase Class .sp Import the integration module, this module is already added to the python path by the test execution. Inherit from the \fBintegration.ModuleCase\fP class. The tests that execute against salt modules should be placed in the \fItests/integration/modules\fP directory so that they will be detected by the test system. .sp Now the workhorse method \fBrun_function\fP can be used to test a module: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import os import integration class TestModuleTest(integration.ModuleCase): \(aq\(aq\(aq Validate the test module \(aq\(aq\(aq def test_ping(self): \(aq\(aq\(aq test.ping \(aq\(aq\(aq self.assertTrue(self.run_function(\(aqtest.ping\(aq)) def test_echo(self): \(aq\(aq\(aq test.echo \(aq\(aq\(aq self.assertEqual(self.run_function(\(aqtest.echo\(aq, [\(aqtext\(aq]), \(aqtext\(aq) .ft P .fi .UNINDENT .UNINDENT .sp ModuleCase can also be used to test states, when testing states place the test module in the \fItests/integration/states\fP directory. The \fBstate_result\fP and the \fBrun_state\fP methods are the workhorse here: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import os import shutil import integration HFILE = os.path.join(integration.TMP, \(aqhosts\(aq) class HostTest(integration.ModuleCase): \(aq\(aq\(aq Validate the host state \(aq\(aq\(aq def setUp(self): shutil.copyfile(os.path.join(integration.FILES, \(aqhosts\(aq), HFILE) super(HostTest, self).setUp() def tearDown(self): if os.path.exists(HFILE): os.remove(HFILE) super(HostTest, self).tearDown() def test_present(self): \(aq\(aq\(aq host.present \(aq\(aq\(aq name = \(aqspam.bacon\(aq ip = \(aq10.10.10.10\(aq ret = self.run_state(\(aqhost.present\(aq, name=name, ip=ip) result = self.state_result(ret) self.assertTrue(result) with open(HFILE) as fp_: output = fp_.read() self.assertIn(\(aq{0}\et\et{1}\(aq.format(ip, name), output) .ft P .fi .UNINDENT .UNINDENT .sp The above example also demonstrates using the integration files and the integration state tree. The variable \fIintegration.FILES\fP will point to the directory used to store files that can be used or added to to help enable tests that require files. The location \fIintegration.TMP\fP can also be used to store temporary files that the test system will clean up when the execution finishes. .sp The integration state tree can be found at \fItests/integration/files/file/base\fP\&. This is where the referenced \fIhost.present\fP sls file resides. .SS Shell Example via ShellCase .sp Validating the shell commands can be done via shell tests. Here are some examples: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import sys import shutil import tempfile import integration class KeyTest(integration.ShellCase): \(aq\(aq\(aq Test salt\-key script \(aq\(aq\(aq _call_binary_ = \(aqsalt\-key\(aq def test_list(self): \(aq\(aq\(aq test salt\-key \-L \(aq\(aq\(aq data = self.run_key(\(aq\-L\(aq) expect = [ \(aqUnaccepted Keys:\(aq, \(aqAccepted Keys:\(aq, \(aqminion\(aq, \(aqsub_minion\(aq, \(aqRejected:\(aq, \(aq\(aq] self.assertEqual(data, expect) .ft P .fi .UNINDENT .UNINDENT .sp This example verifies that the \fBsalt\-key\fP command executes and returns as expected by making use of the \fBrun_key\fP method. .sp All shell tests should be placed in the \fItests/integraion/shell\fP directory. .SH REACTOR SYSTEM .sp Salt version 0.11.0 introduced the reactor system. The premise behind the reactor system is that with Salt\(aqs events and the ability to execute commands, a logic engine could be put in place to allow events to trigger actions, or more accurately, reactions. .sp This system binds sls files to event tags on the master. These sls files then define reactions. This means that the reactor system has two parts. First, the reactor option needs to be set in the master configuration file. The reactor option allows for event tags to be associated with sls reaction files. Second, these reaction files use highdata (like the state system) to define reactions to be executed. .SS Event System .sp A basic understanding of the event system is required to understand reactors. The event system is a local ZeroMQ PUB interface which fires salt events. This event bus is an open system used for sending information notifying Salt and other systems about operations. .sp The event system fires events with a very specific criteria. Every event has a \fBtag\fP which is comprised of a maximum of 20 characters. Event tags allow for fast top level filtering of events. In addition to the tag, each event has a data structure. This data structure is a dict, which contains information about the event. .SS Mapping Events to Reactor SLS Files .sp The event tag and data are both critical when working with the reactor system. In the master configuration file under the reactor option, tags are associated with lists of reactor sls formulas (globs can be used for matching): .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C reactor: \- \(aqauth\(aq: \- /srv/reactor/authreact1.sls \- /srv/reactor/authreact2.sls \- \(aqminion_start\(aq: \- /srv/reactor/start.sls .ft P .fi .UNINDENT .UNINDENT .sp When an event with a tag of \fBauth\fP is fired, the reactor will catch the event and render the two listed files. The rendered files are standard sls files, so by default they are yaml + Jinja. The Jinja is packed with a few data structures similar to state and pillar sls files. The data available is in \fBtag\fP and \fBdata\fP variables. The \fBtag\fP variable is just the tag in the fired event and the \fBdata\fP variable is the event\(aqs data dict. Here is a simple reactor sls: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if data[\(aqid\(aq] == \(aqmysql1\(aq %} highstate_run: cmd.state.highstate: \- tgt: mysql1 {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp This simple reactor file uses Jinja to further refine the reaction to be made. If the \fBid\fP in the event data is \fBmysql1\fP (in other words, if the name of the minion is \fBmysql1\fP) then the following reaction is defined. The same data structure and compiler used for the state system is used for the reactor system. The only difference is that the data is matched up to the salt command API and the runner system. In this example, a command is published to the \fBmysql1\fP minion with a function of \fBstate.highstate\fP\&. Similarly, a runner can be called: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if data[\(aqdata\(aq][\(aqoverstate\(aq] == \(aqrefresh\(aq %} overstate_run: runner.state.over {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp This example will execute the state.overstate runner and initiate an overstate execution. .SS Fire an event .sp From a minion, run bellow command .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt\-call event.fire_master \(aq{"overstate": "refresh"}\(aq \(aqfoo\(aq .ft P .fi .UNINDENT .UNINDENT .sp In reactor fomular files that are associated with tag \fBfoo\fP, data can be accessed via \fBdata[\(aqdata\(aq]\fP\&. Above command passed a dictionary as data, its \fBoverstate\fP key can be accessed via \fBdata[\(aqdata\(aq][\(aqoverstate\(aq]\fP\&. See \fBsalt.modules.event\fP for more information. .SS Understanding the Structure of Reactor Formulas .sp While the reactor system uses the same data structure as the state system, this data does not translate the same way to operations. In state, formulas information is mapped to the state functions, but in the reactor system, information is mapped to a number of available subsystems on the master. These systems are the \fBLocalClient\fP and the \fBRunners\fP\&. The \fBstate declaration\fP field takes a reference to the function to call in each interface. So to trigger a salt\-run call the \fBstate declaration\fP field will start with \fBrunner\fP, followed by the runner function to call. This means that a call to what would be on the command line \fBsalt\-run manage.up\fP will be \fBrunner.manage.up\fP\&. An example of this in a reactor formula would look like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C manage_up: runner.manage.up .ft P .fi .UNINDENT .UNINDENT .sp If the runner takes arguments then they can be specified as well: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C overstate_dev_env: runner.state.over: \- env: dev .ft P .fi .UNINDENT .UNINDENT .sp Executing remote commands maps to the \fBLocalClient\fP interface which is used by the \fBsalt\fP command. This interface more specifically maps to the \fBcmd_async\fP method inside of the \fBLocalClient\fP class. This means that the arguments passed are being passed to the \fBcmd_async\fP method, not the remote method. A field starts with \fBcmd\fP to use the \fBLocalClient\fP subsystem. The result is, to execute a remote command, a reactor fomular would look like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C clean_tmp: cmd.cmd.run: \- tgt: \(aq*\(aq \- arg: \- rm \-rf /tmp/* .ft P .fi .UNINDENT .UNINDENT .sp The \fBarg\fP option takes a list of arguments as they would be presented on the command line, so the above declaration is the same as running this salt command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run \(aqrm \-rf /tmp/*\(aq .ft P .fi .UNINDENT .UNINDENT .sp Use the \fBexpr_form\fP argument to specify a matcher: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C clean_tmp: cmd.cmd.run: \- tgt: \(aqos:Ubuntu\(aq \- expr_form: grain \- arg: \- rm \-rf /tmp/* clean_tmp: cmd.cmd.run: \- tgt: \(aqG@roles:hbase_master\(aq \- expr_form: compound \- arg: \- rm \-rf /tmp/* .ft P .fi .UNINDENT .UNINDENT .SH SALT FORMULAS .sp Formulas are pre\-written Salt States. They are as open\-ended as Salt States themselves and can be used for tasks such as installing a package, configuring and starting a service, setting up users or permissions, and many other common tasks. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Formulas require Salt 0.17 or later. .sp More accurately, Formulas are not tested on earlier versions of Salt so your mileage may vary. .sp All Formulas require the grains execution module that shipped with Salt 0.16.4. Earlier Salt versions may copy \fI\%https://github.com/saltstack/salt/blob/develop/salt/modules/grains.py\fP into the \fB/srv/salt/_modules\fP directory and it will be automatically distributed to all minions. .sp Some Formula utilize features added in Salt 0.17 and will not work on earlier Salt versions. .UNINDENT .UNINDENT .sp All official Salt Formulas are found as separate Git repositories in the "saltstack\-formulas" organization on GitHub: .sp \fI\%https://github.com/saltstack\-formulas\fP .sp As an example, quickly install and configure the popular memcached server using sane defaults simply by including the \fI\%memcached\-formula\fP repository into an existing Salt States tree. .SS Installation .sp Each Salt Formula is an individual Git repository designed as a drop\-in addition to an existing Salt State tree. Formulas can be installed in the following ways. .SS Adding a Formula as a GitFS remote .sp One design goal of Salt\(aqs GitFS fileserver backend was to facilitate reusable States so this is a quick and natural way to use Formulas. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fISetting up GitFS\fP .UNINDENT .UNINDENT .INDENT 0.0 .IP 1. 3 Add one or more Formula repository URLs as remotes in the \fBgitfs_remotes\fP list in the Salt Master configuration file. .IP 2. 3 Restart the Salt master. .UNINDENT .SS Adding a Formula directory manually .sp Since Formulas are simply directories they can be copied onto the local file system by using Git to clone the repository or by downloading and expanding a tarball or zip file of the directory. .INDENT 0.0 .IP \(bu 2 Clone the repository manually and add a new entry to \fBfile_roots\fP pointing to the clone\(aqs directory. .IP \(bu 2 Clone the repository manually and then copy or link the Formula directory into \fBfile_roots\fP\&. .UNINDENT .SS Usage .sp Each Formula is intended to be immediately usable with sane defaults without any additional configuration. Many formulas are also configurable by including data in Pillar Many formulas are also configurable by including data in Pillar; see the \fBpillar.example\fP file in each Formula repository for available options. .SS Including a Formula in an existing State tree .sp Formula may be included in an existing \fBsls\fP file. This is often useful when a state you are writing needs to \fBrequire\fP or \fBextend\fP a state defined in the formula. .sp Here is an example of a state that uses the \fI\%epel\-formula\fP in a \fBrequire\fP declaration which directs Salt to not install the \fBpython26\fP package until after the EPEL repository has also been installed: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- epel python26: pkg: \- installed \- require: \- pkg: epel .ft P .fi .UNINDENT .UNINDENT .SS Including a Formula from a Top File .sp Some Formula perform completely standalone installations that are not referenced from other state files. It is usually cleanest to include these Formula directly from a Top File. .sp For example the easiest way to set up an OpenStack deployment on a single machine is to include the \fI\%openstack\-standalone\-formula\fP directly from a \fBtop.sls\fP file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aqmyopenstackmaster\(aq: \- openstack .ft P .fi .UNINDENT .UNINDENT .sp Quickly deploying OpenStack across several dedicated machines could also be done directly from a Top File and may look something like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aqcontroller\(aq: \- openstack.horizon \- openstack.keystone \(aqhyper\-*\(aq: \- openstack.nova \- openstack.glance \(aqstorage\-*\(aq: \- openstack.swift .ft P .fi .UNINDENT .UNINDENT .SS Configuring Formula using Pillar .sp Salt Formulas are designed to work out of the box with no additional configuration. However, many Formula support additional configuration and customization through \fIPillar\fP\&. Examples of available options can be found in a file named \fBpillar.example\fP in the root directory of each Formula repository. .SS Modifying default Formula behavior .sp Remember that Formula are regular Salt States and can be used with all Salt\(aqs normal mechanisms for determining execution order. Formula can be required from other States with \fBrequire\fP declarations, they can be modified using \fBextend\fP, they can made to watch other states with \fBwatch_in\fP, they can be used as templates for other States with \fBuse\fP\&. Don\(aqt be shy to read through the source for each Formula! .SS Reporting problems & making additions .sp Each Formula is a separate repository on GitHub. If you encounter a bug with a Formula please file an issue in the respective repository! Send fixes and additions as a pull request. Add tips and tricks to the repository wiki. .SS Writing Formulas .sp Each Formula is a separate repository in the \fI\%saltstack\-formulas\fP organization on GitHub. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Get involved creating new Formulas .sp The best way to create new Formula repositories for now is to create a repository in your own account on GitHub and notify a SaltStack employee when it is ready. We will add you as a collaborator on the \fI\%saltstack\-formulas\fP organization and help you transfer the repository over. Ping a SaltStack employee on IRC (\fB#salt\fP on Freenode) or send an email to the Salt mailing list. .UNINDENT .UNINDENT .SS Repository structure .sp A basic Formula repository should have the following layout: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C foo\-formula |\-\- foo/ | |\-\- map.jinja | |\-\- init.sls | \(ga\-\- bar.sls |\-\- LICENSE |\-\- pillar.example \(ga\-\- README.rst .ft P .fi .UNINDENT .UNINDENT .SS \fBREADME.rst\fP .sp The README should detail each available \fB\&.sls\fP file by explaining what it does, whether it has any dependencies on other formulas, whether it has a target platform, and any other installation or usage instructions or tips. .sp A sample skeleton for the \fBREADME.rst\fP file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C foo === Install and configure the FOO service. \&.. note:: See the full \(gaSalt Formulas installation and usage instructions \(ga_. Available states \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \(ga\(gafoo\(ga\(ga Install the \(ga\(gafoo\(ga\(ga package and enable the service. \(ga\(gafoo.bar\(ga\(ga Install the \(ga\(gabar\(ga\(ga package. .ft P .fi .UNINDENT .UNINDENT .SS \fBmap.jinja\fP .sp It is useful to have a single source for platform\-specific or other parameterized information that can be reused throughout a Formula. See "\fIconventions\-formula\-parameterization\fP" below for more information. Such a file should be named \fBmap.jinja\fP and live alongside the state files. .sp The following is an example from the MySQL Formula. .sp \fBmap.jinja\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% set mysql = salt[\(aqgrains.filter_by\(aq]({ \(aqDebian\(aq: { \(aqserver\(aq: \(aqmysql\-server\(aq, \(aqclient\(aq: \(aqmysql\-client\(aq, \(aqservice\(aq: \(aqmysql\(aq, \(aqconfig\(aq: \(aq/etc/mysql/my.cnf\(aq, }, \(aqRedHat\(aq: { \(aqserver\(aq: \(aqmysql\-server\(aq, \(aqclient\(aq: \(aqmysql\(aq, \(aqservice\(aq: \(aqmysqld\(aq, \(aqconfig\(aq: \(aq/etc/my.cnf\(aq, }, \(aqGentoo\(aq: { \(aqserver\(aq: \(aqdev\-db/mysql\(aq, \(aqmysql\-client\(aq: \(aqdev\-db/mysql\(aq, \(aqservice\(aq: \(aqmysql\(aq, \(aqconfig\(aq: \(aq/etc/mysql/my.cnf\(aq, }, }, merge=salt[\(aqpillar.get\(aq](\(aqmysql:lookup\(aq)) %} .ft P .fi .UNINDENT .UNINDENT .sp Any of the values defined above can be fetched for the current platform in any state file using the following syntax: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% from "mysql/map.jinja" import mysql with context %} mysql\-server: pkg: \- installed \- name: {{ mysql.server }} service: \- running \- name: {{ mysql.service }} \- require: \- pkg: mysql\-server mysql\-config: file: \- managed \- name: {{ mysql.config }} \- source: salt://mysql/conf/my.cnf \- watch: \- service: mysql\-server .ft P .fi .UNINDENT .UNINDENT .SS SLS files .sp Each state in a Formula should use sane defaults (as much as is possible) and use Pillar to allow for customization. .sp The root state, in particular, and most states in general, should strive to do no more than the basic expected thing and advanced configuration should be put in child states build on top of the basic states. .sp For example, the root Apache should only install the Apache httpd server and make sure the httpd service is running. It can then be used by more advanced states: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # apache/init.sls httpd: pkg: \- installed service: \- running # apache/mod_wsgi.sls include: \- apache mod_wsgi: pkg: \- installed \- require: \- pkg: apache # apache/debian/vhost_setup.sls {% if grains[\(aqos_family\(aq] == \(aqDebian\(aq %} a2dissite 000\-default: cmd.run: \- onlyif: test \-L /etc/apache2/sites\-enabled/000\-default \- require: \- pkg: apache {% endif %} .ft P .fi .UNINDENT .UNINDENT .SS Platform agnostic .sp Each Salt Formula must be able to be run without error on any platform. If the formula is not applicable to a platform it should do nothing. See the \fI\%epel\-formula\fP for an example. .sp Any platform\-specific states must be wrapped in conditional statements: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if grains[\(aqos_family\(aq] == \(aqDebian\(aq %} \&... {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp A handy method for using platform\-specific values is to create a lookup table using the \fBfilter_by()\fP function: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% set apache = salt[\(aqgrains.filter_by\(aq]({ \(aqDebian\(aq: {\(aqconf\(aq: \(aq/etc/apache2/conf.d\(aq}, \(aqRedHat\(aq: {\(aqconf\(aq: \(aq/etc/httpd/conf.d\(aq}, }) %} myconf: file: \- managed \- name: {{ apache.conf }}/myconf.conf .ft P .fi .UNINDENT .UNINDENT .SS Configuration and parameterization .sp Each Formula should strive for sane defaults that can then be customized using Pillar. Pillar lookups must use the safe \fBget()\fP and must provide a default value: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if salt[\(aqpillar.get\(aq](\(aqhorizon:use_ssl\(aq, False) %} ssl_crt: {{ salt[\(aqpillar.get\(aq](\(aqhorizon:ssl_crt\(aq, \(aq/etc/ssl/certs/horizon.crt\(aq) }} ssl_key: {{ salt[\(aqpillar.get\(aq](\(aqhorizon:ssl_key\(aq, \(aq/etc/ssl/certs/horizon.key\(aq) }} {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp Any default values used in the Formula must also be documented in the \fBpillar.example\fP file in the root of the repository. Comments should be used liberally to explain the intent of each configuration value. In addition, users should be able copy\-and\-paste the contents of this file into their own Pillar to make any desired changes. .SS Scripting .sp Remember that both State files and Pillar files can easily call out to Salt \fIexecution modules\fP and have access to all the system grains as well. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if \(aq/storage\(aq in salt[\(aqmount.active\(aq]() %} /usr/local/etc/myfile.conf: file: \- symlink \- target: /storage/myfile.conf {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp Jinja macros are generally discouraged in favor of adding functions to existing Salt modules or adding new modules. An example of this is the \fBfilter_by()\fP function. .SS Versioning .sp Formula versions are tracked using Git tags. .SS Testing Formulas .sp Salt Formulas are tested by running each \fB\&.sls\fP file via \fBstate.sls\fP and checking the output for success or failure. This is done for each supported platform. .SH SALT CONVENTIONS .SS Salt Formulas .sp Formulas are pre\-written Salt States. They are as open\-ended as Salt States themselves and can be used for tasks such as installing a package, configuring and starting a service, setting up users or permissions, and many other common tasks. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Formulas require Salt 0.17 or later. .sp More accurately, Formulas are not tested on earlier versions of Salt so your mileage may vary. .sp All Formulas require the grains execution module that shipped with Salt 0.16.4. Earlier Salt versions may copy \fI\%https://github.com/saltstack/salt/blob/develop/salt/modules/grains.py\fP into the \fB/srv/salt/_modules\fP directory and it will be automatically distributed to all minions. .sp Some Formula utilize features added in Salt 0.17 and will not work on earlier Salt versions. .UNINDENT .UNINDENT .sp All official Salt Formulas are found as separate Git repositories in the "saltstack\-formulas" organization on GitHub: .sp \fI\%https://github.com/saltstack\-formulas\fP .sp As an example, quickly install and configure the popular memcached server using sane defaults simply by including the \fI\%memcached\-formula\fP repository into an existing Salt States tree. .SS Installation .sp Each Salt Formula is an individual Git repository designed as a drop\-in addition to an existing Salt State tree. Formulas can be installed in the following ways. .SS Adding a Formula as a GitFS remote .sp One design goal of Salt\(aqs GitFS fileserver backend was to facilitate reusable States so this is a quick and natural way to use Formulas. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fISetting up GitFS\fP .UNINDENT .UNINDENT .INDENT 0.0 .IP 1. 3 Add one or more Formula repository URLs as remotes in the \fBgitfs_remotes\fP list in the Salt Master configuration file. .IP 2. 3 Restart the Salt master. .UNINDENT .SS Adding a Formula directory manually .sp Since Formulas are simply directories they can be copied onto the local file system by using Git to clone the repository or by downloading and expanding a tarball or zip file of the directory. .INDENT 0.0 .IP \(bu 2 Clone the repository manually and add a new entry to \fBfile_roots\fP pointing to the clone\(aqs directory. .IP \(bu 2 Clone the repository manually and then copy or link the Formula directory into \fBfile_roots\fP\&. .UNINDENT .SS Usage .sp Each Formula is intended to be immediately usable with sane defaults without any additional configuration. Many formulas are also configurable by including data in Pillar Many formulas are also configurable by including data in Pillar; see the \fBpillar.example\fP file in each Formula repository for available options. .SS Including a Formula in an existing State tree .sp Formula may be included in an existing \fBsls\fP file. This is often useful when a state you are writing needs to \fBrequire\fP or \fBextend\fP a state defined in the formula. .sp Here is an example of a state that uses the \fI\%epel\-formula\fP in a \fBrequire\fP declaration which directs Salt to not install the \fBpython26\fP package until after the EPEL repository has also been installed: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C include: \- epel python26: pkg: \- installed \- require: \- pkg: epel .ft P .fi .UNINDENT .UNINDENT .SS Including a Formula from a Top File .sp Some Formula perform completely standalone installations that are not referenced from other state files. It is usually cleanest to include these Formula directly from a Top File. .sp For example the easiest way to set up an OpenStack deployment on a single machine is to include the \fI\%openstack\-standalone\-formula\fP directly from a \fBtop.sls\fP file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aqmyopenstackmaster\(aq: \- openstack .ft P .fi .UNINDENT .UNINDENT .sp Quickly deploying OpenStack across several dedicated machines could also be done directly from a Top File and may look something like this: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C base: \(aqcontroller\(aq: \- openstack.horizon \- openstack.keystone \(aqhyper\-*\(aq: \- openstack.nova \- openstack.glance \(aqstorage\-*\(aq: \- openstack.swift .ft P .fi .UNINDENT .UNINDENT .SS Configuring Formula using Pillar .sp Salt Formulas are designed to work out of the box with no additional configuration. However, many Formula support additional configuration and customization through \fIPillar\fP\&. Examples of available options can be found in a file named \fBpillar.example\fP in the root directory of each Formula repository. .SS Modifying default Formula behavior .sp Remember that Formula are regular Salt States and can be used with all Salt\(aqs normal mechanisms for determining execution order. Formula can be required from other States with \fBrequire\fP declarations, they can be modified using \fBextend\fP, they can made to watch other states with \fBwatch_in\fP, they can be used as templates for other States with \fBuse\fP\&. Don\(aqt be shy to read through the source for each Formula! .SS Reporting problems & making additions .sp Each Formula is a separate repository on GitHub. If you encounter a bug with a Formula please file an issue in the respective repository! Send fixes and additions as a pull request. Add tips and tricks to the repository wiki. .SS Writing Formulas .sp Each Formula is a separate repository in the \fI\%saltstack\-formulas\fP organization on GitHub. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Get involved creating new Formulas .sp The best way to create new Formula repositories for now is to create a repository in your own account on GitHub and notify a SaltStack employee when it is ready. We will add you as a collaborator on the \fI\%saltstack\-formulas\fP organization and help you transfer the repository over. Ping a SaltStack employee on IRC (\fB#salt\fP on Freenode) or send an email to the Salt mailing list. .UNINDENT .UNINDENT .SS Repository structure .sp A basic Formula repository should have the following layout: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C foo\-formula |\-\- foo/ | |\-\- map.jinja | |\-\- init.sls | \(ga\-\- bar.sls |\-\- LICENSE |\-\- pillar.example \(ga\-\- README.rst .ft P .fi .UNINDENT .UNINDENT .SS \fBREADME.rst\fP .sp The README should detail each available \fB\&.sls\fP file by explaining what it does, whether it has any dependencies on other formulas, whether it has a target platform, and any other installation or usage instructions or tips. .sp A sample skeleton for the \fBREADME.rst\fP file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C foo === Install and configure the FOO service. \&.. note:: See the full \(gaSalt Formulas installation and usage instructions \(ga_. Available states \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \(ga\(gafoo\(ga\(ga Install the \(ga\(gafoo\(ga\(ga package and enable the service. \(ga\(gafoo.bar\(ga\(ga Install the \(ga\(gabar\(ga\(ga package. .ft P .fi .UNINDENT .UNINDENT .SS \fBmap.jinja\fP .sp It is useful to have a single source for platform\-specific or other parameterized information that can be reused throughout a Formula. See "\fIconventions\-formula\-parameterization\fP" below for more information. Such a file should be named \fBmap.jinja\fP and live alongside the state files. .sp The following is an example from the MySQL Formula. .sp \fBmap.jinja\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% set mysql = salt[\(aqgrains.filter_by\(aq]({ \(aqDebian\(aq: { \(aqserver\(aq: \(aqmysql\-server\(aq, \(aqclient\(aq: \(aqmysql\-client\(aq, \(aqservice\(aq: \(aqmysql\(aq, \(aqconfig\(aq: \(aq/etc/mysql/my.cnf\(aq, }, \(aqRedHat\(aq: { \(aqserver\(aq: \(aqmysql\-server\(aq, \(aqclient\(aq: \(aqmysql\(aq, \(aqservice\(aq: \(aqmysqld\(aq, \(aqconfig\(aq: \(aq/etc/my.cnf\(aq, }, \(aqGentoo\(aq: { \(aqserver\(aq: \(aqdev\-db/mysql\(aq, \(aqmysql\-client\(aq: \(aqdev\-db/mysql\(aq, \(aqservice\(aq: \(aqmysql\(aq, \(aqconfig\(aq: \(aq/etc/mysql/my.cnf\(aq, }, }, merge=salt[\(aqpillar.get\(aq](\(aqmysql:lookup\(aq)) %} .ft P .fi .UNINDENT .UNINDENT .sp Any of the values defined above can be fetched for the current platform in any state file using the following syntax: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% from "mysql/map.jinja" import mysql with context %} mysql\-server: pkg: \- installed \- name: {{ mysql.server }} service: \- running \- name: {{ mysql.service }} \- require: \- pkg: mysql\-server mysql\-config: file: \- managed \- name: {{ mysql.config }} \- source: salt://mysql/conf/my.cnf \- watch: \- service: mysql\-server .ft P .fi .UNINDENT .UNINDENT .SS SLS files .sp Each state in a Formula should use sane defaults (as much as is possible) and use Pillar to allow for customization. .sp The root state, in particular, and most states in general, should strive to do no more than the basic expected thing and advanced configuration should be put in child states build on top of the basic states. .sp For example, the root Apache should only install the Apache httpd server and make sure the httpd service is running. It can then be used by more advanced states: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # apache/init.sls httpd: pkg: \- installed service: \- running # apache/mod_wsgi.sls include: \- apache mod_wsgi: pkg: \- installed \- require: \- pkg: apache # apache/debian/vhost_setup.sls {% if grains[\(aqos_family\(aq] == \(aqDebian\(aq %} a2dissite 000\-default: cmd.run: \- onlyif: test \-L /etc/apache2/sites\-enabled/000\-default \- require: \- pkg: apache {% endif %} .ft P .fi .UNINDENT .UNINDENT .SS Platform agnostic .sp Each Salt Formula must be able to be run without error on any platform. If the formula is not applicable to a platform it should do nothing. See the \fI\%epel\-formula\fP for an example. .sp Any platform\-specific states must be wrapped in conditional statements: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if grains[\(aqos_family\(aq] == \(aqDebian\(aq %} \&... {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp A handy method for using platform\-specific values is to create a lookup table using the \fBfilter_by()\fP function: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% set apache = salt[\(aqgrains.filter_by\(aq]({ \(aqDebian\(aq: {\(aqconf\(aq: \(aq/etc/apache2/conf.d\(aq}, \(aqRedHat\(aq: {\(aqconf\(aq: \(aq/etc/httpd/conf.d\(aq}, }) %} myconf: file: \- managed \- name: {{ apache.conf }}/myconf.conf .ft P .fi .UNINDENT .UNINDENT .SS Configuration and parameterization .sp Each Formula should strive for sane defaults that can then be customized using Pillar. Pillar lookups must use the safe \fBget()\fP and must provide a default value: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if salt[\(aqpillar.get\(aq](\(aqhorizon:use_ssl\(aq, False) %} ssl_crt: {{ salt[\(aqpillar.get\(aq](\(aqhorizon:ssl_crt\(aq, \(aq/etc/ssl/certs/horizon.crt\(aq) }} ssl_key: {{ salt[\(aqpillar.get\(aq](\(aqhorizon:ssl_key\(aq, \(aq/etc/ssl/certs/horizon.key\(aq) }} {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp Any default values used in the Formula must also be documented in the \fBpillar.example\fP file in the root of the repository. Comments should be used liberally to explain the intent of each configuration value. In addition, users should be able copy\-and\-paste the contents of this file into their own Pillar to make any desired changes. .SS Scripting .sp Remember that both State files and Pillar files can easily call out to Salt \fIexecution modules\fP and have access to all the system grains as well. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {% if \(aq/storage\(aq in salt[\(aqmount.active\(aq]() %} /usr/local/etc/myfile.conf: file: \- symlink \- target: /storage/myfile.conf {% endif %} .ft P .fi .UNINDENT .UNINDENT .sp Jinja macros are generally discouraged in favor of adding functions to existing Salt modules or adding new modules. An example of this is the \fBfilter_by()\fP function. .SS Versioning .sp Formula versions are tracked using Git tags. .SS Testing Formulas .sp Salt Formulas are tested by running each \fB\&.sls\fP file via \fBstate.sls\fP and checking the output for success or failure. This is done for each supported platform. .SS Salt Release Process .sp The goal for Salt projects is to cut a new feature release every four to six weeks. This document outlines the process for these releases, and the subsequent bug fix releases which follow. .SS Feature Release Process .sp When a new release is ready to be cut, the person responsible for cutting the release will follow the following steps (written using the 0.16 release as an example): .INDENT 0.0 .IP 1. 3 All open issues on the release milestone should be moved to the next release milestone. (e.g. from the \fB0.16\fP milestone to the \fB0.17\fP milestone) .IP 2. 3 Release notes should be created documenting the major new features and bugfixes in the release. .IP 3. 3 Create an annotated tag with only the major and minor version numbers, preceded by the letter \fBv\fP\&. (e.g. \fBv0.16\fP) This tag will reside on the \fBdevelop\fP branch. .IP 4. 3 Create a branch for the new release, using only the major and minor version numbers. (e.g. \fB0.16\fP) .IP 5. 3 On this new branch, create an annotated tag for the first revision release, which is generally a release candidate. It should be preceded by the letter \fBv\fP\&. (e.g. \fBv0.16.0RC\fP) .IP 6. 3 The release should be packaged from this annotated tag and uploaded to PyPI. .IP 7. 3 The packagers should be notified on the \fBsalt\-packagers\fP mailing list so they can create packages for all the major operating systems. (note that release candidates should go in the testing repositories) .IP 8. 3 After the packagers have been given a few days to compile the packages, the release is announced on the \fBsalt\-users\fP mailing list. .IP 9. 3 Log into RTD and add the new release there. (Have to do it manually) .UNINDENT .SS Maintenance and Bugfix Releases .sp Once a release has been cut, regular cherry\-picking sessions should begin to cherry\-pick any bugfixes from the \fBdevelop\fP branch to the release branch (e.g. \fB0.16\fP). Once major bugs have been fixes and cherry\-picked, a bugfix release can be cut: .INDENT 0.0 .IP 1. 3 On the release branch (i.e. \fB0.16\fP), create an annotated tag for the revision release. It should be preceded by the letter \fBv\fP\&. (e.g. \fBv0.16.2\fP) Release candidates are unnecessary for bugfix releases. .IP 2. 3 The release should be packaged from this annotated tag and uploaded to PyPI. .IP 3. 3 The packagers should be notified on the \fBsalt\-packagers\fP mailing list so they can create packages for all the major operating systems. .IP 4. 3 After the packagers have been given a few days to compile the packages, the release is announced on the \fBsalt\-users\fP mailing list. .UNINDENT .SS Salt Coding Style .sp Salt is developed with a certain coding style, while the style is dominantly PEP 8 it is not completely PEP 8. It is also noteworthy that a few development techniques are also employed which should be adhered to. In the end, the code is made to be "Salty". .sp Most importantly though, we will accept code that violates the coding style and KINDLY ask the contributor to fix it, or go ahead and fix the code on behalf of the contributor. Coding style is NEVER grounds to reject code contributions, and is never grounds to talk down to another member of the community (There are no grounds to treat others without respect, especially people working to improve Salt)!! .SS Strings .sp Salt follows a few rules when formatting strings: .SS Single Quotes .sp In Salt, all strings use single quotes unless there is a good reason not to. This means that docstrings use single quotes, standard strings use single quotes etc.: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def foo(): \(aq\(aq\(aq A function that does things \(aq\(aq\(aq name = \(aqA name\(aq return name .ft P .fi .UNINDENT .UNINDENT .SS Formatting Strings .sp All strings which require formatting should use the \fI\&.format\fP string method: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C data = \(aqsome text\(aq more = \(aq{0} and then some\(aq.format(data) .ft P .fi .UNINDENT .UNINDENT .sp Make sure to use indices or identifiers in the format brackets, since empty brackets are not supported by python 2.6. .sp Please do NOT use printf formatting. .SS Docstring Conventions .sp Docstrings should always add a newline, docutils takes care of the new line and it makes the code cleaner and more vertical: .sp \fIGOOD\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def bar(): \(aq\(aq\(aq Here lies a docstring with a newline after the quotes and is the salty way to handle it! Vertical code is the way to go! \(aq\(aq\(aq return .ft P .fi .UNINDENT .UNINDENT .sp \fIBAD\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def baz(): \(aq\(aq\(aqThis is not ok!\(aq\(aq\(aq return .ft P .fi .UNINDENT .UNINDENT .SS Imports .sp Salt code prefers importing modules and not explicit functions. This is both a style and functional preference. The functional preference originates around the fact that the module import system used by pluggable modules will include callable objects (functions) that exist in the direct module namespace. This is not only messy, but may unintentionally expose code python libs to the Salt interface and pose a security problem. .sp To say this more directly with an example, this is \fIGOOD\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import os def minion_path(): path = os.path.join(self.opts[\(aqcachedir\(aq], \(aqminions\(aq) return path .ft P .fi .UNINDENT .UNINDENT .sp This on the other hand is \fIDISCOURAGED\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C from os.path import join def minion_path(): path = join(self.opts[\(aqcachedir\(aq], \(aqminions\(aq) return path .ft P .fi .UNINDENT .UNINDENT .sp The time when this is changed is for importing exceptions, generally directly importing exceptions is preferred: .sp This is a good way to import exceptions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C from salt.exceptions import CommandExecutionError .ft P .fi .UNINDENT .UNINDENT .SS Absolute Imports .sp Although \fI\%absolute imports\fP seems like an awesome idea, please do not use it. Extra care would be necessary all over salt\(aqs code in order for absolute imports to work as supposed. Believe it, it has been tried before and, as a tried example, by renaming \fBsalt.modules.sysmod\fP to \fBsalt.modules.sys\fP, all other salt modules which needed to import \fI\%sys\fP would have to also import \fI\%absolute_import\fP, which should be avoided. .SS Vertical is Better .sp When writing Salt code, vertical code is generally preferred. This is not a hard rule but more of a guideline. As PEP 8 specifies, Salt code should not exceed 79 characters on a line, but it is preferred to separate code out into more newlines in some cases for better readability: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import os os.chmod( os.path.join(self.opts[\(aqsock_dir\(aq], \(aqminion_event_pub.ipc\(aq), 448 ) .ft P .fi .UNINDENT .UNINDENT .sp Where there are more line breaks, this is also apparent when constructing a function with many arguments, something very common in state functions for instance: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def managed(name, source=None, source_hash=\(aq\(aq, user=None, group=None, mode=None, template=None, makedirs=False, context=None, replace=True, defaults=None, env=None, backup=\(aq\(aq, **kwargs): .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Making function and class definitions vertical is only required if the arguments are longer then 80 characters. Otherwise, the formatting is optional and both are acceptable. .UNINDENT .UNINDENT .SS Indenting .sp Some confusion exists in the python world about indenting things like function calls, the above examples use 8 spaces when indenting comma\-delimited constructs. .sp The confusion arises because the pep8 program INCORRECTLY flags this as wrong, where PEP 8, the document, cites only using 4 spaces here as wrong, as it doesn\(aqt differentiate from a new indent level. .sp Right: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def managed(name, source=None, source_hash=\(aq\(aq, user=None) .ft P .fi .UNINDENT .UNINDENT .sp WRONG: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def managed(name, source=None, source_hash=\(aq\(aq, user=None) .ft P .fi .UNINDENT .UNINDENT .sp Lining up the indent is also correct: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def managed(name, source=None, source_hash=\(aq\(aq, user=None) .ft P .fi .UNINDENT .UNINDENT .sp This also applies to function calls and other hanging indents. .sp pep8 and Flake8 (and, by extension, the vim plugin Syntastic) will complain about the double indent for hanging indents. This is a \fI\%known conflict\fP between pep8 (the script) and the actual PEP 8 standard. It is recommended that this particular warning be ignored with the following lines in \fB~/.config/flake8\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C [flake8] ignore = E226,E241,E242,E126 .ft P .fi .UNINDENT .UNINDENT .sp Make sure your Flake8/pep8 are up to date. The first three errors are ignored by default and are present here to keep the behavior the same. This will also work for pep8 without the Flake8 wrapper \-\- just replace all instances of \(aqflake8\(aq with \(aqpep8\(aq, including the filename. .SS Code Churn .sp Many pull requests have been submitted that only churn code in the name of PEP 8. Code churn is a leading source of bugs and is strongly discouraged. While style fixes are encouraged they should be isolated to a single file per commit, and the changes should be legitimate, if there are any questions about whether a style change is legitimate please reference this document and the official PEP 8 (\fI\%http://www.python.org/dev/peps/pep\-0008/\fP) document before changing code. Many claims that a change is PEP 8 have been invalid, please double check before committing fixes. .SH SALT RELEASE PROCESS .sp The goal for Salt projects is to cut a new feature release every four to six weeks. This document outlines the process for these releases, and the subsequent bug fix releases which follow. .SS Feature Release Process .sp When a new release is ready to be cut, the person responsible for cutting the release will follow the following steps (written using the 0.16 release as an example): .INDENT 0.0 .IP 1. 3 All open issues on the release milestone should be moved to the next release milestone. (e.g. from the \fB0.16\fP milestone to the \fB0.17\fP milestone) .IP 2. 3 Release notes should be created documenting the major new features and bugfixes in the release. .IP 3. 3 Create an annotated tag with only the major and minor version numbers, preceded by the letter \fBv\fP\&. (e.g. \fBv0.16\fP) This tag will reside on the \fBdevelop\fP branch. .IP 4. 3 Create a branch for the new release, using only the major and minor version numbers. (e.g. \fB0.16\fP) .IP 5. 3 On this new branch, create an annotated tag for the first revision release, which is generally a release candidate. It should be preceded by the letter \fBv\fP\&. (e.g. \fBv0.16.0RC\fP) .IP 6. 3 The release should be packaged from this annotated tag and uploaded to PyPI. .IP 7. 3 The packagers should be notified on the \fBsalt\-packagers\fP mailing list so they can create packages for all the major operating systems. (note that release candidates should go in the testing repositories) .IP 8. 3 After the packagers have been given a few days to compile the packages, the release is announced on the \fBsalt\-users\fP mailing list. .IP 9. 3 Log into RTD and add the new release there. (Have to do it manually) .UNINDENT .SS Maintenance and Bugfix Releases .sp Once a release has been cut, regular cherry\-picking sessions should begin to cherry\-pick any bugfixes from the \fBdevelop\fP branch to the release branch (e.g. \fB0.16\fP). Once major bugs have been fixes and cherry\-picked, a bugfix release can be cut: .INDENT 0.0 .IP 1. 3 On the release branch (i.e. \fB0.16\fP), create an annotated tag for the revision release. It should be preceded by the letter \fBv\fP\&. (e.g. \fBv0.16.2\fP) Release candidates are unnecessary for bugfix releases. .IP 2. 3 The release should be packaged from this annotated tag and uploaded to PyPI. .IP 3. 3 The packagers should be notified on the \fBsalt\-packagers\fP mailing list so they can create packages for all the major operating systems. .IP 4. 3 After the packagers have been given a few days to compile the packages, the release is announced on the \fBsalt\-users\fP mailing list. .UNINDENT .SH SALT CODING STYLE .sp Salt is developed with a certain coding style, while the style is dominantly PEP 8 it is not completely PEP 8. It is also noteworthy that a few development techniques are also employed which should be adhered to. In the end, the code is made to be "Salty". .sp Most importantly though, we will accept code that violates the coding style and KINDLY ask the contributor to fix it, or go ahead and fix the code on behalf of the contributor. Coding style is NEVER grounds to reject code contributions, and is never grounds to talk down to another member of the community (There are no grounds to treat others without respect, especially people working to improve Salt)!! .SS Strings .sp Salt follows a few rules when formatting strings: .SS Single Quotes .sp In Salt, all strings use single quotes unless there is a good reason not to. This means that docstrings use single quotes, standard strings use single quotes etc.: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def foo(): \(aq\(aq\(aq A function that does things \(aq\(aq\(aq name = \(aqA name\(aq return name .ft P .fi .UNINDENT .UNINDENT .SS Formatting Strings .sp All strings which require formatting should use the \fI\&.format\fP string method: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C data = \(aqsome text\(aq more = \(aq{0} and then some\(aq.format(data) .ft P .fi .UNINDENT .UNINDENT .sp Make sure to use indices or identifiers in the format brackets, since empty brackets are not supported by python 2.6. .sp Please do NOT use printf formatting. .SS Docstring Conventions .sp Docstrings should always add a newline, docutils takes care of the new line and it makes the code cleaner and more vertical: .sp \fIGOOD\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def bar(): \(aq\(aq\(aq Here lies a docstring with a newline after the quotes and is the salty way to handle it! Vertical code is the way to go! \(aq\(aq\(aq return .ft P .fi .UNINDENT .UNINDENT .sp \fIBAD\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def baz(): \(aq\(aq\(aqThis is not ok!\(aq\(aq\(aq return .ft P .fi .UNINDENT .UNINDENT .SS Imports .sp Salt code prefers importing modules and not explicit functions. This is both a style and functional preference. The functional preference originates around the fact that the module import system used by pluggable modules will include callable objects (functions) that exist in the direct module namespace. This is not only messy, but may unintentionally expose code python libs to the Salt interface and pose a security problem. .sp To say this more directly with an example, this is \fIGOOD\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import os def minion_path(): path = os.path.join(self.opts[\(aqcachedir\(aq], \(aqminions\(aq) return path .ft P .fi .UNINDENT .UNINDENT .sp This on the other hand is \fIDISCOURAGED\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C from os.path import join def minion_path(): path = join(self.opts[\(aqcachedir\(aq], \(aqminions\(aq) return path .ft P .fi .UNINDENT .UNINDENT .sp The time when this is changed is for importing exceptions, generally directly importing exceptions is preferred: .sp This is a good way to import exceptions: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C from salt.exceptions import CommandExecutionError .ft P .fi .UNINDENT .UNINDENT .SS Absolute Imports .sp Although \fI\%absolute imports\fP seems like an awesome idea, please do not use it. Extra care would be necessary all over salt\(aqs code in order for absolute imports to work as supposed. Believe it, it has been tried before and, as a tried example, by renaming \fBsalt.modules.sysmod\fP to \fBsalt.modules.sys\fP, all other salt modules which needed to import \fI\%sys\fP would have to also import \fI\%absolute_import\fP, which should be avoided. .SS Vertical is Better .sp When writing Salt code, vertical code is generally preferred. This is not a hard rule but more of a guideline. As PEP 8 specifies, Salt code should not exceed 79 characters on a line, but it is preferred to separate code out into more newlines in some cases for better readability: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import os os.chmod( os.path.join(self.opts[\(aqsock_dir\(aq], \(aqminion_event_pub.ipc\(aq), 448 ) .ft P .fi .UNINDENT .UNINDENT .sp Where there are more line breaks, this is also apparent when constructing a function with many arguments, something very common in state functions for instance: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def managed(name, source=None, source_hash=\(aq\(aq, user=None, group=None, mode=None, template=None, makedirs=False, context=None, replace=True, defaults=None, env=None, backup=\(aq\(aq, **kwargs): .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Making function and class definitions vertical is only required if the arguments are longer then 80 characters. Otherwise, the formatting is optional and both are acceptable. .UNINDENT .UNINDENT .SS Indenting .sp Some confusion exists in the python world about indenting things like function calls, the above examples use 8 spaces when indenting comma\-delimited constructs. .sp The confusion arises because the pep8 program INCORRECTLY flags this as wrong, where PEP 8, the document, cites only using 4 spaces here as wrong, as it doesn\(aqt differentiate from a new indent level. .sp Right: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def managed(name, source=None, source_hash=\(aq\(aq, user=None) .ft P .fi .UNINDENT .UNINDENT .sp WRONG: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def managed(name, source=None, source_hash=\(aq\(aq, user=None) .ft P .fi .UNINDENT .UNINDENT .sp Lining up the indent is also correct: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def managed(name, source=None, source_hash=\(aq\(aq, user=None) .ft P .fi .UNINDENT .UNINDENT .sp This also applies to function calls and other hanging indents. .sp pep8 and Flake8 (and, by extension, the vim plugin Syntastic) will complain about the double indent for hanging indents. This is a \fI\%known conflict\fP between pep8 (the script) and the actual PEP 8 standard. It is recommended that this particular warning be ignored with the following lines in \fB~/.config/flake8\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C [flake8] ignore = E226,E241,E242,E126 .ft P .fi .UNINDENT .UNINDENT .sp Make sure your Flake8/pep8 are up to date. The first three errors are ignored by default and are present here to keep the behavior the same. This will also work for pep8 without the Flake8 wrapper \-\- just replace all instances of \(aqflake8\(aq with \(aqpep8\(aq, including the filename. .SS Code Churn .sp Many pull requests have been submitted that only churn code in the name of PEP 8. Code churn is a leading source of bugs and is strongly discouraged. While style fixes are encouraged they should be isolated to a single file per commit, and the changes should be legitimate, if there are any questions about whether a style change is legitimate please reference this document and the official PEP 8 (\fI\%http://www.python.org/dev/peps/pep\-0008/\fP) document before changing code. Many claims that a change is PEP 8 have been invalid, please double check before committing fixes. .SH SALT STACK GIT POLICY .sp The Salt Stack team follows a git policy to maintain stability and consistency with the repository. The git policy has been developed to encourage contributions and make contributing to Salt as easy as possible. Code contributors to Salt Stack projects DO NOT NEED TO READ THIS DOCUMENT, because all contributions come into Salt Stack via a single gateway to make it as easy as possible for contributors to give us code. .sp The primary rule of git management in Salt Stack is to make life easy on contributors and developers to send in code. Simplicity is always a goal! .SS New Code Entry .sp All new Salt Stack code is posted to the \fIdevelop\fP branch, this is the single point of entry. The only exception here is when a bugfix to develop cannot be cleanly merged into a release branch and the bugfix needs to be rewritten for the release branch. .SS Release Branching .sp Salt Stack maintains two types of releases, \fIFeature Releases\fP and \fIPoint Releases\fP\&. A feature release is managed by incrementing the first or second release point number, so 0.10.5 \-> 0.11.0 signifies a feature release and 0.11.0 \-> 0.11.1 signifies a point release, also a hypothetical 0.42.7 \-> 1.0.0 would also signify a feature release. .SS Feature Release Branching .sp Each feature release is maintained in a dedicated git branch derived from the last applicable release commit on develop. All file changes relevant to the feature release will be completed in the develop branch prior to the creation of the feature release branch. The feature release branch will be named after the relevant numbers to the feature release, which constitute the first two numbers. This means that the release branch for the 0.11.0 series is named 0.11. .sp A feature release branch is created with the following command: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # git checkout \-b 0.11 # From the develop branch # git push origin 0.11 .ft P .fi .UNINDENT .UNINDENT .SS Point Releases .sp Each point release is derived from its parent release branch. Constructing point releases is a critical aspect of Salt development and is managed by members of the core development team. Point releases comprise bug and security fixes which are cherry picked from develop onto the aforementioned release branch. At the time when a core developer accepts a pull request a determination needs to be made if the commits in the pull request need to be backported to the release branch. Some simple criteria are used to make this determination: .INDENT 0.0 .IP \(bu 2 Is this commit fixing a bug? Backport .IP \(bu 2 Does this commit change or add new features in any way? Don\(aqt backport .IP \(bu 2 Is this a PEP8 or code cleanup commit? Don\(aqt backport .IP \(bu 2 Does this commit fix a security issue? Backport .UNINDENT .sp Determining when a point release is going to be made is up to the project leader (Thomas Hatch). Generally point releases are made every 1\-2 weeks or if there is a security fix they can be made sooner. .sp The point release is only designated by tagging the commit on the release branch with release number using the existing convention (version 0.11.1 is tagged with v0.11.1). From the tag point a new source tarball is generated and published to PyPI, and a release announcement is made. .SH SALT DEVELOPMENT GUIDELINES .SS Deprecating Code .sp Salt should remain backwards compatible, though sometimes, this backwards compatibility needs to be broken because a specific feature and/or solution is no longer necessary or required. At first one might think, let me change this code, it seems that it\(aqs not used anywhere else so it should be safe to remove. Then, once there\(aqs a new release, users complain about functionality which was removed and they where using it, etc. This should, at all costs, be avoided, and, in these cases, \fIthat\fP specific code should be deprecated. .sp Depending on the complexity and usage of a specific piece of code, the deprecation time frame should be properly evaluated. As an example, a deprecation warning which is shown for 2 major releases, for example \fI0.17.0\fP and \fI0.18.0\fP, gives users enough time to stop using the deprecated code and adapt to the new one. .sp For example, if you\(aqre deprecating the usage of a keyword argument to a function, that specific keyword argument should remain in place for the full deprecation time frame and if that keyword argument is used, a deprecation warning should be shown to the user. .sp To help in this deprecation task, salt provides \fBsalt.utils.warn_until\fP\&. The idea behind this helper function is to show the deprecation warning until salt reaches the provided version. Once that provided version is equaled \fBsalt.utils.warn_until\fP will raise a \fI\%RuntimeError\fP making salt stop its execution. This stoppage is unpleasant and will remind the developer that the deprecation limit has been reached and that the code can then be safely removed. .sp Consider the following example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def some_function(bar=False, foo=None): if foo is not None: salt.utils.warn_until( (0, 18), \(aqThe \e\(aqfoo\e\(aq argument has been deprecated and its \(aq \(aqfunctionality removed, as such, its usage is no longer \(aq \(aqrequired.\(aq ) .ft P .fi .UNINDENT .UNINDENT .sp Consider that the current salt release is \fB0.16.0\fP\&. Whenever \fBfoo\fP is passed a value different from \fBNone\fP that warning will be shown to the user. This will happen in versions \fB0.16.2\fP to \fB0.18.0\fP, after which a \fI\%RuntimeError\fP will be raised making us aware that the deprecated code should now be removed. .SS Dunder Dictionaries .sp Salt provides several special "dunder" dictionaries as a convenience for Salt development. These include \fB__opts__\fP, \fB__context__\fP, \fB__salt__\fP, and others. This document will describe each dictionary and detail where they exist and what information and/or functionality they provide. .SS __context__ .sp \fB__context__\fP exists in state modules and execution modules. .sp During a state run the \fB__context__\fP dictionary persists across all states that are run and then is destroyed when the state ends. .sp When running an execution module \fB__context__\fP persists across all module executions until the modules are refreshed; such as when \fBsaltutils.sync_all\fP or \fBstate.highstate\fP are executed. .sp A great place to see how to use \fB__context__\fP is in the cp.py module in salt/modules/cp.py. The fileclient authenticates with the master when it is instantiated and then is used to copy files to the minion. Rather than create a new fileclient for each file that is to be copied down, one instance of the fileclient is instantiated in the \fB__context__\fP dictionary and is reused for each file. Here is an example from salt/modules/cp.py: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C if not \(aqcp.fileclient\(aq in __context__: __context__[\(aqcp.fileclient\(aq] = salt.fileclient.get_file_client(__opts__) .ft P .fi .UNINDENT .UNINDENT .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 Because __context__ may or may not have been destroyed, always be sure to check for the existence of the key in __context__ and generate the key before using it. .UNINDENT .UNINDENT .SS External Pillars .sp Salt provides a mechanism for generating pillar data by calling external pillar interfaces. This document will describe an outline of an ext_pillar module. .SS Location .sp Salt expects to find your \fBext_pillar\fP module in the same location where it looks for other python modules. If the \fBextension_modules\fP option in your Salt master configuration is set, Salt will look for a \fBpillar\fP directory under there and load all the modules it finds. Otherwise, it will look in your Python site\-packages \fBsalt/pillar\fP directory. .SS Configuration .sp The external pillars that are called when a minion refreshes its pillars is controlled by the \fBext_pillar\fP option in the Salt master configuration. You can pass a single argument, a list of arguments or a dictionary of arguments to your pillar: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C ext_pillar: \- example_a: some argument \- example_b: \- argumentA \- argumentB \- example_c: keyA: valueA keyB: valueB .ft P .fi .UNINDENT .UNINDENT .SS The Module .SS Imports and Logging .sp Import modules your external pillar module needs. You should first include generic modules that come with stock Python: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C import logging .ft P .fi .UNINDENT .UNINDENT .sp And then start logging. This is an idiomatic way of setting up logging in Salt: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log = logging.getLogger(__name__) .ft P .fi .UNINDENT .UNINDENT .sp Finally, load modules that are specific to what you are doing. You should catch import errors and set a flag that the the \fB__virtual__\fP function can use later. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C try: import weird_thing example_a_loaded = True except ImportError: example_a_loaded = False .ft P .fi .UNINDENT .UNINDENT .SS Options .sp If you define an \fB__opts__\fP dictionary, it will be merged into the \fB__opts__\fP dictionary handed to the \fBext_pillar\fP function later. This is a good place to put default configuration items. The convention is to name things \fBmodulename.option\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C __opts__ = { \(aqexample_a.someconfig\(aq: 137 } .ft P .fi .UNINDENT .UNINDENT .SS Initialization .sp If you define an \fB__init__\fP function, it will be called with the following signature: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def __init__( __opts__ ): # Do init work here .ft P .fi .UNINDENT .UNINDENT .sp \fBNote\fP: The \fB__init__\fP function is ran every time a particular minion causes the external pillar to be called, so don\(aqt put heavy initialization code here. The \fB__init__\fP functionality is a side\-effect of the Salt loader, so it may not be as useful in pillars as it is in other Salt items. .SS __virtual__ .sp If you define a \fB__virtual__\fP function, you can control whether or not this module is visible. If it returns \fBFalse\fP then Salt ignores this module. If it returns a string, then that string will be how Salt identifies this external pillar in its \fBext_pillar\fP configuration. If this function does not exist, then the name Salt\(aqs \fBext_pillar\fP will use to identify this module is its conventional name in Python. .sp This is useful to write modules that can be installed on all Salt masters, but will only be visible if a particular piece of software your module requires is installed. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # This external pillar will be known as \(gaexample_a\(ga def __virtual__(): if example_a_loaded: return \(aqexample_a\(aq else: return False .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C # This external pillar will be known as \(gasomething_else\(ga def __virtual__(): if example_a_loaded: return \(aqsomething_else\(aq else: return False .ft P .fi .UNINDENT .UNINDENT .SS ext_pillar .sp This is where the real work of an external pillar is done. If this module is active and has a function called \fBext_pillar\fP, whenever a minion updates its pillar this function is called. .sp How it is called depends on how it is configured in the Salt master configuration. The first argument is always the current pillar dictionary, this contains pillar items that have already been added, starting with the data from \fBpillar_roots\fP, and then from any already\-ran external pillars. .sp Using our example above: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C ext_pillar( pillar, \(aqsome argument\(aq ) # example_a ext_pillar( pillar, \(aqargumentA\(aq, \(aqargumentB\(aq ) # example_b ext_pillar( pillar, keyA=\(aqvalueA\(aq, keyB=\(aqvalueB\(aq } ) # example_c .ft P .fi .UNINDENT .UNINDENT .sp In the \fBexample_a\fP case, \fBpillar\fP will contain the items from the \fBpillar_roots\fP, in \fBexample_b\fP \fBpillar\fP will contain that plus the items added by \fBexample_a\fP, and in \fBexample_c\fP \fBpillar\fP will contain that plus the items added by \fBexample_b\fP\&. .sp This function should return a dictionary, the contents of which are merged in with all of the other pillars and returned to the minion. \fBNote\fP: this function is called once for each minion that fetches its pillar data. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def ext_pillar( pillar, *args, **kwargs ): my_pillar = {} # Do stuff return my_pillar .ft P .fi .UNINDENT .UNINDENT .sp You shouldn\(aqt just add items to \fBpillar\fP and return that, since that will cause Salt to merge data that already exists. Rather, just return the items you are adding or changing. You could, however, use \fBpillar\fP in your module to make some decision based on pillar data that already exists. .sp This function has access to some useful globals: .INDENT 0.0 .TP .B __opts__ A dictionary of mostly Salt configuration options. If you had an \fB__opts__\fP dictionary defined in your module, those values will be included. Also included and most useful is \fB__opts__[\(aqid\(aq]\fP, which is the minion id of the minion asking for pillar data. .TP .B __salt__ A dictionary of Salt module functions, useful so you don\(aqt have to duplicate functions that already exist. E.g. \fB__salt__[\(aqcmd.run\(aq]( \(aqls \-l\(aq )\fP \fBNote\fP, runs on the \fImaster\fP .TP .B __grains__ A dictionary of the grains of the minion making this pillar call. .UNINDENT .SS Example configuration .sp As an example, if you wanted to add external pillar via the \fBcmd_json\fP external pillar, add something like this to your master config: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C ext_pillar: \- cmd_json: "echo {\(aqarg\(aq:\(aqvalue\(aq}" .ft P .fi .UNINDENT .UNINDENT .SS Logging Internals .sp TODO .SS Modular Systems .sp When first working with Salt, it is not always clear where all of the modular components are and what they do. Salt comes loaded with more modular systems than many users are aware of, making Salt very easy to extend in many places. .sp The most commonly used modular systems are execution modules and states. But the modular systems extend well beyond the more easily exposed components and are often added to Salt to make the complete system more flexible. .SS Execution Modules .sp Execution modules make up the core of the functionality used by Salt to interact with client systems. The execution modules create the core system management library used by all Salt systems, including states, which interact with minion systems. .sp Execution modules are completely open ended in their execution. They can be used to do anything required on a minion, from installing packages to detecting information about the system. The only restraint in execution modules is that the defined functions always return a JSON serializable object. .sp For a list of all built in execution modules, click \fBhere\fP .sp For information on writing execution modules, see \fBthis page\fP\&. .SS State Modules .sp State modules are used to define the state interfaces used by Salt States. These modules are restrictive in that they must follow a number of rules to function properly. .sp \fBNOTE:\fP .INDENT 0.0 .INDENT 3.5 State modules define the available routines in sls files. If calling an execution module directly is desired, take a look at the \fImodule\fP state. .UNINDENT .UNINDENT .SS Auth .sp The auth module system allows for external authentication routines to be easily added into Salt. The \fIauth\fP function needs to be implemented to satisfy the requirements of an auth module. Use the \fBpam\fP module as an example. .SS Fileserver .sp The fileserver module system is used to create fileserver backends used by the Salt Master. These modules need to implement the functions used in the fileserver subsystem. Use the \fBgitfs\fP module as an example. .SS Grains .sp Grain modules define extra routines to populate grains data. All defined public functions will be executed and MUST return a Python dict object. The dict keys will be added to the grains made available to the minion. .SS Output .sp The output modules supply the outputter system with routines to display data in the terminal. These modules are very simple and only require the \fIoutput\fP function to execute. The default system outputter is the \fBnested\fP module. .SS Pillar .sp Used to define optional external pillar systems. The pillar generated via the filesystem pillar is passed into external pillars. This is commonly used as a bridge to database data for pillar, but is also the backend to the libvirt state used to generate and sign libvirt certificates on the fly. .SS Renderers .sp Renderers are the system used to render sls files into salt highdata for the state compiler. They can be as simple as the \fBpy\fP renderer and as complex as \fBstateconf\fP and \fBpydsl\fP\&. .SS Returners .sp Returners are used to send data from minions to external sources, commonly databases. A full returner will implement all routines to be supported as an external job cache. Use the \fBredis\fP returner as an example. .SS Runners .sp Runners are purely master\-side execution sequences. These range from simple reporting to orchestration engines like the overstate. .SS Tops .sp Tops modules are used to convert external data sources into top file data for the state system. .SS Wheel .sp The wheel system is used to manage master side management routines. These routines are primarily intended for the API to enable master configuration. .SS Package Providers .sp This page contains guidelines for writing package providers. .SS Package Functions .sp One of the most important features of Salt is package management. There is no shortage of package managers, so in the interest of providing a consistent experience in \fBpkg\fP states, there are certain functions that should be present in a package provider. Note that these are subject to change as new features are added or existing features are enhanced. .SS list_pkgs .sp This function should declare an empty dict, and then add packages to it by calling \fBpkg_resource.add_pkg\fP, like so: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C __salt__[\(aqpkg_resource.add_pkg\(aq](ret, name, version) .ft P .fi .UNINDENT .UNINDENT .sp The last thing that should be done before returning is to execute \fBpkg_resource.sort_pkglist\fP\&. This function does not presently do anything to the return dict, but will be used in future versions of Salt. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C __salt__[\(aqpkg_resource.sort_pkglist\(aq](ret) .ft P .fi .UNINDENT .UNINDENT .sp \fBlist_pkgs\fP returns a dictionary of installed packages, with the keys being the package names and the values being the version installed. Example return data: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {\(aqfoo\(aq: \(aq1.2.3\-4\(aq, \(aqbar\(aq: \(aq5.6.7\-8\(aq} .ft P .fi .UNINDENT .UNINDENT .SS latest_version .sp Accepts an arbitrary number of arguments. Each argument is a package name. The return value for a package will be an empty string if the package is not found or if the package is up\-to\-date. The only case in which a non\-empty string is returned is if the package is available for new installation (i.e. not already installed) or if there is an upgrade available. .sp If only one argument was passed, this function return a string, otherwise a dict of name/version pairs is returned. .sp This function must also accept \fB**kwargs\fP, in order to receive the \fBfromrepo\fP and \fBrepo\fP keyword arguments from pkg states. Where supported, these arguments should be used to find the install/upgrade candidate in the specified repository. The \fBfromrepo\fP kwarg takes precedence over \fBrepo\fP, so if both of those kwargs are present, the repository specified in \fBfromrepo\fP should be used. However, if \fBrepo\fP is used instead of \fBfromrepo\fP, it should still work, to preserve backwards compatibility with older versions of Salt. .SS version .sp Like \fBlatest_version\fP, accepts an arbitrary number of arguments and returns a string if a single package name was passed, or a dict of name/value pairs if more than one was passed. The only difference is that the return values are the currently\-installed versions of whatever packages are passed. If the package is not installed, an empty string is returned for that package. .SS upgrade_available .sp Deprecated and destined to be removed. For now, should just do the following: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C return __salt__[\(aqpkg.latest_version\(aq](name) != \(aq\(aq .ft P .fi .UNINDENT .UNINDENT .SS install .sp The following arguments are required and should default to \fBNone\fP: .INDENT 0.0 .IP 1. 3 name (for single\-package pkg states) .IP 2. 3 pkgs (for multiple\-package pkg states) .IP 3. 3 sources (for binary package file installation) .UNINDENT .sp The first thing that this function should do is call \fBpkg_resource.parse_targets\fP (see below). This function will convert the SLS input into a more easily parsed data structure. \fBpkg_resource.parse_targets\fP may need to be modified to support your new package provider, as it does things like parsing package metadata which cannot be done for every package management system. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C pkg_params, pkg_type = __salt__[\(aqpkg_resource.parse_targets\(aq](name, pkgs, sources) .ft P .fi .UNINDENT .UNINDENT .sp Two values will be returned to the \fBinstall\fP function. The first of them will be a dictionary. The keys of this dictionary will be package names, though the values will differ depending on what kind of installation is being done: .INDENT 0.0 .IP \(bu 2 If \fBname\fP was provided (and \fBpkgs\fP was not), then there will be a single key in the dictionary, and its value will be \fBNone\fP\&. Once the data has been returned, if the \fBversion\fP keyword argument was provided, then it should replace the \fBNone\fP value in the dictionary. .IP \(bu 2 If \fBpkgs\fP was provided, then \fBname\fP is ignored, and the dictionary will contain one entry for each package in the \fBpkgs\fP list. The values in the dictionary will be \fBNone\fP if a version was not specified for the package, and the desired version if specified. See the \fBMultiple Package Installation Options\fP section of the \fBpkg.installed\fP state for more info. .IP \(bu 2 If \fBsources\fP was provided, then \fBname\fP is ignored, and the dictionary values will be the path/URI for the package. .UNINDENT .sp The second return value will be a string with two possible values: \fBrepository\fP or \fBfile\fP\&. The \fBinstall\fP function can use this value (if necessary) to build the proper command to install the targeted package(s). .sp Both before and after the installing the target(s), you should run \fBlist_pkgs\fP to obtain a list of the installed packages. You should then return the output of \fBpkg_resource.find_changes\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C return __salt__[\(aqpkg_resource.find_changes\(aq](old, new) .ft P .fi .UNINDENT .UNINDENT .SS remove .sp Removes the passed package and return a list of the packages removed. .SS Package Repo Functions .sp There are some functions provided by \fBpkg\fP which are specific to package repositories, and not to packages themselves. When writing modules for new package managers, these functions should be made available as stated below, in order to provide compatibility with the \fBpkgrepo\fP state. .sp All repo functions should accept a basedir option, which defines which directory repository configuration should be found in. The default for this is dictated by the repo manager that is being used, and rarely needs to be changed. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C basedir = \(aq/etc/yum.repos.d\(aq __salt__[\(aqpkg.list_repos\(aq](basedir) .ft P .fi .UNINDENT .UNINDENT .SS list_repos .sp Lists the repositories that are currently configured on this system. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C __salt__[\(aqpkg.list_repos\(aq]() .ft P .fi .UNINDENT .UNINDENT .sp Returns a dictionary, in the following format: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {\(aqreponame\(aq: \(aqconfig_key_1\(aq: \(aqconfig value 1\(aq, \(aqconfig_key_2\(aq: \(aqconfig value 2\(aq, \(aqconfig_key_3\(aq: [\(aqlist item 1 (when appropriate)\(aq, \(aqlist item 2 (when appropriate)]} .ft P .fi .UNINDENT .UNINDENT .SS get_repo .sp Displays all local configuration for a specific repository. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C __salt__[\(aqpkg.get_repo\(aq](repo=\(aqmyrepo\(aq) .ft P .fi .UNINDENT .UNINDENT .sp The information is formatted in much the same way as list_repos, but is specific to only one repo. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {\(aqconfig_key_1\(aq: \(aqconfig value 1\(aq, \(aqconfig_key_2\(aq: \(aqconfig value 2\(aq, \(aqconfig_key_3\(aq: [\(aqlist item 1 (when appropriate)\(aq, \(aqlist item 2 (when appropriate)]} .ft P .fi .UNINDENT .UNINDENT .SS del_repo .sp Removes the local configuration for a specific repository. Requires a \fIrepo\fP argument, which must match the locally configured name. This function returns a string, which informs the user as to whether or not the operation was a success. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C __salt__[\(aqpkg.del_repo\(aq](repo=\(aqmyrepo\(aq) .ft P .fi .UNINDENT .UNINDENT .SS mod_repo .sp Modify the local configuration for one or more option for a configured repo. This is also the way to create new repository configuration on the local system; if a repo is specified which does not yet exist, it will be created. .sp The options specified for this function are specific to the system; please refer to the documentation for your specific repo manager for specifics. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C __salt__[\(aqpkg.mod_repo\(aq](repo=\(aqmyrepo\(aq, url=\(aqhttp://myurl.com/repo\(aq) .ft P .fi .UNINDENT .UNINDENT .SS Low\-Package Functions .sp In general, the standard package functions as describes above will meet your needs. These functions use the system\(aqs native repo manager (for instance, yum or the apt tools). In most cases, the repo manager is actually separate from the package manager. For instance, yum is usually a front\-end for rpm, and apt is usually a front\-end for dpkg. When possible, the package functions that use those package managers directly should do so through the low package functions. .sp It is normal and sane for \fBpkg\fP to make calls to \fBlowpkgs\fP, but \fBlowpkg\fP must never make calls to \fBpkg\fP\&. This is affects functions which are required by both \fBpkg\fP and \fBlowpkg\fP, but the technique in \fBpkg\fP is more performant than what is available to \fBlowpkg\fP\&. When this is the case, the \fBlowpkg\fP function that requires that technique must still use the \fBlowpkg\fP version. .SS list_pkgs .sp Returns a dict of packages installed, including the package name and version. Can accept a list of packages; if none are specified, then all installed packages will be listed. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C installed = __salt__[\(aqlowpkg.list_pkgs\(aq](\(aqfoo\(aq, \(aqbar\(aq) .ft P .fi .UNINDENT .UNINDENT .sp Example output: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {\(aqfoo\(aq: \(aq1.2.3\-4\(aq, \(aqbar\(aq: \(aq5.6.7\-8\(aq} .ft P .fi .UNINDENT .UNINDENT .SS verify .sp Many (but not all) package management systems provide a way to verify that the files installed by the package manager have or have not changed. This function accepts a list of packages; if none are specified, all packages will be included. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C installed = __salt__[\(aqlowpkg.verify\(aq](\(aqhttpd\(aq) .ft P .fi .UNINDENT .UNINDENT .sp Example output: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {\(aq/etc/httpd/conf/httpd.conf\(aq: {\(aqmismatch\(aq: [\(aqsize\(aq, \(aqmd5sum\(aq, \(aqmtime\(aq], \(aqtype\(aq: \(aqconfig\(aq}} .ft P .fi .UNINDENT .UNINDENT .SS file_list .sp Lists all of the files installed by all packages specified. If not packages are specified, then all files for all known packages are returned. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C installed = __salt__[\(aqlowpkg.file_list\(aq](\(aqhttpd\(aq, \(aqapache\(aq) .ft P .fi .UNINDENT .UNINDENT .sp This function does not return which files belong to which packages; all files are returned as one giant list (hence the \fIfile_list\fP function name. However, This information is still returned inside of a dict, so that it can provide any errors to the user in a sane manner. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {\(aqerrors\(aq: [\(aqpackage apache is not installed\(aq], \(aqfiles\(aq: [\(aq/etc/httpd\(aq, \(aq/etc/httpd/conf\(aq, \(aq/etc/httpd/conf.d\(aq, \(aq...SNIP...\(aq]} .ft P .fi .UNINDENT .UNINDENT .SS file_dict .sp Lists all of the files installed by all packages specified. If not packages are specified, then all files for all known packages are returned. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C installed = __salt__[\(aqlowpkg.file_dict\(aq](\(aqhttpd\(aq, \(aqapache\(aq, \(aqkernel\(aq) .ft P .fi .UNINDENT .UNINDENT .sp Unlike \fIfile_list\fP, this function will break down which files belong to which packages. It will also return errors in the same manner as \fIfile_list\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C {\(aqerrors\(aq: [\(aqpackage apache is not installed\(aq], \(aqpackages\(aq: {\(aqhttpd\(aq: [\(aq/etc/httpd\(aq, \(aq/etc/httpd/conf\(aq, \(aq...SNIP...\(aq], \(aqkernel\(aq: [\(aq/boot/.vmlinuz\-2.6.32\-279.el6.x86_64.hmac\(aq, \(aq/boot/System.map\-2.6.32\-279.el6.x86_64\(aq, \(aq...SNIP...\(aq]}} .ft P .fi .UNINDENT .UNINDENT .SH LOGGING .sp The salt project tries to get the logging to work for you and help us solve any issues you might find along the way. .sp If you want to get some more information on the nitty\-gritty of salt\(aqs logging system, please head over to the \fBlogging development document\fP, if all you\(aqre after is salt\(aqs logging configurations, please continue reading. .SS Available Configuration Settings .SS \fBlog_file\fP .sp The log records can be sent to a regular file, local path name, or network location. Remote logging works best when configured to use rsyslogd(8) (e.g.: \fBfile:///dev/log\fP), with rsyslogd(8) configured for network logging. The format for remote addresses is: \fB://:/\fP\&. .sp Default: Dependant of the binary being executed, for example, for \fBsalt\-master\fP, \fB/var/log/salt/master\fP\&. .sp Examples: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_file: /var/log/salt/master .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_file: /var/log/salt/minion .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_file: file:///dev/log .ft P .fi .UNINDENT .UNINDENT .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_file: udp://loghost:10514 .ft P .fi .UNINDENT .UNINDENT .SS \fBlog_level\fP .sp Default: \fBwarning\fP .sp The level of log record messages to send to the console. One of \fBall\fP, \fBgarbage\fP, \fBtrace\fP, \fBdebug\fP, \fBinfo\fP, \fBwarning\fP, \fBerror\fP, \fBcritical\fP, \fBquiet\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_level: warning .ft P .fi .UNINDENT .UNINDENT .SS \fBlog_level_logfile\fP .sp Default: \fBwarning\fP .sp The level of messages to send to the log file. One of \fBall\fP, \fBgarbage\fP, \fBtrace\fP, \fBdebug\fP, \fBinfo\fP, \fBwarning\fP, \fBerror\fP, \fBcritical\fP, \fBquiet\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_level_logfile: warning .ft P .fi .UNINDENT .UNINDENT .SS \fBlog_datefmt\fP .sp Default: \fB%H:%M:%S\fP .sp The date and time format used in console log messages. Allowed date/time formatting can be seen on \fI\%time.strftime\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_datefmt: \(aq%H:%M:%S\(aq .ft P .fi .UNINDENT .UNINDENT .SS \fBlog_datefmt_logfile\fP .sp Default: \fB%Y\-%m\-%d %H:%M:%S\fP .sp The date and time format used in log file messages. Allowed date/time formatting can be seen on \fI\%time.strftime\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_datefmt_logfile: \(aq%Y\-%m\-%d %H:%M:%S\(aq .ft P .fi .UNINDENT .UNINDENT .SS \fBlog_fmt_console\fP .sp Default: \fB[%(levelname)\-8s] %(message)s\fP .sp The format of the console logging messages. Allowed formatting options can be seen on the \fI\%LogRecord attributes\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_fmt_console: \(aq[%(levelname)\-8s] %(message)s\(aq .ft P .fi .UNINDENT .UNINDENT .SS \fBlog_fmt_logfile\fP .sp Default: \fB%(asctime)s,%(msecs)03.0f [%(name)\-17s][%(levelname)\-8s] %(message)s\fP .sp The format of the log file logging messages. Allowed formatting options can be seen on the \fI\%LogRecord attributes\fP\&. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_fmt_logfile: \(aq%(asctime)s,%(msecs)03.0f [%(name)\-17s][%(levelname)\-8s] %(message)s\(aq .ft P .fi .UNINDENT .UNINDENT .SS \fBlog_granular_levels\fP .sp Default: \fB{}\fP .sp This can be used to control logging levels more specifically. The example sets the main salt library at the \(aqwarning\(aq level, but sets \fBsalt.modules\fP to log at the \fBdebug\fP level: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C log_granular_levels: \(aqsalt\(aq: \(aqwarning\(aq, \(aqsalt.modules\(aq: \(aqdebug\(aq .ft P .fi .UNINDENT .UNINDENT .SS External Logging Handlers .sp Besides the internal logging handlers used by salt, there are some external which can be used, see the \fBexternal logging handlers\fP document. .SH EXTERNAL LOGGING HANDLERS .TS center; |l|l|. _ T{ \fBlogstash_mod\fP T} T{ .INDENT 0.0 .TP .B codeauthor Pedro Algarvio (\fI\%pedro@algarvio.me\fP) .UNINDENT T} _ T{ \fBsentry_mod\fP T} T{ .INDENT 0.0 .TP .B codeauthor Pedro Algarvio (\fI\%pedro@algarvio.me\fP) .UNINDENT T} _ .TE .SS Logstash Logging Handler .sp New in version 0.17.0. .sp This module provides some \fI\%Logstash\fP logging handlers. .SS UDP Logging Handler .sp In order to setup the datagram handler for \fI\%Logstash\fP, please define on the salt configuration file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C logstash_udp_handler: host: 127.0.0.1 port = 9999 .ft P .fi .UNINDENT .UNINDENT .sp On the \fI\%Logstash\fP configuration file you need something like: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C input { udp { type => "udp\-type" format => "json_event" } } .ft P .fi .UNINDENT .UNINDENT .sp Please read the \fI\%UDP input\fP configuration page for additional information. .SS ZeroMQ Logging Handler .sp In order to setup the ZMQ handler for \fI\%Logstash\fP, please define on the salt configuration file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C logstash_zmq_handler: address: tcp://127.0.0.1:2021 .ft P .fi .UNINDENT .UNINDENT .sp On the \fI\%Logstash\fP configuration file you need something like: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C input { zeromq { type => "zeromq\-type" mode => "server" topology => "pubsub" address => "tcp://0.0.0.0:2021" charset => "UTF\-8" format => "json_event" } } .ft P .fi .UNINDENT .UNINDENT .sp Please read the \fI\%ZeroMQ input\fP configuration page for additional information. .INDENT 0.0 .INDENT 3.5 .IP "Important Logstash Setting" .sp One of the most important settings that you should not forget on your \fI\%Logstash\fP configuration file regarding these logging handlers is \fBformat\fP\&. Both the \fIUDP\fP and \fIZeroMQ\fP inputs need to have \fBformat\fP as \fBjson_event\fP which is what we send over the wire. .UNINDENT .UNINDENT .SS Log Level .sp Both the \fBlogstash_udp_handler\fP and the \fBlogstash_zmq_handler\fP configuration sections accept an additional setting \fBlog_level\fP\&. If not set, the logging level used will be the one defined for \fBlog_level\fP in the global configuration file section. .SS HWM .sp The \fI\%high water mark\fP for the ZMQ socket setting. Only applicable for the \fBlogstash_zmq_handler\fP\&. .INDENT 0.0 .INDENT 3.5 .IP "Inspiration" .sp This work was inspired in \fI\%pylogstash\fP, \fI\%python\-logstash\fP, \fI\%canary\fP and the \fI\%PyZMQ logging handler\fP\&. .UNINDENT .UNINDENT .SS Sentry Logging Handler .sp New in version 0.17.0. .sp Configuring the python \fI\%Sentry\fP client, \fI\%Raven\fP, should be done under the \fBsentry_handler\fP configuration key. At the bare minimum, you need to define the \fI\%DSN\fP\&. As an example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sentry_handler: dsn: https://pub\-key:secret\-key@app.getsentry.com/app\-id .ft P .fi .UNINDENT .UNINDENT .sp More complex configurations can be achieved, for example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sentry_handler: servers: \- https://sentry.example.com \- http://192.168.1.1 project: app\-id public_key: deadbeefdeadbeefdeadbeefdeadbeef secret_key: beefdeadbeefdeadbeefdeadbeefdead .ft P .fi .UNINDENT .UNINDENT .sp All the client configuration keys are supported, please see the \fI\%Raven client documentation\fP\&. .sp The default logging level for the sentry handler is \fBERROR\fP\&. If you wish to define a different one, define \fBlog_level\fP under the \fBsentry_handler\fP configuration key: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sentry_handler: dsn: https://pub\-key:secret\-key@app.getsentry.com/app\-id log_level: warning .ft P .fi .UNINDENT .UNINDENT .sp The available log levels are those also available for the salt \fBcli\fP tools and configuration; \fBsalt \-\-help\fP should give you the required information. .SS Threaded Transports .sp Raven\(aqs documents rightly suggest using its threaded transport for critical applications. However, don\(aqt forget that if you start having troubles with Salt after enabling the threaded transport, please try switching to a non\-threaded transport to see if that fixes your problem. .SH LOGSTASH LOGGING HANDLER .sp New in version 0.17.0. .sp This module provides some \fI\%Logstash\fP logging handlers. .SS UDP Logging Handler .sp In order to setup the datagram handler for \fI\%Logstash\fP, please define on the salt configuration file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C logstash_udp_handler: host: 127.0.0.1 port = 9999 .ft P .fi .UNINDENT .UNINDENT .sp On the \fI\%Logstash\fP configuration file you need something like: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C input { udp { type => "udp\-type" format => "json_event" } } .ft P .fi .UNINDENT .UNINDENT .sp Please read the \fI\%UDP input\fP configuration page for additional information. .SS ZeroMQ Logging Handler .sp In order to setup the ZMQ handler for \fI\%Logstash\fP, please define on the salt configuration file: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C logstash_zmq_handler: address: tcp://127.0.0.1:2021 .ft P .fi .UNINDENT .UNINDENT .sp On the \fI\%Logstash\fP configuration file you need something like: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C input { zeromq { type => "zeromq\-type" mode => "server" topology => "pubsub" address => "tcp://0.0.0.0:2021" charset => "UTF\-8" format => "json_event" } } .ft P .fi .UNINDENT .UNINDENT .sp Please read the \fI\%ZeroMQ input\fP configuration page for additional information. .INDENT 0.0 .INDENT 3.5 .IP "Important Logstash Setting" .sp One of the most important settings that you should not forget on your \fI\%Logstash\fP configuration file regarding these logging handlers is \fBformat\fP\&. Both the \fIUDP\fP and \fIZeroMQ\fP inputs need to have \fBformat\fP as \fBjson_event\fP which is what we send over the wire. .UNINDENT .UNINDENT .SS Log Level .sp Both the \fBlogstash_udp_handler\fP and the \fBlogstash_zmq_handler\fP configuration sections accept an additional setting \fBlog_level\fP\&. If not set, the logging level used will be the one defined for \fBlog_level\fP in the global configuration file section. .SS HWM .sp The \fI\%high water mark\fP for the ZMQ socket setting. Only applicable for the \fBlogstash_zmq_handler\fP\&. .INDENT 0.0 .INDENT 3.5 .IP "Inspiration" .sp This work was inspired in \fI\%pylogstash\fP, \fI\%python\-logstash\fP, \fI\%canary\fP and the \fI\%PyZMQ logging handler\fP\&. .UNINDENT .UNINDENT .SH SENTRY LOGGING HANDLER .sp New in version 0.17.0. .sp Configuring the python \fI\%Sentry\fP client, \fI\%Raven\fP, should be done under the \fBsentry_handler\fP configuration key. At the bare minimum, you need to define the \fI\%DSN\fP\&. As an example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sentry_handler: dsn: https://pub\-key:secret\-key@app.getsentry.com/app\-id .ft P .fi .UNINDENT .UNINDENT .sp More complex configurations can be achieved, for example: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sentry_handler: servers: \- https://sentry.example.com \- http://192.168.1.1 project: app\-id public_key: deadbeefdeadbeefdeadbeefdeadbeef secret_key: beefdeadbeefdeadbeefdeadbeefdead .ft P .fi .UNINDENT .UNINDENT .sp All the client configuration keys are supported, please see the \fI\%Raven client documentation\fP\&. .sp The default logging level for the sentry handler is \fBERROR\fP\&. If you wish to define a different one, define \fBlog_level\fP under the \fBsentry_handler\fP configuration key: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C sentry_handler: dsn: https://pub\-key:secret\-key@app.getsentry.com/app\-id log_level: warning .ft P .fi .UNINDENT .UNINDENT .sp The available log levels are those also available for the salt \fBcli\fP tools and configuration; \fBsalt \-\-help\fP should give you the required information. .SS Threaded Transports .sp Raven\(aqs documents rightly suggest using its threaded transport for critical applications. However, don\(aqt forget that if you start having troubles with Salt after enabling the threaded transport, please try switching to a non\-threaded transport to see if that fixes your problem. .SH INTRODUCTION TO EXTENDING SALT .sp 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 without assuming what those problems might be. .sp 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. .SS Client API .sp 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. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fIclient\-apis\fP .UNINDENT .UNINDENT .SS Adding Loadable Plugins .sp 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. .sp The breaking points and helping interfaces span from convenience master side executions to manipulating the flow of how data is handled by Salt. .SS Minion Execution Modules .sp The minion execution modules or just \fBmodules\fP are the core to what Salt is and does. These modules are found in: .sp \fI\%https://github.com/saltstack/salt/blob/develop/salt/modules\fP .sp 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 \fImodules\fP directory and restarting the minion. .SS Grains .sp 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. .sp The Salt grains are the interface used for auto detection and dynamic assignment of execution modules and types to specific Salt minions. .sp The code used to generate the Salt grains can be found here: .sp \fI\%https://github.com/saltstack/salt/blob/develop/salt/grains\fP .SS States .sp Salt supports state enforcement, this makes Salt a high speed and very efficient solution for system configuration management. .sp States can be easily added to Salt by dropping a new state module in: .sp \fI\%https://github.com/saltstack/salt/blob/develop/salt/states\fP .SS Renderers .sp 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. .sp The existing renderers can be found here: .sp \fI\%https://github.com/saltstack/salt/blob/develop/salt/renderers\fP .SS Returners .sp 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. .sp The existing returners can be found here: .sp \fI\%https://github.com/saltstack/salt/blob/develop/salt/returners\fP .SS Runners .sp 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. .sp Existing Salt runners are located here: .sp \fI\%https://github.com/saltstack/salt/blob/develop/salt/runners\fP .SH MODULES .sp Salt modules are the functions called by the \fBsalt\fP command. .sp \fBSEE ALSO:\fP .INDENT 0.0 .INDENT 3.5 \fIFull list of builtin modules\fP .sp Salt ships with many modules that cover a wide variety of tasks. .UNINDENT .UNINDENT .SS Modules Are Easy to Write! .sp Salt modules are amazingly simple to write. Just write a regular Python module or a regular \fI\%Cython\fP module and place it a directory called \fB_modules/\fP within the \fBfile_roots\fP specified by the master config file, and they will be synced to the minions when \fBstate.highstate\fP is run, or by executing the \fBsaltutil.sync_modules\fP or \fBsaltutil.sync_all\fP functions. .sp Any custom modules which have been synced to a minion, that are named the same as one of Salt\(aqs default set of modules, will take the place of the default module with the same name. Note that a module\(aqs default name is its filename (i.e. \fBfoo.py\fP becomes module \fBfoo\fP), but that its name can be overridden by using a \fI__virtual__ function\fP\&. .sp 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. .sp If adding a Cython module the file must be named \fB.pyx\fP 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 \fB*.pyx\fP file is required. .SS Cross Calling Modules .sp 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. .sp The variable \fB__salt__\fP is packed into the modules after they are loaded into the Salt minion. This variable is a \fI\%Python dictionary\fP of all of the Salt functions, laid out in the same way that they are made available to the Salt command. .sp Salt modules can be cross called by accessing the value in the \fB__salt__\fP dict: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def foo(bar): return __salt__[\(aqcmd.run\(aq](bar) .ft P .fi .UNINDENT .UNINDENT .sp This code will call the Salt cmd module\(aqs \fBrun\fP function and pass the argument \fBbar\fP\&. .SS Preloaded Modules Data .sp 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. .SS Grains Data .sp 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 .sp The values detected by the Salt Grains on the minion are available in a \fI\%dict\fP named \fB__grains__\fP and can be accessed from within callable objects in the Python modules. .sp To see the contents of the grains dict for a given system in your deployment run the \fBgrains.items()\fP function: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aqhostname\(aq grains.items .ft P .fi .UNINDENT .UNINDENT .sp To use the \fB__grains__\fP dict simply call it as a Python dict from within your code, an excellent example is available in the Grains module: \fBsalt.modules.grains\fP\&. .SS Module Configuration .sp 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. .sp 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 \fBstrongly\fP recommended that the values passed in the configuration file match the module. This means that a value intended for the \fBtest\fP module should be named \fBtest.\fP\&. .sp Configuration also requires that default configuration parameters need to be loaded as well. This can be done simply by adding the \fB__opts__\fP dict to the top level of the module. .sp 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. \fBsalt.modules.test\fP, \fBconf/minion\fP\&. .SS Printout Configuration .sp Since module functions can return different data, and the way the data is printed can greatly change the presentation, Salt has a printout configuration. .sp When writing a module the \fB__outputter__\fP dict can be declared in the module. The \fB__outputter__\fP dict contains a mapping of function name to Salt Outputter. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C __outputter__ = { \(aqrun\(aq: \(aqtxt\(aq } .ft P .fi .UNINDENT .UNINDENT .sp This will ensure that the text outputter is used. .SS Virtual Modules .sp 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. .sp The Salt modules for package managers all contain a \fB__virtual__\fP function which is called to define what systems the module should be loaded on. .sp The \fB__virtual__\fP function is used to return either a \fI\%string\fP or \fI\%False\fP\&. 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. .sp This means that the package manager modules can be presented as the \fBpkg\fP module regardless of what the actual module is named. .sp The package manager modules are the best example of using the \fB__virtual__\fP function: \fI\%https://github.com/saltstack/salt/blob/develop/salt/modules/pacman.py\fP \fI\%https://github.com/saltstack/salt/blob/develop/salt/modules/yumpkg.py\fP \fI\%https://github.com/saltstack/salt/blob/develop/salt/modules/apt.py\fP .SS Documentation .sp Salt modules are self documenting, the \fBsys.doc()\fP function will return the documentation for all available modules: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sys.doc .ft P .fi .UNINDENT .UNINDENT .sp This function simply prints out the docstrings found in the modules; when writing Salt modules, please follow the formatting conventions for docstrings as they appear in the other modules. .SS Adding Documentation to Salt Modules .sp 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. .sp Documenting Salt modules is easy! Just add a \fI\%Python docstring\fP to the function. .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def spam(eggs): \(aq\(aq\(aq A function to make some spam with eggs! CLI Example:: salt \(aq*\(aq test.spam eggs \(aq\(aq\(aq return eggs .ft P .fi .UNINDENT .UNINDENT .sp Now when the sys.doc call is executed the docstring will be cleanly returned to the calling terminal. .SS Add Module metadata .sp Add information about the module using the following field lists: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C :maintainer: Thomas Hatch :maturity: new :depends: python\-mysqldb :platform: all .ft P .fi .UNINDENT .UNINDENT .sp The maintainer field is a comma\-delimited list of developers who help maintain this module. .sp The maturity field indicates the level of quality and testing for this module. Standard labels will be determined. .sp The depends field is a comma\-delimited list of modules that this module depends on. .sp The platform field is a comma\-delimited list of platforms that this module is known to run on. .SS How Functions are Read .sp 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 \fB_\fP\&. .SS Objects Loaded Into the Salt Minion .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def foo(bar): return bar class baz: def __init__(self, quo): pass .ft P .fi .UNINDENT .UNINDENT .SS Objects NOT Loaded into the Salt Minion .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def _foobar(baz): # Preceded with an _ return baz cheese = {} # Not a callable Python object .ft P .fi .UNINDENT .UNINDENT .SS Useful Decorators for Modules .sp Sometimes when writing modules for large scale deployments you run into some small things that end up severely complicating the code. To alleviate some of this pain Salt has some useful decorators for use within modules! .SS Depends Decorator .sp When writing custom modules there are many times where some of the module will work on all hosts, but some functions require (for example) a service to be installed. Instead of trying to wrap much of the code in large try/except blocks you can use a simple decorator to do this. If the dependencies passed to the decorator don\(aqt exist, then the salt minion will remove those functions from the module on that host. If a "fallback_function" is defined, it will replace the function instead of removing it .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C from salt.utils.decorators import depends try: import dependency_that_sometimes_exists except ImportError: pass @depends(\(aqdependency_that_sometimes_exists\(aq) def foo(): \(aq\(aq\(aq Function with a dependency on the "dependency_that_sometimes_exists" module, if the "dependency_that_sometimes_exists" is missing this function will not exist \(aq\(aq\(aq return True def _fallback(): \(aq\(aq\(aq Fallback function for the depends decorator to replace a function with \(aq\(aq\(aq return \(aq"dependency_that_sometimes_exists" needs to be installed for this function to exist\(aq @depends(\(aqdependency_that_sometimes_exists\(aq, fallback_function=_fallback) def foo(): \(aq\(aq\(aq Function with a dependency on the "dependency_that_sometimes_exists" module. If the "dependency_that_sometimes_exists" is missing this function will be replaced with "_fallback" \(aq\(aq\(aq return True .ft P .fi .UNINDENT .UNINDENT .SS Examples of Salt Modules .sp The existing Salt modules should be fairly easy to read and understand, the goal of the main distribution\(aqs Salt modules is not only to build a set of functions for Salt, but to stand as examples for building out more Salt modules. .sp The existing modules can be found here: \fI\%https://github.com/saltstack/salt/blob/develop/salt/modules\fP .sp The most simple module is the test module, it contains the simplest Salt function, \fBtest.ping\fP: .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C def ping(): \(aq\(aq\(aq Just used to make sure the minion is up and responding Return True CLI Example:: salt \(aq*\(aq test.ping \(aq\(aq\(aq return True .ft P .fi .UNINDENT .UNINDENT .SH FULL LIST OF BUILTIN EXECUTION MODULES .INDENT 0.0 .INDENT 3.5 .IP "Virtual modules" .SS salt.modules.pkg .sp \fBpkg\fP is a virtual module that is fulfilled by one of the following modules: .INDENT 0.0 .IP \(bu 2 \fBsalt.modules.apt\fP .IP \(bu 2 \fBsalt.modules.ebuild\fP .IP \(bu 2 \fBsalt.modules.freebsdpkg\fP .IP \(bu 2 \fBsalt.modules.pacman\fP .IP \(bu 2 \fBsalt.modules.yumpkg\fP .IP \(bu 2 \fBsalt.modules.yumpkg5\fP .IP \(bu 2 \fBsalt.modules.zypper\fP .IP \(bu 2 \fBsalt.modules.brew\fP .IP \(bu 2 \fBsalt.modules.win_pkg\fP .UNINDENT .SS salt.modules.sys .sp 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. .sp 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: .INDENT 0.0 .TP .B salt.modules.sys.doc([module[, module.function]]) Display the inline documentation for all available modules, or for the specified module or function. .UNINDENT .INDENT 0.0 .TP .B 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. .UNINDENT .INDENT 0.0 .TP .B salt.modules.sys.list_modules() List all available (loaded) modules. .UNINDENT .INDENT 0.0 .TP .B salt.modules.sys.list_functions() List all known functions that are in available (loaded) modules. .UNINDENT .UNINDENT .UNINDENT .TS center; |l|l|. _ T{ \fBaliases\fP T} T{ Manage the information in the aliases file T} _ T{ \fBalternatives\fP T} T{ Support for Alternatives system T} _ T{ \fBapache\fP T} T{ Support for Apache T} _ T{ \fBapt\fP T} T{ Support for APT (Advanced Packaging Tool) T} _ T{ \fBarchive\fP T} T{ A module to wrap archive calls T} _ T{ \fBat\fP T} T{ Wrapper module for at(1) T} _ T{ \fBaugeas_cfg\fP T} T{ Manages configuration files via augeas T} _ T{ \fBbluez\fP T} T{ Support for Bluetooth (using BlueZ in Linux). T} _ T{ \fBbrew\fP T} T{ Homebrew for Mac OS X T} _ T{ \fBbridge\fP T} T{ Module for gathering and managing bridging information T} _ T{ \fBbsd_shadow\fP T} T{ Manage the password database on BSD systems T} _ T{ \fBcassandra\fP T} T{ Cassandra NoSQL Database Module T} _ T{ \fBcmdmod\fP T} T{ A module for shelling out T} _ T{ \fBconfig\fP T} T{ Return config information T} _ T{ \fBcp\fP T} T{ Minion side functions for salt\-cp T} _ T{ \fBcron\fP T} T{ Work with cron T} _ T{ \fBdaemontools\fP T} T{ daemontools service module. This module will create daemontools type T} _ T{ \fBdarwin_sysctl\fP T} T{ Module for viewing and modifying sysctl parameters T} _ T{ \fBdata\fP T} T{ Manage a local persistent data structure that can hold any arbitrary data T} _ T{ \fBddns\fP T} T{ Support for RFC 2136 dynamic DNS updates. T} _ T{ \fBdebconfmod\fP T} T{ Support for Debconf T} _ T{ \fBdebian_service\fP T} T{ Service support for Debian systems (uses update\-rc.d and /sbin/service) T} _ T{ \fBdig\fP T} T{ Compendium of generic DNS utilities T} _ T{ \fBdisk\fP T} T{ Module for gathering disk information T} _ T{ \fBdjangomod\fP T} T{ Manage Django sites T} _ T{ \fBdnsmasq\fP T} T{ Module for managing dnqmasq T} _ T{ \fBdnsutil\fP T} T{ Compendium of generic DNS utilities T} _ T{ \fBdpkg\fP T} T{ Support for DEB packages T} _ T{ \fBebuild\fP T} T{ Support for Portage T} _ T{ \fBeix\fP T} T{ Support for Eix T} _ T{ \fBeselect\fP T} T{ Support for eselect, Gentoo\(aqs configuration and management tool. T} _ T{ \fBevent\fP T} T{ Use the \fBSalt Event System\fP to fire events from the T} _ T{ \fBextfs\fP T} T{ Module for managing ext2/3/4 file systems T} _ T{ \fBfile\fP T} T{ Manage information about regular files, directories, T} _ T{ \fBfreebsd_sysctl\fP T} T{ Module for viewing and modifying sysctl parameters T} _ T{ \fBfreebsdjail\fP T} T{ The jail module for FreeBSD T} _ T{ \fBfreebsdkmod\fP T} T{ Module to manage FreeBSD kernel modules T} _ T{ \fBfreebsdpkg\fP T} T{ Package support for FreeBSD T} _ T{ \fBfreebsdservice\fP T} T{ The service module for FreeBSD T} _ T{ \fBgem\fP T} T{ Manage ruby gems. T} _ T{ \fBgentoo_service\fP T} T{ Top level package command wrapper, used to translate the os detected by grains to the correct service manager T} _ T{ \fBgentoolkitmod\fP T} T{ Support for Gentoolkit T} _ T{ \fBgit\fP T} T{ Support for the Git SCM T} _ T{ \fBglance\fP T} T{ Module for handling openstack glance calls. T} _ T{ \fBgrains\fP T} T{ Return/control aspects of the grains data T} _ T{ \fBgroupadd\fP T} T{ Manage groups on Linux and OpenBSD T} _ T{ \fBgrub_legacy\fP T} T{ Support for GRUB Legacy T} _ T{ \fBguestfs\fP T} T{ Interact with virtual machine images via libguestfs T} _ T{ \fBhg\fP T} T{ Support for the Mercurial SCM T} _ T{ \fBhosts\fP T} T{ Manage the information in the hosts file T} _ T{ \fBimg\fP T} T{ Virtual machine image management tools T} _ T{ \fBiptables\fP T} T{ Support for iptables T} _ T{ \fBkey\fP T} T{ Functions to view the minion\(aqs public key information T} _ T{ \fBkeyboard\fP T} T{ Module for managing keyboards on POSIX\-like systems. T} _ T{ \fBkeystone\fP T} T{ Module for handling openstack keystone calls. T} _ T{ \fBkmod\fP T} T{ Module to manage Linux kernel modules T} _ T{ \fBlaunchctl\fP T} T{ Module for the management of MacOS systems that use launchd/launchctl T} _ T{ \fBlayman\fP T} T{ Support for Layman T} _ T{ \fBldapmod\fP T} T{ Salt interface to LDAP commands T} _ T{ \fBlinux_acl\fP T} T{ Support for Linux File Access Control Lists T} _ T{ \fBlinux_lvm\fP T} T{ Support for Linux LVM2 T} _ T{ \fBlinux_sysctl\fP T} T{ Module for viewing and modifying sysctl parameters T} _ T{ \fBlocalemod\fP T} T{ Module for managing locales on POSIX\-like systems. T} _ T{ \fBlocate\fP T} T{ Module for using the locate utilities T} _ T{ \fBlogrotate\fP T} T{ Module for managing logrotate. T} _ T{ \fBlxc\fP T} T{ Work with linux containers T} _ T{ \fBmakeconf\fP T} T{ Support for modifying make.conf under Gentoo T} _ T{ \fBmatch\fP T} T{ The match module allows for match routines to be run and determine target specs T} _ T{ \fBmdadm\fP T} T{ Salt module to manage RAID arrays with mdadm T} _ T{ \fBmine\fP T} T{ The function cache system allows for data to be stored on the master so it can be easily read by other minions T} _ T{ \fBmodjk\fP T} T{ Control Modjk via the Apache Tomcat "Status" worker T} _ T{ \fBmongodb\fP T} T{ Module to provide MongoDB functionality to Salt T} _ T{ \fBmonit\fP T} T{ Monit service module. T} _ T{ \fBmoosefs\fP T} T{ Module for gathering and managing information about MooseFS T} _ T{ \fBmount\fP T} T{ Salt module to manage unix mounts and the fstab file T} _ T{ \fBmunin\fP T} T{ Run munin plugins/checks from salt and format the output as data. T} _ T{ \fBmysql\fP T} T{ Module to provide MySQL compatibility to salt. T} _ T{ \fBnetbsd_sysctl\fP T} T{ Module for viewing and modifying sysctl parameters T} _ T{ \fBnetbsdservice\fP T} T{ The service module for NetBSD T} _ T{ \fBnetwork\fP T} T{ Module for gathering and managing network information T} _ T{ \fBnfs3\fP T} T{ Module for managing NFS version 3. T} _ T{ \fBnginx\fP T} T{ Support for nginx T} _ T{ \fBnova\fP T} T{ Module for handling openstack nova calls. T} _ T{ \fBnpm\fP T} T{ Manage and query NPM packages. T} _ T{ \fBnzbget\fP T} T{ Support for nzbget T} _ T{ \fBopenbsdpkg\fP T} T{ Package support for OpenBSD T} _ T{ \fBopenbsdservice\fP T} T{ The service module for OpenBSD T} _ T{ \fBosxdesktop\fP T} T{ Mac OS X implementations of various commands in the "desktop" interface T} _ T{ \fBpacman\fP T} T{ A module to wrap pacman calls, since Arch is the best T} _ T{ \fBpam\fP T} T{ Support for pam T} _ T{ \fBparted\fP T} T{ Module for managing partitions on POSIX\-like systems. T} _ T{ \fBpecl\fP T} T{ Manage PHP pecl extensions. T} _ T{ \fBpillar\fP T} T{ Extract the pillar data for this minion T} _ T{ \fBpip\fP T} T{ Install Python packages with pip to either the system or a virtualenv T} _ T{ \fBpkg_resource\fP T} T{ Resources needed by pkg providers T} _ T{ \fBpkgin\fP T} T{ Package support for pkgin based systems, inspired from freebsdpkg module T} _ T{ \fBpkgng\fP T} T{ Support for pkgng T} _ T{ \fBpkgutil\fP T} T{ Pkgutil support for Solaris T} _ T{ \fBportage_config\fP T} T{ Configure \fBportage(5)\fP T} _ T{ \fBpostgres\fP T} T{ Module to provide Postgres compatibility to salt. T} _ T{ \fBpoudriere\fP T} T{ Support for poudriere T} _ T{ \fBps\fP T} T{ A salt interface to psutil, a system and process library. T} _ T{ \fBpublish\fP T} T{ Publish a command from a minion to a target T} _ T{ \fBpuppet\fP T} T{ Execute puppet routines T} _ T{ \fBpw_group\fP T} T{ Manage groups on FreeBSD T} _ T{ \fBpw_user\fP T} T{ Manage users with the useradd command T} _ T{ \fBqemu_img\fP T} T{ Qemu\-img Command Wrapper T} _ T{ \fBqemu_nbd\fP T} T{ Qemu Command Wrapper T} _ T{ \fBquota\fP T} T{ Module for managing quotas on POSIX\-like systems. T} _ T{ \fBrabbitmq\fP T} T{ Module to provide RabbitMQ compatibility to Salt. T} _ T{ \fBrbenv\fP T} T{ Manage ruby installations with rbenv. T} _ T{ \fBreg\fP T} T{ Manage the registry on Windows T} _ T{ \fBret\fP T} T{ Module to integrate with the returner system and retrieve data sent to a salt returner T} _ T{ \fBrh_ip\fP T} T{ The networking module for RHEL/Fedora based distros T} _ T{ \fBrh_service\fP T} T{ Service support for RHEL\-based systems, including support for both upstart and sysvinit T} _ T{ \fBrpm\fP T} T{ Support for rpm T} _ T{ \fBrvm\fP T} T{ Manage ruby installations and gemsets with RVM, the Ruby Version Manager. T} _ T{ \fBs3\fP T} T{ Connection module for Amazon S3 T} _ T{ \fBsaltutil\fP T} T{ 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. T} _ T{ \fBseed\fP T} T{ Virtual machine image management tools T} _ T{ \fBselinux\fP T} T{ Execute calls on selinux .. T} _ T{ \fBservice\fP T} T{ The default service module, if not otherwise specified salt will fall back T} _ T{ \fBshadow\fP T} T{ Manage the shadow file T} _ T{ \fBsmartos_imgadm\fP T} T{ Module for running imgadm command on SmartOS T} _ T{ \fBsmartos_vmadm\fP T} T{ Module for managing VMs on SmartOS T} _ T{ \fBsmf\fP T} T{ Service support for Solaris 10 and 11, should work with other systems T} _ T{ \fBsolaris_group\fP T} T{ Manage groups on Solaris T} _ T{ \fBsolaris_shadow\fP T} T{ Manage the password database on Solaris systems T} _ T{ \fBsolaris_user\fP T} T{ Manage users with the useradd command T} _ T{ \fBsolarispkg\fP T} T{ Package support for Solaris T} _ T{ \fBsolr\fP T} T{ Apache Solr Salt Module T} _ T{ \fBsqlite3\fP T} T{ Support for SQLite3 T} _ T{ \fBssh\fP T} T{ Manage client ssh components T} _ T{ \fBstate\fP T} T{ Control the state system on the minion T} _ T{ \fBstatus\fP T} T{ Module for returning various status data about a minion. T} _ T{ \fBsupervisord\fP T} T{ Provide the service module for system supervisord or supervisord in a virtualenv T} _ T{ \fBsvn\fP T} T{ Subversion SCM T} _ T{ \fBsysbench\fP T} T{ The \(aqsysbench\(aq module is used to analyse the T} _ T{ \fBsysmod\fP T} T{ The sys module provides information about the available functions on the minion T} _ T{ \fBsystem\fP T} T{ Support for reboot, shutdown, etc T} _ T{ \fBsystemd\fP T} T{ Provide the service module for systemd T} _ T{ \fBtest\fP T} T{ Module for running arbitrary tests T} _ T{ \fBtimezone\fP T} T{ Module for managing timezone on POSIX\-like systems. T} _ T{ \fBtls\fP T} T{ A salt module for SSL/TLS. T} _ T{ \fBtomcat\fP T} T{ Support for Tomcat T} _ T{ \fBupstart\fP T} T{ Module for the management of upstart systems. T} _ T{ \fBuseradd\fP T} T{ Manage users with the useradd command T} _ T{ \fBvirt\fP T} T{ Work with virtual machines managed by libvirt T} _ T{ \fBvirtualenv_mod\fP T} T{ Create virtualenv environments T} _ T{ \fBwin_disk\fP T} T{ Module for gathering disk information on Windows T} _ T{ \fBwin_file\fP T} T{ Manage information about files on the minion, set/read user, group T} _ T{ \fBwin_groupadd\fP T} T{ Manage groups on Windows T} _ T{ \fBwin_network\fP T} T{ Module for gathering and managing network information T} _ T{ \fBwin_pkg\fP T} T{ A module to manage software on Windows T} _ T{ \fBwin_service\fP T} T{ Windows Service module. T} _ T{ \fBwin_shadow\fP T} T{ Manage the shadow file T} _ T{ \fBwin_status\fP T} T{ Module for returning various status data about a minion. T} _ T{ \fBwin_system\fP T} T{ Support for reboot, shutdown, etc T} _ T{ \fBwin_useradd\fP T} T{ Manage Windows users with the net user command T} _ T{ \fBxapi\fP T} T{ This module (mostly) uses the XenAPI to manage Xen virtual machines. T} _ T{ \fByumpkg\fP T} T{ Support for YUM T} _ T{ \fByumpkg5\fP T} T{ Support for YUM T} _ T{ \fBzfs\fP T} T{ Module for running ZFS command T} _ T{ \fBzpool\fP T} T{ Module for running ZFS zpool command T} _ T{ \fBzypper\fP T} T{ Package support for openSUSE via the zypper package manager T} _ .TE .SS salt.modules.aliases .sp Manage the information in the aliases file .INDENT 0.0 .TP .B salt.modules.aliases.get_target(alias) Return the target associated with an alias .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq aliases.get_target alias .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.aliases.has_target(alias, target) Return true if the alias/target is set .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq aliases.has_target alias target .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.aliases.list_aliases() Return the aliases found in the aliases file in this format: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aqalias\(aq: \(aqtarget\(aq} .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq aliases.list_aliases .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.aliases.rm_alias(alias) Remove an entry from the aliases file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq aliases.rm_alias alias .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B 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. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq aliases.set_target alias target .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.alternatives .sp Support for Alternatives system .INDENT 0.0 .TP .B codeauthor Radek Rada <\fI\%radek.rada@gmail.com\fP> .TP .B copyright © 2012 by the SaltStack Team, see AUTHORS for more details. .TP .B license Apache 2.0, see LICENSE for more details. .UNINDENT .INDENT 0.0 .TP .B salt.modules.alternatives.auto(name) Trigger alternatives to set the path for as specified by priority. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq alternatives.auto name .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.alternatives.check_installed(name, path) Check if the current highest\-priority match for a given alternatives link is set to the desired path .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq alternatives.check_installed name path .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.alternatives.display(name) Display alternatives settings for defined command name .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq alternatives.display editor .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.alternatives.install(name, link, path, priority) Install symbolic links determining default commands .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq alternatives.install editor /usr/bin/editor /usr/bin/emacs23 50 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.alternatives.remove(name, path) Remove symbolic links determining the default commands. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq alternatives.remove name path .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.alternatives.set_(name, path) Manually set the alternative for . .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq alternatives.set name path .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.alternatives.show_current(name) Display the current highest\-priority alternative for a given alternatives link .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq alternatives.show_current editor .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.apache .sp Support for Apache .INDENT 0.0 .TP .B salt.modules.apache.a2dissite(site) Runs a2dissite for the given site. .sp This will only be functional on Debian\-based operating systems (Ubuntu, Mint, etc). .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.a2dissite example.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.a2ensite(site) Runs a2ensite for the given site. .sp This will only be functional on Debian\-based operating systems (Ubuntu, Mint, etc). .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.a2ensite example.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.check_site_enabled(site) Checks to see if the specific Site symlink is in /etc/apache2/sites\-enabled. .sp This will only be functional on Debian\-based operating systems (Ubuntu, Mint, etc). .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.check_site_enabled example.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.directives() Return list of directives together with expected arguments and places where the directive is valid (\fBapachectl \-L\fP) .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.directives .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.fullversion() Return server version from apachectl \-V .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.fullversion .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.modules() Return list of static and shared modules from apachectl \-M .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.modules .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.server_status(profile=\(aqdefault\(aq) Get Information from the Apache server\-status handler .sp NOTE: the server\-status handler is disabled by default. in order for this function to work it needs to be enabled. \fI\%http://httpd.apache.org/docs/2.2/mod/mod_status.html\fP .sp The following configuration needs to exists in pillar/grains each entry nested in apache.server\-status is a profile of a vhost/server this would give support for multiple apache servers/vhosts .INDENT 7.0 .TP .B apache.server\-status: .INDENT 7.0 .TP .B \(aqdefault\(aq: \(aqurl\(aq: \fI\%http://localhost/server\-status\fP \(aquser\(aq: someuser \(aqpass\(aq: password \(aqrealm\(aq: \(aqauthentication realm for digest passwords\(aq \(aqtimeout\(aq: 5 .UNINDENT .UNINDENT .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.server_status salt \(aq*\(aq apache.server_status other\-profile .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.servermods() Return list of modules compiled into the server (apachectl \-l) .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.servermods .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.signal(signal=None) Signals httpd to start, restart, or stop. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.signal restart .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.useradd(pwfile, user, password, opts=\(aq\(aq) Add an HTTP user using the htpasswd command. If the htpasswd file does not exist, it will be created. Valid options that can be passed are: .INDENT 7.0 .INDENT 3.5 n Don\(aqt update file; display results on stdout. m Force MD5 encryption of the password (default). d Force CRYPT encryption of the password. p Do not encrypt the password (plaintext). s Force SHA encryption of the password. .UNINDENT .UNINDENT .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.useradd /etc/httpd/htpasswd larry badpassword salt \(aq*\(aq apache.useradd /etc/httpd/htpasswd larry badpass opts=ns .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.userdel(pwfile, user) Delete an HTTP user from the specified htpasswd file. .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.userdel /etc/httpd/htpasswd larry .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.version() Return server version from apachectl \-v .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq apache.version .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apache.vhosts() Show the settings as parsed from the config file (currently only shows the virtualhost settings). (\fBapachectl \-S\fP) Because each additional virtual host adds to the execution time, this command may require a long timeout be specified. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \-t 10 \(aq*\(aq apache.vhosts .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.apt .sp Support for APT (Advanced Packaging Tool) .INDENT 0.0 .TP .B salt.modules.apt.del_repo(repo, **kwargs) Delete a repo from the sources.list / sources.list.d .sp If the .list file is in the sources.list.d directory and the file that the repo exists in does not contain any other repo configuration, the file itself will be deleted. .sp The repo passed in must be a fully formed repository definition string. .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.del_repo "myrepo definition" .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.expand_repo_def(repokwargs) Take a repository definition and expand it to the full pkg repository dict that can be used for comparison. This is a helper function to make the Debian/Ubuntu apt sources sane for comparison in the pkgrepo states. .sp There is no use to calling this function via the CLI. .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.file_dict(*packages) List the files that belong to a package, grouped by package. Not specifying any packages will return a list of _every_ file on the system\(aqs package database (not generally recommended). .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.file_list httpd salt \(aq*\(aq pkg.file_list httpd postfix salt \(aq*\(aq pkg.file_list .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.file_list(*packages) List the files that belong to a package. Not specifying any packages will return a list of _every_ file on the system\(aqs package database (not generally recommended). .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.file_list httpd salt \(aq*\(aq pkg.file_list httpd postfix salt \(aq*\(aq pkg.file_list .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.get_repo(repo, **kwargs) Display a repo from the sources.list / sources.list.d .sp The repo passwd in needs to be a complete repo entry. .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.get_repo "myrepo definition" .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.get_selections(pattern=None, state=None) View package state from the dpkg database. .sp Returns a dict of dicts containing the state, and package names: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: {\(aq\(aq: [\(aqpkg1\(aq, ... ] }, ... } .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.get_selections salt \(aq*\(aq pkg.get_selections \(aqpython\-*\(aq salt \(aq*\(aq pkg.get_selections state=hold salt \(aq*\(aq pkg.get_selections \(aqopenssh*\(aq state=hold .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.install(name=None, refresh=False, fromrepo=None, skip_verify=False, debconf=None, pkgs=None, sources=None, **kwargs) Install the passed package, add refresh=True to update the dpkg database. .INDENT 7.0 .TP .B name The name of the package to be installed. Note that this parameter is ignored if either "pkgs" or "sources" is passed. Additionally, please note that this option can only be used to install packages from a software repository. To install a package file manually, use the "sources" option. .sp 32\-bit packages can be installed on 64\-bit systems by appending the architecture designation (\fB:i386\fP, etc.) to the end of the package name. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install .ft P .fi .UNINDENT .UNINDENT .TP .B refresh Whether or not to refresh the package database before installing. .TP .B fromrepo Specify a package repository to install from (e.g., \fBapt\-get \-t unstable install somepackage\fP) .TP .B skip_verify Skip the GPG verification check (e.g., \fB\-\-allow\-unauthenticated\fP, or \fB\-\-force\-bad\-verify\fP for install from package file). .TP .B debconf Provide the path to a debconf answers file, processed before installation. .TP .B version Install a specific version of the package, e.g. 1.2.3~0ubuntu0. Ignored if "pkgs" or "sources" is passed. .UNINDENT .sp Multiple Package Installation Options: .INDENT 7.0 .TP .B pkgs A list of packages to install from a software repository. Must be passed as a python list. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install pkgs=\(aq["foo", "bar"]\(aq salt \(aq*\(aq pkg.install pkgs=\(aq["foo", {"bar": "1.2.3\-0ubuntu0"}]\(aq .ft P .fi .UNINDENT .UNINDENT .TP .B sources A list of DEB packages to install. Must be passed as a list of dicts, with the keys being package names, and the values being the source URI or local path to the package. .sp 32\-bit packages can be installed on 64\-bit systems by appending the architecture designation (\fB:i386\fP, etc.) to the end of the package name. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install sources=\(aq[{"foo": "salt://foo.deb"},{"bar": "salt://bar.deb"}]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp Returns a dict containing the new package names and versions: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: {\(aqold\(aq: \(aq\(aq, \(aqnew\(aq: \(aq\(aq}} .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.latest_version(*names, **kwargs) Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of name/version pairs is returned. .sp If the latest version of a given package is already installed, an empty string will be returned for that package. .sp A specific repo can be requested using the \fBfromrepo\fP keyword argument. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.latest_version salt \(aq*\(aq pkg.latest_version fromrepo=unstable salt \(aq*\(aq pkg.latest_version ... .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.list_pkgs(versions_as_list=False, removed=False) List the packages currently installed in a dict: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: \(aq\(aq} .ft P .fi .UNINDENT .UNINDENT .sp If removed is \fBTrue\fP, then only packages which have been removed (but not purged) will be returned. .sp External dependencies: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C Virtual package resolution requires dctrl\-tools. Without dctrl\-tools virtual packages will be reported as not installed. .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.list_pkgs salt \(aq*\(aq pkg.list_pkgs versions_as_list=True .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.list_repos() Lists all repos in the sources.list (and sources.lists.d) files .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.list_repos salt \(aq*\(aq pkg.list_repos disabled=True .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.list_upgrades(refresh=True) List all available package upgrades. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.list_upgrades .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.mod_repo(repo, **kwargs) Modify one or more values for a repo. If the repo does not exist, it will be created, so long as the definition is well formed. For Ubuntu the "ppa:/repo" format is acceptable. "ppa:" format can only be used to create a new repository. .sp The following options are available to modify a repo definition: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C comps (a comma separated list of components for the repo, e.g. "main") file (a file name to be used) keyserver (keyserver to get gpg key from) keyid (key id to load with the keyserver argument) key_url (URL to a gpg key to add to the apt gpg keyring) consolidate (if true, will attempt to de\-dup and consolidate sources) * Note: Due to the way keys are stored for apt, there is a known issue where the key wont be updated unless another change is made at the same time. Keys should be properly added on initial configuration. .ft P .fi .UNINDENT .UNINDENT .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.mod_repo \(aqmyrepo definition\(aq uri=http://new/uri salt \(aq*\(aq pkg.mod_repo \(aqmyrepo definition\(aq comps=main,universe .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.purge(name=None, pkgs=None, **kwargs) Remove packages via \fBapt\-get purge\fP along with all configuration files and unused dependencies. .INDENT 7.0 .TP .B name The name of the package to be deleted. .UNINDENT .sp Multiple Package Options: .INDENT 7.0 .TP .B pkgs A list of packages to delete. Must be passed as a python list. The \fBname\fP parameter will be ignored if this option is passed. .UNINDENT .sp New in version 0.16.0. .sp Returns a dict containing the changes. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.purge salt \(aq*\(aq pkg.purge ,, salt \(aq*\(aq pkg.purge pkgs=\(aq["foo", "bar"]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.refresh_db() Updates the APT database to latest packages based upon repositories .sp Returns a dict, with the keys being package databases and the values being the result of the update attempt. Values can be one of the following: .INDENT 7.0 .IP \(bu 2 \fBTrue\fP: Database updated successfully .IP \(bu 2 \fBFalse\fP: Problem updating database .IP \(bu 2 \fBNone\fP: Database already up\-to\-date .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.refresh_db .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.remove(name=None, pkgs=None, **kwargs) Remove packages using \fBapt\-get remove\fP\&. .INDENT 7.0 .TP .B name The name of the package to be deleted. .UNINDENT .sp Multiple Package Options: .INDENT 7.0 .TP .B pkgs A list of packages to delete. Must be passed as a python list. The \fBname\fP parameter will be ignored if this option is passed. .UNINDENT .sp New in version 0.16.0. .sp Returns a dict containing the changes. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.remove salt \(aq*\(aq pkg.remove ,, salt \(aq*\(aq pkg.remove pkgs=\(aq["foo", "bar"]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.set_selections(path=None, selection=None, clear=False) Change package state in the dpkg database. .sp The state can be any one of, documented in \fBdpkg(1)\fP: .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 install .IP \(bu 2 hold .IP \(bu 2 deinstall .IP \(bu 2 purge .UNINDENT .UNINDENT .UNINDENT .sp This command is commonly used to mark specific packages to be held from being upgraded, that is, to be kept at a certain version. When a state is changed to anything but being held, then it is typically followed by \fBapt\-get \-u dselect\-upgrade\fP\&. .sp Note: Be careful with the \fBclear\fP argument, since it will start with setting all packages to deinstall state. .sp Returns a dict of dicts containing the package names, and the new and old versions: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: {\(aq\(aq: {\(aqnew\(aq: \(aq\(aq, \(aqold\(aq: \(aq\(aq} }, ... } .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.set_selections selection=\(aq{"install": ["netcat"]}\(aq salt \(aq*\(aq pkg.set_selections selection=\(aq{"hold": ["openssh\-server", "openssh\-client"]}\(aq salt \(aq*\(aq pkg.set_selections salt://path/to/file salt \(aq*\(aq pkg.set_selections salt://path/to/file clear=True .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.upgrade(refresh=True, **kwargs) Upgrades all packages via \fBapt\-get dist\-upgrade\fP .sp Returns a dict containing the changes. .INDENT 7.0 .INDENT 3.5 .INDENT 0.0 .TP .B {\(aq\(aq: {\(aqold\(aq: \(aq\(aq, \(aqnew\(aq: \(aq\(aq}} .UNINDENT .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.upgrade .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.upgrade_available(name) Check whether or not an upgrade is available for a given package .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.upgrade_available .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.version(*names, **kwargs) Returns a string representing the package version or an empty string if not installed. If more than one package name is specified, a dict of name/version pairs is returned. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.version salt \(aq*\(aq pkg.version ... .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.apt.version_cmp(pkg1, pkg2) Do a cmp\-style comparison on two packages. Return \-1 if pkg1 < pkg2, 0 if pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem making the comparison. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.version_cmp \(aq0.2.4\-0ubuntu1\(aq \(aq0.2.4.1\-0ubuntu1\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.archive .sp A module to wrap archive calls .INDENT 0.0 .TP .B salt.modules.archive.gunzip(gzipfile, template=None) Uses the gunzip command to unpack gzip files .sp CLI Example to create \fB/tmp/sourcefile.txt\fP: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.gunzip /tmp/sourcefile.txt.gz .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.gunzip template=jinja /tmp/{{grains.id}}.txt.gz .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.archive.gzip(sourcefile, template=None) Uses the gzip command to create gzip files .sp CLI Example to create \fB/tmp/sourcefile.txt.gz\fP: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.gzip /tmp/sourcefile.txt .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.gzip template=jinja /tmp/{{grains.id}}.txt .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.archive.rar(rarfile, sources, template=None) Uses the rar command to create rar files Uses rar for Linux from \fI\%http://www.rarlab.com/\fP .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.rar /tmp/rarfile.rar /tmp/sourcefile1,/tmp/sourcefile2 .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. .sp For example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.rar template=jinja /tmp/rarfile.rar /tmp/sourcefile1,/tmp/{{grains.id}}.txt .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.archive.tar(options, tarfile, sources, cwd=None, template=None) .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 This function has changed for version 0.17.0. In prior versions, the \fBcwd\fP and \fBtemplate\fP arguments must be specified, with the source directories/files coming as a space\-separated list at the end of the command. Beginning with 0.17.0, \fBsources\fP must be a comma\-separated list, and the \fBcwd\fP and \fBtemplate\fP arguments are optional. .UNINDENT .UNINDENT .sp Uses the tar command to pack, unpack, etc tar files .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.tar cjvf /tmp/tarfile.tar.bz2 /tmp/file_1,/tmp/file_2 .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \fBjinja\fP or another supported template engine to render the command arguments before execution. For example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.tar template=jinja cjvf /tmp/salt.tar.bz2 {{grains.saltpath}} .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.archive.unrar(rarfile, dest, excludes=None, template=None) Uses the unrar command to unpack rar files Uses rar for Linux from \fI\%http://www.rarlab.com/\fP .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.unrar /tmp/rarfile.rar /home/strongbad/ excludes=file_1,file_2 .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. .sp For example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.unrar template=jinja /tmp/rarfile.rar /tmp/{{grains.id}}/ excludes=file_1,file_2 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.archive.unzip(zipfile, dest, excludes=None, template=None) Uses the unzip command to unpack zip files .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.unzip /tmp/zipfile.zip /home/strongbad/ excludes=file_1,file_2 .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. .sp For example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.unzip template=jinja /tmp/zipfile.zip /tmp/{{grains.id}}/ excludes=file_1,file_2 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.archive.zip_(zipfile, sources, template=None) Uses the zip command to create zip files .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.zip /tmp/zipfile.zip /tmp/sourcefile1,/tmp/sourcefile2 .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. .sp For example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq archive.zip template=jinja /tmp/zipfile.zip /tmp/sourcefile1,/tmp/{{grains.id}}.txt .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.at .sp Wrapper module for at(1) .sp Also, a \(aqtag\(aq feature has been added to more easily tag jobs. .INDENT 0.0 .TP .B salt.modules.at.at(*args, **kwargs) Add a job to the queue. .sp The \(aqtimespec\(aq follows the format documented in the at(1) manpage. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq at.at [tag=] [runas=] salt \(aq*\(aq at.at 12:05am \(aq/sbin/reboot\(aq tag=reboot salt \(aq*\(aq at.at \(aq3:05am +3 days\(aq \(aqbin/myscript\(aq tag=nightly runas=jim .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.at.atc(jobid) Print the at(1) script that will run for the passed job id. This is mostly for debugging so the output will just be text. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq at.atc .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.at.atq(tag=None) List all queued and running jobs or only those with an optional \(aqtag\(aq. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq at.atq salt \(aq*\(aq at.atq [tag] salt \(aq*\(aq at.atq [job number] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.at.atrm(*args) Remove jobs from the queue. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq at.atrm .. salt \(aq*\(aq at.atrm all salt \(aq*\(aq at.atrm all [tag] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.augeas_cfg .sp Manages configuration files via augeas .sp \fBNOTE:\fP This state requires the \fBaugeas\fP Python module. .INDENT 0.0 .TP .B salt.modules.augeas_cfg.get(path, value=\(aq\(aq) Get a value for a specific augeas path .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq augeas.get /files/etc/hosts/1/ ipaddr .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.augeas_cfg.ls(path) List the direct children of a node .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq augeas.ls /files/etc/passwd .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.augeas_cfg.match(path, value=\(aq\(aq) Get matches for path expression .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq augeas.match /files/etc/services/service\-name ssh .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.augeas_cfg.remove(path) Get matches for path expression .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq augeas.remove /files/etc/sysctl.conf/net.ipv4.conf.all.log_martians .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.augeas_cfg.setvalue(*args) Set a value for a specific augeas path .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq augeas.setvalue /files/etc/hosts/1/canonical localhost .ft P .fi .UNINDENT .UNINDENT .sp This will set the first entry in /etc/hosts to localhost .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq augeas.setvalue /files/etc/hosts/01/ipaddr 192.168.1.1 \e /files/etc/hosts/01/canonical test .ft P .fi .UNINDENT .UNINDENT .sp Adds a new host to /etc/hosts the ip address 192.168.1.1 and hostname test .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq augeas.setvalue prefix=/files/etc/sudoers/ \e "spec[user = \(aq%wheel\(aq]/user" "%wheel" \e "spec[user = \(aq%wheel\(aq]/host_group/host" \(aqALL\(aq \e "spec[user = \(aq%wheel\(aq]/host_group/command[1]" \(aqALL\(aq \e "spec[user = \(aq%wheel\(aq]/host_group/command[1]/tag" \(aqPASSWD\(aq \e "spec[user = \(aq%wheel\(aq]/host_group/command[2]" \(aq/usr/bin/apt\-get\(aq \e "spec[user = \(aq%wheel\(aq]/host_group/command[2]/tag" NOPASSWD .ft P .fi .UNINDENT .UNINDENT .sp Ensures that the following line is present in /etc/sudoers: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C %wheel ALL = PASSWD : ALL , NOPASSWD : /usr/bin/apt\-get , /usr/bin/aptitude .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.augeas_cfg.tree(path) Returns recursively the complete tree of a node .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq augeas.tree /files/etc/ .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.bluez .sp Support for Bluetooth (using BlueZ in Linux). .sp The following packages are required packages for this module: .INDENT 0.0 .INDENT 3.5 bluez >= 5.7 bluez\-libs >= 5.7 bluez\-utils >= 5.7 pybluez >= 0.18 .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.address_() Get the many addresses of the Bluetooth adapter .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.address .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.block(bdaddr) Block a specific bluetooth device by BD Address .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.block DE:AD:BE:EF:CA:FE .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.discoverable(dev) Enable this bluetooth device to be discovrable. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.discoverable hci0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.noscan(dev) Turn off scanning modes on this device. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.noscan hci0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.pair(address, key) Pair the bluetooth adapter with a device .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.pair DE:AD:BE:EF:CA:FE 1234 .ft P .fi .UNINDENT .UNINDENT .sp Where DE:AD:BE:EF:CA:FE is the address of the device to pair with, and 1234 is the passphrase. .sp TODO: This function is currently broken, as the bluez\-simple\-agent program no longer ships with BlueZ >= 5.0. It needs to be refactored. .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.power(dev, mode) Power a bluetooth device on or off .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.power hci0 on salt \(aq*\(aq bluetooth.power hci0 off .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.scan() Scan for bluetooth devices in the area .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.scan .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.start() Start the bluetooth service. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.start .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.stop() Stop the bluetooth service. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.stop .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.unblock(bdaddr) Unblock a specific bluetooth device by BD Address .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.unblock DE:AD:BE:EF:CA:FE .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.unpair(address) Unpair the bluetooth adapter from a device .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetooth.unpair DE:AD:BE:EF:CA:FE .ft P .fi .UNINDENT .UNINDENT .sp Where DE:AD:BE:EF:CA:FE is the address of the device to unpair. .sp TODO: This function is currently broken, as the bluez\-simple\-agent program no longer ships with BlueZ >= 5.0. It needs to be refactored. .UNINDENT .INDENT 0.0 .TP .B salt.modules.bluez.version() Return Bluez version from bluetoothd \-v .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bluetoothd.version .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.brew .sp Homebrew for Mac OS X .INDENT 0.0 .TP .B salt.modules.brew.install(name=None, pkgs=None, taps=None, options=None, **kwargs) Install the passed package(s) with \fBbrew install\fP .INDENT 7.0 .TP .B name The name of the formula to be installed. Note that this parameter is ignored if "pkgs" is passed. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install .ft P .fi .UNINDENT .UNINDENT .TP .B taps Unofficial Github repos to use when updating and installing formulas. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install tap=\(aq\(aq salt \(aq*\(aq pkg.install zlib taps=\(aqhomebrew/dupes\(aq salt \(aq*\(aq pkg.install php54 taps=\(aq["josegonzalez/php", "homebrew/dupes"]\(aq .ft P .fi .UNINDENT .UNINDENT .TP .B options Options to pass to brew. Only applies to inital install. Due to how brew works, modifying chosen options requires a full uninstall followed by a fresh install. Note that if "pkgs" is used, all options will be passed to all packages. Unreconized options for a package will be silently ignored by brew. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install tap=\(aq\(aq salt \(aq*\(aq pkg.install php54 taps=\(aq["josegonzalez/php", "homebrew/dupes"]\(aq options=\(aq["\-\-with\-fpm"]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp Multiple Package Installation Options: .INDENT 7.0 .TP .B pkgs A list of formulas to install. Must be passed as a python list. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install pkgs=\(aq["foo","bar"]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp Returns a dict containing the new package names and versions: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: {\(aqold\(aq: \(aq\(aq, \(aqnew\(aq: \(aq\(aq}} .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install \(aqpackage package package\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.brew.latest_version(*names, **kwargs) Return the latest version of the named package available for upgrade or installation .sp Note that this currently not fully implemented but needs to return something to avoid a traceback when calling pkg.latest. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.latest_version salt \(aq*\(aq pkg.latest_version .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.brew.list_pkgs(versions_as_list=False, **kwargs) List the packages currently installed in a dict: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: \(aq\(aq} .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.list_pkgs .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.brew.list_upgrades() Check whether or not an upgrade is available for all packages .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.list_upgrades .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.brew.remove(name=None, pkgs=None, **kwargs) Removes packages with \fBbrew uninstall\fP\&. .INDENT 7.0 .TP .B name The name of the package to be deleted. .UNINDENT .sp Multiple Package Options: .INDENT 7.0 .TP .B pkgs A list of packages to delete. Must be passed as a python list. The \fBname\fP parameter will be ignored if this option is passed. .UNINDENT .sp New in version 0.16.0. .sp Returns a dict containing the changes. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.remove salt \(aq*\(aq pkg.remove ,, salt \(aq*\(aq pkg.remove pkgs=\(aq["foo", "bar"]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.brew.upgrade_available(pkg) Check whether or not an upgrade is available for a given package .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.upgrade_available .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.brew.version(*names, **kwargs) Returns a string representing the package version or an empty string if not installed. If more than one package name is specified, a dict of name/version pairs is returned. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.version salt \(aq*\(aq pkg.version .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.bridge .sp Module for gathering and managing bridging information .INDENT 0.0 .TP .B salt.modules.bridge.add(br=None) Creates a bridge .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bridge.add br0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bridge.addif(br=None, iface=None) Adds an interface to a bridge .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bridge.addif br0 eth0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bridge.delete(br=None) Deletes a bridge .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bridge.delete br0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bridge.delif(br=None, iface=None) Removes an interface from a bridge .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bridge.delif br0 eth0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bridge.find_interfaces(*args) Returns the bridge to which the interfaces are bond to .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bridge.find_interfaces eth0 [eth1...] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bridge.interfaces(br=None) Returns interfaces attached to a bridge .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bridge.interfaces br0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bridge.list_() Returns the machine\(aqs bridges list .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bridge.list .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bridge.show(br=None) Returns bridges interfaces along with enslaved physical interfaces. If no interface is given, all bridges are shown, else only the specified bridge values are returned. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bridge.show salt \(aq*\(aq bridge.show br0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bridge.stp(br=None, state=\(aqdisable\(aq, iface=None) Sets Spanning Tree Protocol state for a bridge .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bridge.stp br0 enable salt \(aq*\(aq bridge.stp br0 disable .ft P .fi .UNINDENT .UNINDENT .sp For the NetBSD operating system, it is required to add the interface on which to enable the STP. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq bridge.stp bridge0 enable fxp0 salt \(aq*\(aq bridge.stp bridge0 disable fxp0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.bsd_shadow .sp Manage the password database on BSD systems .INDENT 0.0 .TP .B salt.modules.bsd_shadow.default_hash() Returns the default hash used for unset passwords .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq shadow.default_hash .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bsd_shadow.info(name) Return information for the specified user .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq shadow.info someuser .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.bsd_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: .sp \fBpython \-c "import crypt; print crypt.crypt(\(aqpassword\(aq, ciphersalt)"\fP .sp \fBNOTE:\fP When constructing the \fBciphersalt\fP string, you must escape any dollar signs, to avoid them being interpolated by the shell. .sp \fB\(aqpassword\(aq\fP is, of course, the password for which you want to generate a hash. .sp \fBciphersalt\fP is a combination of a cipher identifier, an optional number of rounds, and the cryptographic salt. The arrangement and format of these fields depends on the cipher and which flavor of BSD you are using. For more information on this, see the manpage for \fBcrpyt(3)\fP\&. On NetBSD, additional information is available in \fBpasswd.conf(5)\fP\&. .sp It is important to make sure that a supported cipher is used. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq shadow.set_password someuser \(aq$1$UYCIxa628.9qXjpQCjM4a..\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.cassandra .sp Cassandra NoSQL Database Module .INDENT 0.0 .TP .B depends .INDENT 7.0 .IP \(bu 2 pycassa Cassandra Python adapter .UNINDENT .TP .B configuration The location of the \(aqnodetool\(aq command, host, and thrift port needs to be specified via pillar: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C cassandra.nodetool: /usr/local/bin/nodetool cassandra.host: localhost cassandra.thrift_port: 9160 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cassandra.column_families(keyspace=None) Return existing column families for all keyspaces or just the provided one. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cassandra.column_families salt \(aq*\(aq cassandra.column_families .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cassandra.column_family_definition(keyspace=None, column_family=None) Return a dictionary of column family definitions for the given keyspace/column_family .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cassandra.column_family_definition .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cassandra.compactionstats() Return compactionstats info .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cassandra.compactionstats .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cassandra.info() Return cassandra node info .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cassandra.info .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cassandra.keyspaces() Return existing keyspaces .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cassandra.keyspaces .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cassandra.netstats() Return netstats info .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cassandra.netstats .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cassandra.ring() Return cassandra ring info .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cassandra.ring .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cassandra.tpstats() Return tpstats info .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cassandra.tpstats .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cassandra.version() Return the cassandra version .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cassandra.version .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.cmdmod .sp A module for shelling out .sp 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 .INDENT 0.0 .TP .B 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 .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.exec_code ruby \(aqputs "cheese"\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cmdmod.has_exec(cmd) Returns true if the executable is available on the minion, false otherwise .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.has_exec cat .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cmdmod.retcode(cmd, cwd=None, stdin=None, runas=None, shell=\(aq/usr/bin/zsh\(aq, env=(), clean_env=False, template=None, umask=None, quiet=False, timeout=None, reset_system_locale=True) Execute a shell command and return the command\(aqs return code. .sp Note that \fBenv\fP represents the environment variables for the command, and should be formatted as a dict, or a YAML string which resolves to a dict. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.retcode "file /bin/bash" .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. For example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.retcode template=jinja "file {{grains.pythonpath[0]}}/python" .ft P .fi .UNINDENT .UNINDENT .sp A string of standard input can be specified for the command to be run using the \fBstdin\fP parameter. This can be useful in cases where sensitive information must be read from standard input.: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.retcode "grep f" stdin=\(aqone\entwo\enthree\enfour\enfive\en\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cmdmod.run(cmd, cwd=None, stdin=None, runas=None, shell=\(aq/usr/bin/zsh\(aq, env=(), clean_env=False, template=None, rstrip=True, umask=None, quiet=False, timeout=None, reset_system_locale=True, **kwargs) Execute the passed command and return the output as a string .sp Note that \fBenv\fP represents the environment variables for the command, and should be formatted as a dict, or a YAML string which resolves to a dict. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run "ls \-l | awk \(aq/foo/{print \e$2}\(aq" .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. For example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run template=jinja "ls \-l /tmp/{{grains.id}} | awk \(aq/foo/{print \e$2}\(aq" .ft P .fi .UNINDENT .UNINDENT .sp Specify an alternate shell with the shell parameter: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run "Get\-ChildItem C:\e " shell=\(aqpowershell\(aq .ft P .fi .UNINDENT .UNINDENT .sp A string of standard input can be specified for the command to be run using the \fBstdin\fP parameter. This can be useful in cases where sensitive information must be read from standard input.: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run "grep f" stdin=\(aqone\entwo\enthree\enfour\enfive\en\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cmdmod.run_all(cmd, cwd=None, stdin=None, runas=None, shell=\(aq/usr/bin/zsh\(aq, env=(), clean_env=False, template=None, rstrip=True, umask=None, quiet=False, timeout=None, reset_system_locale=True, **kwargs) Execute the passed command and return a dict of return data .sp Note that \fBenv\fP represents the environment variables for the command, and should be formatted as a dict, or a YAML string which resolves to a dict. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run_all "ls \-l | awk \(aq/foo/{print \e$2}\(aq" .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. For example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run_all template=jinja "ls \-l /tmp/{{grains.id}} | awk \(aq/foo/{print \e$2}\(aq" .ft P .fi .UNINDENT .UNINDENT .sp A string of standard input can be specified for the command to be run using the \fBstdin\fP parameter. This can be useful in cases where sensitive information must be read from standard input.: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run_all "grep f" stdin=\(aqone\entwo\enthree\enfour\enfive\en\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cmdmod.run_stderr(cmd, cwd=None, stdin=None, runas=None, shell=\(aq/usr/bin/zsh\(aq, env=(), clean_env=False, template=None, rstrip=True, umask=None, quiet=False, timeout=None, reset_system_locale=True, **kwargs) Execute a command and only return the standard error .sp Note that \fBenv\fP represents the environment variables for the command, and should be formatted as a dict, or a YAML string which resolves to a dict. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run_stderr "ls \-l | awk \(aq/foo/{print \e$2}\(aq" .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. For example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run_stderr template=jinja "ls \-l /tmp/{{grains.id}} | awk \(aq/foo/{print \e$2}\(aq" .ft P .fi .UNINDENT .UNINDENT .sp A string of standard input can be specified for the command to be run using the \fBstdin\fP parameter. This can be useful in cases where sensitive information must be read from standard input.: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run_stderr "grep f" stdin=\(aqone\entwo\enthree\enfour\enfive\en\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cmdmod.run_stdout(cmd, cwd=None, stdin=None, runas=None, shell=\(aq/usr/bin/zsh\(aq, env=(), clean_env=False, template=None, rstrip=True, umask=None, quiet=False, timeout=None, reset_system_locale=True, **kwargs) Execute a command, and only return the standard out .sp Note that \fBenv\fP represents the environment variables for the command, and should be formatted as a dict, or a YAML string which resolves to a dict. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run_stdout "ls \-l | awk \(aq/foo/{print \e$2}\(aq" .ft P .fi .UNINDENT .UNINDENT .sp The template arg can be set to \(aqjinja\(aq or another supported template engine to render the command arguments before execution. For example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run_stdout template=jinja "ls \-l /tmp/{{grains.id}} | awk \(aq/foo/{print \e$2}\(aq" .ft P .fi .UNINDENT .UNINDENT .sp A string of standard input can be specified for the command to be run using the \fBstdin\fP parameter. This can be useful in cases where sensitive information must be read from standard input.: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.run_stdout "grep f" stdin=\(aqone\entwo\enthree\enfour\enfive\en\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cmdmod.script(source, args=None, cwd=None, stdin=None, runas=None, shell=\(aq/usr/bin/zsh\(aq, env=(), template=\(aqjinja\(aq, umask=None, timeout=None, reset_system_locale=True, __env__=\(aqbase\(aq, **kwargs) Download a script from a remote location and execute the script locally. The script can be located on the salt master file server or on an HTTP/FTP server. .sp The script will be executed directly, so it can be written in any available programming language. .sp The script can also be formated as a template, the default is jinja. Arguments for the script can be specified as well. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.script salt://scripts/runme.sh salt \(aq*\(aq cmd.script salt://scripts/runme.sh \(aqarg1 arg2 "arg 3"\(aq salt \(aq*\(aq cmd.script salt://scripts/windows_task.ps1 args=\(aq \-Input c:\etmp\einfile.txt\(aq shell=\(aqpowershell\(aq .ft P .fi .UNINDENT .UNINDENT .sp A string of standard input can be specified for the command to be run using the \fBstdin\fP parameter. This can be useful in cases where sensitive information must be read from standard input.: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.script salt://scripts/runme.sh stdin=\(aqone\entwo\enthree\enfour\enfive\en\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cmdmod.script_retcode(source, cwd=None, stdin=None, runas=None, shell=\(aq/usr/bin/zsh\(aq, env=(), template=\(aqjinja\(aq, umask=None, timeout=None, reset_system_locale=True, __env__=\(aqbase\(aq, **kwargs) Download a script from a remote location and execute the script locally. The script can be located on the salt master file server or on an HTTP/FTP server. .sp The script will be executed directly, so it can be written in any available programming language. .sp The script can also be formated as a template, the default is jinja. .sp Only evaluate the script return code and do not block for terminal output .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.script_retcode salt://scripts/runme.sh .ft P .fi .UNINDENT .UNINDENT .sp A string of standard input can be specified for the command to be run using the \fBstdin\fP parameter. This can be useful in cases where sensitive information must be read from standard input.: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.script_retcode salt://scripts/runme.sh stdin=\(aqone\entwo\enthree\enfour\enfive\en\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cmdmod.which(cmd) Returns the path of an executable available on the minion, None otherwise .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.which cat .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cmdmod.which_bin(cmds) Returns the first command found in a list of commands .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cmd.which_bin \(aq[pip2, pip, pip\-python]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.config .sp Return config information .INDENT 0.0 .TP .B salt.modules.config.backup_mode(backup=\(aq\(aq) Return the backup mode .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq config.backup_mode .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.config.dot_vals(value) Pass in a configuration value that should be preceded by the module name and a dot, this will return a list of all read key/value pairs .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq config.dot_vals host .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.config.gather_bootstrap_script(replace=False) Download the salt\-bootstrap script, set replace to True to refresh the script if it has already been downloaded .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq config.gather_bootstrap_script True .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.config.get(key, default=\(aq\(aq) Attempt to retrieve the named value from opts, pillar, grains of the master config, if the named value is not available return the passed default. The default return is an empty string. .sp The value can also represent a value in a nested dict using a ":" delimiter for the dict. This means that if a dict looks like this: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aqpkg\(aq: {\(aqapache\(aq: \(aqhttpd\(aq}} .ft P .fi .UNINDENT .UNINDENT .sp To retrieve the value associated with the apache key in the pkg dict this key can be passed: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C pkg:apache .ft P .fi .UNINDENT .UNINDENT .sp This routine traverses these data stores in this order: .INDENT 7.0 .IP \(bu 2 Local minion config (opts) .IP \(bu 2 Minion\(aqs grains .IP \(bu 2 Minion\(aqs pillar .IP \(bu 2 Master config .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq config.get pkg:apache .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.config.manage_mode(mode) Return a mode value, normalized to a string .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq config.manage_mode .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.config.merge(value, default=\(aq\(aq, omit_opts=False, omit_master=False, omit_pillar=False) Retrieves an option based on key, merging all matches. .sp Same as \fBoption()\fP except that it merges all matches, rather than taking the first match. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq config.merge schedule .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.config.option(value, default=\(aq\(aq, omit_opts=False, omit_master=False, omit_pillar=False) Pass in a generic option and receive the value that will be assigned .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq config.option redis.host .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.config.valid_fileproto(uri) Returns a boolean value based on whether or not the URI passed has a valid remote file protocol designation .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq config.valid_fileproto salt://path/to/file .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.cp .sp Minion side functions for salt\-cp .INDENT 0.0 .TP .B salt.modules.cp.cache_dir(path, env=\(aqbase\(aq, include_empty=False) Download and cache everything under a directory from the master .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.cache_dir salt://path/to/dir .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.cache_file(path, env=\(aqbase\(aq) Used to cache a single file in the local salt\-master file cache. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.cache_file salt://path/to/file .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.cache_files(paths, env=\(aqbase\(aq) 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. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.cache_files salt://pathto/file1,salt://pathto/file1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.cache_local_file(path) Cache a local file on the minion in the localfiles cache .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.cache_local_file /etc/hosts .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.cache_master(env=\(aqbase\(aq) Retrieve all of the files on the master and cache them locally .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.cache_master .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.get_dir(path, dest, env=\(aqbase\(aq, template=None, gzip=None) Used to recursively copy a directory from the salt master .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.get_dir salt://path/to/dir/ /minion/dest .ft P .fi .UNINDENT .UNINDENT .sp get_dir supports the same template and gzip arguments as get_file. .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.get_file(path, dest, env=\(aqbase\(aq, makedirs=False, template=None, gzip=None) Used to get a single file from the salt master .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.get_file salt://path/to/file /minion/dest .ft P .fi .UNINDENT .UNINDENT .sp Template rendering can be enabled on both the source and destination file names like so: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.get_file "salt://{{grains.os}}/vimrc" /etc/vimrc template=jinja .ft P .fi .UNINDENT .UNINDENT .sp This example would instruct all Salt minions to download the vimrc from a directory with the same name as their os grain and copy it to /etc/vimrc .sp For larger files, the cp.get_file module also supports gzip compression. Because gzip is CPU\-intensive, this should only be used in scenarios where the compression ratio is very high (e.g. pretty\-printed JSON or YAML files). .sp Use the \fIgzip\fP named argument to enable it. Valid values are 1..9, where 1 is the lightest compression and 9 the heaviest. 1 uses the least CPU on the master (and minion), 9 uses the most. .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.get_file_str(path, env=\(aqbase\(aq) Return the contents of a file from a URL .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.get_file_str salt://my/file .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.get_template(path, dest, template=\(aqjinja\(aq, env=\(aqbase\(aq, **kwargs) Render a file as a template before setting it down .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.get_template salt://path/to/template /minion/dest .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.get_url(path, dest, env=\(aqbase\(aq) Used to get a single file from a URL. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.get_url salt://my/file /tmp/mine salt \(aq*\(aq cp.get_url http://www.slashdot.org /tmp/index.html .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.hash_file(path, env=\(aqbase\(aq) Return the hash of a file, to get the hash of a file on the salt master file server prepend the path with salt:// otherwise, prepend the file with / for a local file. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.hash_file salt://path/to/file .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.is_cached(path, env=\(aqbase\(aq) Return a boolean if the given path on the master has been cached on the minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.is_cached salt://path/to/file .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.list_master(env=\(aqbase\(aq, prefix=\(aq\(aq) List all of the files stored on the master .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.list_master .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.list_master_dirs(env=\(aqbase\(aq, prefix=\(aq\(aq) List all of the directories stored on the master .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.list_master_dirs .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.list_minion(env=\(aqbase\(aq) List all of the files cached on the minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.list_minion .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.list_states(env=\(aqbase\(aq) List all of the available state modules in an environment .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.list_states .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.push(path) Push a file from the minion up to the master, the file will be saved to the salt master in the master\(aqs minion files cachedir (defaults to \fB/var/cache/salt/master/minions/minion\-id/files\fP) .sp Since this feature allows a minion to push a file up to the master server it is disabled by default for security purposes. To enable, set \fBfile_recv\fP to \fBTrue\fP in the master configuration file, and restart the master. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cp.push /etc/fstab .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cp.recv(files, dest) Used with salt\-cp, pass the files dict, and the destination. .sp This function receives small fast copy files from the master via salt\-cp. It does not work via the CLI. .UNINDENT .SS salt.modules.cron .sp Work with cron .INDENT 0.0 .TP .B salt.modules.cron.list_tab(user) Return the contents of the specified user\(aqs crontab .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.list_tab root .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cron.ls(user) Return the contents of the specified user\(aqs crontab .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.list_tab root .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cron.raw_cron(user) Return the contents of the user\(aqs crontab .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.raw_cron root .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cron.rm(user, cmd, minute=None, hour=None, daymonth=None, month=None, dayweek=None) Remove a cron job for a specified user. If any of the day/time params are specified, the job will only be removed if the specified params match. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.rm_job root /usr/local/weekly salt \(aq*\(aq cron.rm_job root /usr/bin/foo dayweek=1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cron.rm_env(user, name) Remove cron environment variable for a specified user. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.rm_env root MAILTO .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cron.rm_job(user, cmd, minute=None, hour=None, daymonth=None, month=None, dayweek=None) Remove a cron job for a specified user. If any of the day/time params are specified, the job will only be removed if the specified params match. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.rm_job root /usr/local/weekly salt \(aq*\(aq cron.rm_job root /usr/bin/foo dayweek=1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cron.set_env(user, name, value=None) Set up an environment variable in the crontab. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.set_env root MAILTO user@example.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cron.set_job(user, minute, hour, daymonth, month, dayweek, cmd) Sets a cron job up for a specified user. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.set_job root \(aq*\(aq \(aq*\(aq \(aq*\(aq \(aq*\(aq 1 /usr/local/weekly .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cron.set_special(user, special, cmd) Set up a special command in the crontab. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.set_special @hourly \(aqecho foobar\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cron.write_cron_file(user, path) Writes the contents of a file to a user\(aqs crontab .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.write_cron_file root /tmp/new_cron .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.cron.write_cron_file_verbose(user, path) Writes the contents of a file to a user\(aqs crontab and return error message on error .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq cron.write_cron_file_verbose root /tmp/new_cron .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.daemontools .sp daemontools service module. This module will create daemontools type service watcher. This module is states.service compatible so it can be used to maintain service state via provider interface: .INDENT 0.0 .INDENT 3.5 .INDENT 0.0 .IP \(bu 2 provider: daemontools .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.daemontools.full_restart(name) Calls daemontools.restart() function .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq daemontools.full_restart .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.daemontools.get_all() Return a list of all available services .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq daemontools.get_all .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.daemontools.reload_(name) Wrapper for term() .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq daemontools.reload .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.daemontools.restart(name) Restart service via daemontools. This will stop/start service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq daemontools.restart .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.daemontools.start(name) Starts service via daemontools .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq daemontools.start .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.daemontools.status(name, sig=None) Return the status for a service via daemontools, return pid if running .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq daemontools.status .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.daemontools.stop(name) Stops service via daemontools .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq daemontools.stop .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.daemontools.term(name) Send a TERM to service via daemontools .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq daemontools.term .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.darwin_sysctl .sp Module for viewing and modifying sysctl parameters .INDENT 0.0 .TP .B salt.modules.darwin_sysctl.assign(name, value) Assign a single sysctl parameter for this minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sysctl.assign net.inet.icmp.icmplim 50 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.darwin_sysctl.get(name) Return a single sysctl parameter for this minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sysctl.get hw.physmem .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.darwin_sysctl.persist(name, value, config=\(aq/etc/sysctl.conf\(aq) Assign and persist a simple sysctl parameter for this minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sysctl.persist net.inet.icmp.icmplim 50 salt \(aq*\(aq sysctl.persist coretemp_load NO config=/etc/sysctl.conf .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.darwin_sysctl.show() Return a list of sysctl parameters for this minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sysctl.show .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.data .sp Manage a local persistent data structure that can hold any arbitrary data specific to the minion .INDENT 0.0 .TP .B salt.modules.data.cas(key, value, old_value) Check and set a value in the minion datastore .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq data.cas .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.data.clear() Clear out all of the data in the minion datastore, this function is destructive! .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq data.clear .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.data.dump(new_data) Replace the entire datastore with a passed data structure .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq data.dump \(aq{\(aqeggs\(aq: \(aqspam\(aq}\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.data.getval(key) Get a value from the minion datastore .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq data.getval .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.data.getvals(*keys) Get values from the minion datastore .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq data.getvals [ ...] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.data.load() Return all of the data in the minion datastore .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq data.load .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.data.update(key, value) Update a key with a value in the minion datastore .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq data.update .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.ddns .sp Support for RFC 2136 dynamic DNS updates. Requires dnspython module. .INDENT 0.0 .TP .B salt.modules.ddns.add_host(zone, name, ttl, ip, nameserver=\(aq127.0.0.1\(aq, replace=True) Add, replace, or update the A and PTR (reverse) records for a host. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 ddns.add_host example.com host1 60 10.1.1.1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ddns.delete(zone, name, rdtype=None, data=None, nameserver=\(aq127.0.0.1\(aq) Delete a DNS record. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 ddns.delete example.com host1 A .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ddns.delete_host(zone, name, nameserver=\(aq127.0.0.1\(aq) Delete the forward and reverse records for a host. .sp Returns true if any records are deleted. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 ddns.delete_host example.com host1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ddns.update(zone, name, ttl, rdtype, data, nameserver=\(aq127.0.0.1\(aq, replace=False) Add, replace, or update a DNS record. nameserver must be an IP address and the minion running this module must have update privileges on that server. If replace is true, first deletes all records for this name and type. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 ddns.update example.com host1 60 A 10.0.0.1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.debconfmod .sp Support for Debconf .INDENT 0.0 .TP .B salt.modules.debconfmod.get_selections(fetchempty=True) Answers to debconf questions for all packages in the following format: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aqpackage\(aq: [[\(aqquestion\(aq, \(aqtype\(aq, \(aqvalue\(aq], ...]} .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq debconf.get_selections .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debconfmod.set_(package, question, type, value, *extra) Set answers to debconf questions for a package. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq debconf.set [ ...] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debconfmod.set_file(path, **kwargs) Set answers to debconf questions from a file. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq debconf.set_file salt://pathto/pkg.selections .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debconfmod.show(name) Answers to debconf questions for a package in the following format: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C [[\(aqquestion\(aq, \(aqtype\(aq, \(aqvalue\(aq], ...] .ft P .fi .UNINDENT .UNINDENT .sp If debconf doesn\(aqt know about a package, we return None. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq debconf.show .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.debian_service .sp Service support for Debian systems (uses update\-rc.d and /sbin/service) .INDENT 0.0 .TP .B salt.modules.debian_service.disable(name, **kwargs) Disable the named service to start at boot .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.disable .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.disabled(name) Return True if the named service is enabled, false otherwise .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.disabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.enable(name, **kwargs) Enable the named service to start at boot .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.enable .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.enabled(name) Return True if the named service is enabled, false otherwise .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.enabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.force_reload(name) Force\-reload the named service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.force_reload .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.get_all() Return all available boot services .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.get_all .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.get_disabled() Return a set of services that are installed but disabled .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.get_disabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.get_enabled() Return a list of service that are enabled on boot .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.get_enabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.reload_(name) Reload the named service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.reload .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.restart(name) Restart the named service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.restart .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.start(name) Start the specified service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.start .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.status(name, sig=None) Return the status for a service, pass a signature to use to find the service via ps .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.status .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.debian_service.stop(name) Stop the specified service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.stop .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.dig .sp Compendium of generic DNS utilities .INDENT 0.0 .TP .B salt.modules.dig.A(host, nameserver=None) Return the A record for \fBhost\fP\&. .sp Always returns a list. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dig.A www.google.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dig.MX(domain, resolve=False, nameserver=None) Return a list of lists for the MX of \fBdomain\fP\&. .sp If the \fBresolve\fP argument is True, resolve IPs for the servers. .sp It\(aqs limited to one IP, because although in practice it\(aqs very rarely a round robin, it is an acceptable configuration and pulling just one IP lets the data be similar to the non\-resolved version. If you think an MX has multiple IPs, don\(aqt use the resolver here, resolve them in a separate step. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dig.MX google.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dig.NS(domain, resolve=True, nameserver=None) Return a list of IPs of the nameservers for \fBdomain\fP .sp If \fBresolve\fP is False, don\(aqt resolve names. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dig.NS google.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dig.SPF(domain, record=\(aqSPF\(aq, nameserver=None) Return the allowed IPv4 ranges in the SPF record for \fBdomain\fP\&. .sp If record is \fBSPF\fP and the SPF record is empty, the TXT record will be searched automatically. If you know the domain uses TXT and not SPF, specifying that will save a lookup. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dig.SPF google.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dig.check_ip(x) Check that string x is a valid IP .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dig.check_ip 127.0.0.1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.disk .sp Module for gathering disk information .INDENT 0.0 .TP .B salt.modules.disk.inodeusage(args=None) Return inode usage information for volumes mounted on this minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq disk.inodeusage .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.disk.usage(args=None) Return usage information for volumes mounted on this minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq disk.usage .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.djangomod .sp Manage Django sites .INDENT 0.0 .TP .B salt.modules.djangomod.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, env=None) Collect static files from each of your applications into a single location that can easily be served in production. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq django.collectstatic .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.djangomod.command(settings_module, command, bin_env=None, pythonpath=None, env=None, *args, **kwargs) Run arbitrary django management command .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq django.command .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.djangomod.createsuperuser(settings_module, username, email, bin_env=None, database=None, pythonpath=None, env=None) Create a super user for the database. This function defaults to use the \fB\-\-noinput\fP flag which prevents the creation of a password for the superuser. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq django.createsuperuser user user@example.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.djangomod.loaddata(settings_module, fixtures, bin_env=None, database=None, pythonpath=None, env=None) Load fixture data .INDENT 7.0 .TP .B Fixtures: comma separated list of fixtures to load .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq django.loaddata .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.djangomod.syncdb(settings_module, bin_env=None, migrate=False, database=None, pythonpath=None, env=None, noinput=True) Run syncdb .sp Execute the Django\-Admin syncdb command, if South is available on the minion the \fBmigrate\fP option can be passed as \fBTrue\fP calling the migrations to run after the syncdb completes .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq django.syncdb .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.dnsmasq .sp Module for managing dnqmasq .INDENT 0.0 .TP .B salt.modules.dnsmasq.fullversion() Shows installed version of dnsmasq, and compile options .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq dnsmasq.version .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsmasq.get_config(config_file=\(aq/etc/dnsmasq.conf\(aq) Dumps all options from the config file .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq dnsmasq.get_config salt \(aq*\(aq dnsmasq.get_config file=/etc/dnsmasq.conf .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsmasq.set_config(config_file=\(aq/etc/dnsmasq.conf\(aq, follow=True, **kwargs) Sets a value or a set of values in the specified file. By default, if conf\-dir is configured in this file, salt will attempt to set the option in any file inside the conf\-dir where it has already been enabled. If it does not find it inside any files, it will append it to the main config file. Setting follow to False will turn off this behavior. .sp If a config option currently appears multiple times (such as dhcp\-host, which is specified at least once per host), the new option will be added to the end of the main config file (and not to any includes). If you need an option added to a specific include file, specify it as the config_file. .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq dnsmasq.set_config domain=mydomain.com salt \(aq*\(aq dnsmasq.set_config follow=False domain=mydomain.com salt \(aq*\(aq dnsmasq.set_config file=/etc/dnsmasq.conf domain=mydomain.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsmasq.version() Shows installed version of dnsmasq .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq dnsmasq.version .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.dnsutil .sp Compendium of generic DNS utilities .INDENT 0.0 .TP .B salt.modules.dnsutil.A(host, nameserver=None) Return the A record for \(aqhost\(aq. .sp Always returns a list. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dig.A www.google.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsutil.MX(domain, resolve=False, nameserver=None) Return a list of lists for the MX of \fBdomain\fP\&. .sp If the \(aqresolve\(aq argument is True, resolve IPs for the servers. .sp It\(aqs limited to one IP, because although in practice it\(aqs very rarely a round robin, it is an acceptable configuration and pulling just one IP lets the data be similar to the non\-resolved version. If you think an MX has multiple IPs, don\(aqt use the resolver here, resolve them in a separate step. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dig.MX google.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsutil.NS(domain, resolve=True, nameserver=None) Return a list of IPs of the nameservers for \fBdomain\fP .sp If \(aqresolve\(aq is False, don\(aqt resolve names. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dig.NS google.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsutil.SPF(domain, record=\(aqSPF\(aq, nameserver=None) Return the allowed IPv4 ranges in the SPF record for \fBdomain\fP\&. .sp If record is \fBSPF\fP and the SPF record is empty, the TXT record will be searched automatically. If you know the domain uses TXT and not SPF, specifying that will save a lookup. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dig.SPF google.com .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsutil.check_ip(ip_addr) Check that string ip_addr is a valid IP .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dig.check_ip 127.0.0.1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsutil.hosts_append(hostsfile=\(aq/etc/hosts\(aq, ip_addr=None, entries=None) Append a single line to the /etc/hosts file. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq dnsutil.hosts_append /etc/hosts 127.0.0.1 ad1.yuk.co,ad2.yuk.co .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsutil.hosts_remove(hostsfile=\(aq/etc/hosts\(aq, entries=None) Remove a host from the /etc/hosts file. If doing so will leave a line containing only an IP address, then the line will be deleted. This function will leave comments and blank lines intact. .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq dnsutil.hosts_remove /etc/hosts ad1.yuk.co salt \(aq*\(aq dnsutil.hosts_remove /etc/hosts ad2.yuk.co,ad1.yuk.co .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsutil.parse_hosts(hostsfile=\(aq/etc/hosts\(aq, hosts=None) Parse /etc/hosts file. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq dnsutil.parse_hosts .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dnsutil.parse_zone(zonefile=None, zone=None) Parses a zone file. Can be passed raw zone data on the API level. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt ns1 dnsutil.parse_zone /var/lib/named/example.com.zone .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.dpkg .sp Support for DEB packages .INDENT 0.0 .TP .B salt.modules.dpkg.file_dict(*packages) List the files that belong to a package, grouped by package. Not specifying any packages will return a list of _every_ file on the system\(aqs package database (not generally recommended). .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq lowpkg.file_list httpd salt \(aq*\(aq lowpkg.file_list httpd postfix salt \(aq*\(aq lowpkg.file_list .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dpkg.file_list(*packages) List the files that belong to a package. Not specifying any packages will return a list of _every_ file on the system\(aqs package database (not generally recommended). .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq lowpkg.file_list httpd salt \(aq*\(aq lowpkg.file_list httpd postfix salt \(aq*\(aq lowpkg.file_list .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.dpkg.list_pkgs(*packages) List the packages currently installed in a dict: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: \(aq\(aq} .ft P .fi .UNINDENT .UNINDENT .sp External dependencies: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C Virtual package resolution requires aptitude. Because this function uses dpkg, virtual packages will be reported as not installed. .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq lowpkg.list_pkgs salt \(aq*\(aq lowpkg.list_pkgs httpd .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.ebuild .sp Support for Portage .INDENT 0.0 .TP .B optdepends .INDENT 7.0 .IP \(bu 2 portage Python adapter .UNINDENT .UNINDENT .sp For now all package names \fIMUST\fP include the package category, i.e. \fB\(aqvim\(aq\fP will not work, \fB\(aqapp\-editors/vim\(aq\fP will. .INDENT 0.0 .TP .B salt.modules.ebuild.check_db(*names, **kwargs) New in version 0.17.0. .sp Returns a dict containing the following information for each specified package: .INDENT 7.0 .IP 1. 3 A key \fBfound\fP, which will be a boolean value denoting if a match was found in the package database. .IP 2. 3 If \fBfound\fP is \fBFalse\fP, then a second key called \fBsuggestions\fP will be present, which will contain a list of possible matches. This list will be empty if the package name was specified in \fBcategory/pkgname\fP format, since the suggestions are only intended to disambiguate ambiguous package names (ones submitted without a category). .UNINDENT .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.check_db .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.check_extra_requirements(pkgname, pkgver) Check if the installed package already has the given requirements. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.check_extra_requirements \(aqsys\-devel/gcc\(aq \(aq~>4.1.2:4.1::gentoo[nls,fortran]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.depclean(name=None, slot=None, fromrepo=None, pkgs=None) Portage has a function to remove unused dependencies. If a package is provided, it will only removed the package if no other package depends on it. .INDENT 7.0 .TP .B name The name of the package to be cleaned. .TP .B slot Restrict the remove to a specific slot. Ignored if \fBname\fP is None. .TP .B fromrepo Restrict the remove to a specific slot. Ignored if \fBname\fP is None. .TP .B pkgs Clean multiple packages. \fBslot\fP and \fBfromrepo\fP arguments are ignored if this argument is present. Must be passed as a python list. .UNINDENT .sp Return a list containing the removed packages: .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.depclean .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.ex_mod_init(low) Enforce a nice tree structure for /etc/portage/package.* configuration files. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.ex_mod_init .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.install(name=None, refresh=False, pkgs=None, sources=None, slot=None, fromrepo=None, uses=None, **kwargs) Install the passed package(s), add refresh=True to sync the portage tree before package is installed. .INDENT 7.0 .TP .B name The name of the package to be installed. Note that this parameter is ignored if either "pkgs" or "sources" is passed. Additionally, please note that this option can only be used to emerge a package from the portage tree. To install a tbz2 package manually, use the "sources" option described below. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install .ft P .fi .UNINDENT .UNINDENT .TP .B refresh Whether or not to sync the portage tree before installing. .TP .B version Install a specific version of the package, e.g. 1.0.9\-r1. Ignored if "pkgs" or "sources" is passed. .TP .B slot Similar to version, but specifies a valid slot to be installed. It will install the latest available version in the specified slot. Ignored if "pkgs" or "sources" or "version" is passed. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install sys\-devel/gcc slot=\(aq4.4\(aq .ft P .fi .UNINDENT .UNINDENT .TP .B fromrepo Similar to slot, but specifies the repository from the package will be installed. It will install the latest available version in the specified repository. Ignored if "pkgs" or "sources" or "version" is passed. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install salt fromrepo=\(aqgentoo\(aq .ft P .fi .UNINDENT .UNINDENT .TP .B uses Similar to slot, but specifies a list of use flag. Ignored if "pkgs" or "sources" or "version" is passed. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install sys\-devel/gcc uses=\(aq["nptl","\-nossp"]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp Multiple Package Installation Options: .INDENT 7.0 .TP .B pkgs A list of packages to install from the portage tree. Must be passed as a python list. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install pkgs=\(aq["foo","bar","~category/package:slot::repository[use]"]\(aq .ft P .fi .UNINDENT .UNINDENT .TP .B sources A list of tbz2 packages to install. Must be passed as a list of dicts, with the keys being package names, and the values being the source URI or local path to the package. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install sources=\(aq[{"foo": "salt://foo.tbz2"},{"bar": "salt://bar.tbz2"}]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp Returns a dict containing the new package names and versions: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: {\(aqold\(aq: \(aq\(aq, \(aqnew\(aq: \(aq\(aq}} .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.latest_version(*names, **kwargs) Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of name/version pairs is returned. .sp If the latest version of a given package is already installed, an empty string will be returned for that package. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.latest_version salt \(aq*\(aq pkg.latest_version ... .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.list_pkgs(versions_as_list=False, **kwargs) List the packages currently installed in a dict: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: \(aq\(aq} .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.list_pkgs .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.list_upgrades(refresh=True) List all available package upgrades. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.list_upgrades .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.porttree_matches(name) Returns a list containing the matches for a given package name from the portage tree. Note that the specific version of the package will not be provided for packages that have several versions in the portage tree, but rather the name of the package (i.e. "dev\-python/paramiko"). .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.purge(name=None, slot=None, fromrepo=None, pkgs=None, **kwargs) Portage does not have a purge, this function calls remove followed by depclean to emulate a purge process .INDENT 7.0 .TP .B name The name of the package to be deleted. .TP .B slot Restrict the remove to a specific slot. Ignored if name is None. .TP .B fromrepo Restrict the remove to a specific slot. Ignored if \fBname\fP is None. .UNINDENT .sp Multiple Package Options: .INDENT 7.0 .TP .B pkgs Uninstall multiple packages. \fBslot\fP and \fBfromrepo\fP arguments are ignored if this argument is present. Must be passed as a python list. .UNINDENT .sp New in version 0.16.0. .sp Returns a dict containing the changes. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.purge salt \(aq*\(aq pkg.purge slot=4.4 salt \(aq*\(aq pkg.purge ,, salt \(aq*\(aq pkg.purge pkgs=\(aq["foo", "bar"]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.refresh_db() Updates the portage tree (emerge \-\-sync). Uses eix\-sync if available. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.refresh_db .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.remove(name=None, slot=None, fromrepo=None, pkgs=None, **kwargs) Remove packages via emerge \-\-unmerge. .INDENT 7.0 .TP .B name The name of the package to be deleted. .TP .B slot Restrict the remove to a specific slot. Ignored if \fBname\fP is None. .TP .B fromrepo Restrict the remove to a specific slot. Ignored if \fBname\fP is None. .UNINDENT .sp Multiple Package Options: .INDENT 7.0 .TP .B pkgs Uninstall multiple packages. \fBslot\fP and \fBfromrepo\fP arguments are ignored if this argument is present. Must be passed as a python list. .UNINDENT .sp New in version 0.16.0. .sp Returns a dict containing the changes. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.remove salt \(aq*\(aq pkg.remove slot=4.4 fromrepo=gentoo salt \(aq*\(aq pkg.remove ,, salt \(aq*\(aq pkg.remove pkgs=\(aq["foo", "bar"]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.update(pkg, slot=None, fromrepo=None, refresh=False) Updates the passed package (emerge \-\-update package) .INDENT 7.0 .TP .B slot Restrict the update to a particular slot. It will update to the latest version within the slot. .TP .B fromrepo Restrict the update to a particular repository. It will update to the latest version within the repository. .UNINDENT .sp Return a dict containing the new package names and versions: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: {\(aqold\(aq: \(aq\(aq, \(aqnew\(aq: \(aq\(aq}} .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.update .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.upgrade(refresh=True) Run a full system upgrade (emerge \-\-update world) .sp Return a dict containing the new package names and versions: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: {\(aqold\(aq: \(aq\(aq, \(aqnew\(aq: \(aq\(aq}} .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.upgrade .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.upgrade_available(name) Check whether or not an upgrade is available for a given package .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.upgrade_available .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.version(*names, **kwargs) Returns a string representing the package version or an empty string if not installed. If more than one package name is specified, a dict of name/version pairs is returned. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.version salt \(aq*\(aq pkg.version ... .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.version_clean(version) Clean the version string removing extra data. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.version_clean .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.ebuild.version_cmp(pkg1, pkg2) Do a cmp\-style comparison on two packages. Return \-1 if pkg1 < pkg2, 0 if pkg1 == pkg2, and 1 if pkg1 > pkg2. Return None if there was a problem making the comparison. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.version_cmp \(aq0.2.4\-0\(aq \(aq0.2.4.1\-0\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.eix .sp Support for Eix .INDENT 0.0 .TP .B salt.modules.eix.sync() Sync portage/overlay trees and update the eix database .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq eix.sync .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.eix.update() Update the eix database .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq eix.update .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.eselect .sp Support for eselect, Gentoo\(aqs configuration and management tool. .INDENT 0.0 .TP .B salt.modules.eselect.exec_action(module, action, parameter=\(aq\(aq, state_only=False) Execute an arbitrary action on a module. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq eselect.exec_action [parameter] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.eselect.get_current_target(module) Get the currently selected target for the given module. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq eselect.get_current_target .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.eselect.get_modules() Get available modules list. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq eselect.get_modules .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.eselect.get_target_list(module) Get available target for the given module. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq eselect.get_target_list .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.eselect.set_target(module, target) Set the target for the given module. Target can be specified by index or name. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq eselect.set_target .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.event .sp Use the \fBSalt Event System\fP to fire events from the master to the minion and vice\-versa. .INDENT 0.0 .TP .B salt.modules.event.fire(data, tag) Fire an event on the local minion event bus .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq event.fire \(aqstuff to be in the event\(aq \(aqtag\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.event.fire_master(data, tag) Fire an event off up to the master server .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq event.fire_master \(aqstuff to be in the event\(aq \(aqtag\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.extfs .sp Module for managing ext2/3/4 file systems .INDENT 0.0 .TP .B salt.modules.extfs.attributes(device, args=None) Return attributes from dumpe2fs for a specified device .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq extfs.attributes /dev/sda1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.extfs.blocks(device, args=None) Return block and inode info from dumpe2fs for a specified device .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq extfs.blocks /dev/sda1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.extfs.dump(device, args=None) Return all contents of dumpe2fs for a specified device .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq extfs.dump /dev/sda1 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.extfs.mkfs(device, fs_type, **kwargs) Create a file system on the specified device .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq extfs.mkfs /dev/sda1 fs_type=ext4 opts=\(aqacl,noexec\(aq .ft P .fi .UNINDENT .UNINDENT .sp Valid options are: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C block_size: 1024, 2048 or 4096 check: check for bad blocks direct: use direct IO ext_opts: extended file system options (comma\-separated) fragment_size: size of fragments force: setting force to True will cause mke2fs to specify the \-F option twice (it is already set once); this is truly dangerous blocks_per_group: number of blocks in a block group number_of_groups: ext4 option for a virtual block group bytes_per_inode: set the bytes/inode ratio inode_size: size of the inode journal: set to True to create a journal (default on ext3/4) journal_opts: options for the fs journal (comma separated) blocks_file: read bad blocks from file label: label to apply to the file system reserved: percentage of blocks reserved for super\-user last_dir: last mounted directory test: set to True to not actually create the file system (mke2fs \-n) number_of_inodes: override default number of inodes creator_os: override "creator operating system" field opts: mount options (comma separated) revision: set the filesystem revision (default 1) super: write superblock and group descriptors only fs_type: set the filesystem type (REQUIRED) usage_type: how the filesystem is going to be used uuid: set the UUID for the file system .ft P .fi .UNINDENT .UNINDENT .sp See the \fBmke2fs(8)\fP manpage for a more complete description of these options. .UNINDENT .INDENT 0.0 .TP .B salt.modules.extfs.tune(device, **kwargs) Set attributes for the specified device (using tune2fs) .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq extfs.tune /dev/sda1 force=True label=wildstallyns opts=\(aqacl,noexec\(aq .ft P .fi .UNINDENT .UNINDENT .sp Valid options are: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C max: max mount count count: mount count error: error behavior extended_opts: extended options (comma separated) force: force, even if there are errors (set to True) group: group name or gid that can use the reserved blocks interval: interval between checks journal: set to True to create a journal (default on ext3/4) journal_opts: options for the fs journal (comma separated) label: label to apply to the file system reserved: percentage of blocks reserved for super\-user last_dir: last mounted directory opts: mount options (comma separated) feature: set or clear a feature (comma separated) mmp_check: mmp check interval reserved: reserved blocks count quota_opts: quota options (comma separated) time: time last checked user: user or uid who can use the reserved blocks uuid: set the UUID for the file system .ft P .fi .UNINDENT .UNINDENT .sp See the \fBmke2fs(8)\fP manpage for a more complete description of these options. .UNINDENT .SS salt.modules.file .sp Manage information about regular files, directories, and special files on the minion, set/read user, group, mode, and data .INDENT 0.0 .TP .B salt.modules.file.append(path, *args) New in version 0.9.5. .sp Append text to the end of a file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.append /etc/motd \e "With all thine offerings thou shalt offer salt." \e "Salt is what makes things taste bad when it isn\(aqt in them." .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.check_file_meta(name, sfn, source, source_sum, user, group, mode, env, template=None, contents=None) Check for the changes in the file metadata. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.check_file_meta /etc/httpd/conf.d/httpd.conf salt://http/httpd.conf \(aq{hash_type: \(aqmd5\(aq, \(aqhsum\(aq: }\(aq root, root, \(aq755\(aq base .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.check_hash(path, hash) Check if a file matches the given hash string .sp Returns true if the hash matched, otherwise false. Raises ValueError if the hash was not formatted correctly. .INDENT 7.0 .TP .B path A file path .TP .B hash A string in the form =. For example: \fBmd5=e138491e9d5b97023cea823fe17bac22\fP .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.check_hash /etc/fstab md5= .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.check_managed(name, source, source_hash, user, group, mode, template, makedirs, context, defaults, env, contents=None, **kwargs) Check to see what changes need to be made for a file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.check_managed /etc/httpd/conf.d/httpd.conf salt://http/httpd.conf \(aq{hash_type: \(aqmd5\(aq, \(aqhsum\(aq: }\(aq root, root, \(aq755\(aq jinja True None None base .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.check_perms(name, ret, user, group, mode) Check the permissions on files and chown if needed .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.check_perms /etc/sudoers \(aq{}\(aq root root 400 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.chgrp(path, group) Change the group of a file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.chgrp /etc/passwd root .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.chown(path, user, group) Chown a file, pass the file the desired user and group .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.chown /etc/passwd root root .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.comment(path, regex, char=\(aq#\(aq, backup=\(aq.bak\(aq) New in version 0.9.5. .sp Comment out specified lines in a file .INDENT 7.0 .TP .B path The full path to the file to be edited .TP .B 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 \fB^\fP or \fB$\fP characters outside the parenthesis (e.g., the pattern \fB^foo$\fP will be rewritten as \fB^(foo)$\fP) .TP .B char \fB#\fP The character to be inserted at the beginning of a line in order to comment it out .TP .B backup \fB\&.bak\fP The file will be backed up before edit with this file extension .sp \fBWARNING:\fP .INDENT 7.0 .INDENT 3.5 This backup will be overwritten each time \fBsed\fP / \fBcomment\fP / \fBuncomment\fP is called. Meaning the backup will only be useful after the first invocation. .UNINDENT .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.comment /etc/modules pcspkr .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.contains(path, text) New in version 0.9.5. .sp Return \fBTrue\fP if the file at \fBpath\fP contains \fBtext\fP .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.contains /etc/crontab \(aqmymaintenance.sh\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.contains_glob(path, glob) Return True if the given glob matches a string in the named file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.contains_glob /etc/foobar \(aq*cheese*\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.contains_regex(path, regex, lchar=\(aq\(aq) Return True if the given regular expression matches on any line in the text of a given file. .sp If the lchar argument (leading char) is specified, it will strip \fIlchar\fP from the left side of each line before trying to match .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.contains_regex /etc/crontab .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.contains_regex_multiline(path, regex) Return True if the given regular expression matches anything in the text of a given file .sp Traverses multiple lines at a time, via the salt BufferedReader (reads in chunks) .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.contains_regex_multiline /etc/crontab \(aq^maint\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.copy(src, dst) Copy a file or directory .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.copy /path/to/src /path/to/dst .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.delete_backup(path, backup_id) .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 This function will be available in version 0.17.0. .UNINDENT .UNINDENT .sp Restore a previous version of a file that was backed up using Salt\(aqs \fBfile state backup\fP system. .INDENT 7.0 .TP .B path The path on the minion to check for backups .TP .B backup_id The numeric id for the backup you wish to delete, as found using \fBfile.list_backups\fP .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.restore_backup /foo/bar/baz.txt 0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.directory_exists(path) Tests to see if path is a valid directory. Returns True/False. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.directory_exists /etc .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.file_exists(path) Tests to see if path is a valid file. Returns True/False. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.file_exists /etc/passwd .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.find(path, **kwargs) Approximate the Unix \fBfind(1)\fP command and return a list of paths that meet the specified criteria. .sp The options include match criteria: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .sp and/or actions: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C delete [= file\-types] # default type = \(aqf\(aq exec = command [arg ...] # where {} is replaced by pathname print [= print\-opts] .ft P .fi .UNINDENT .UNINDENT .sp The default action is \(aqprint=path\(aq. .sp file\-glob: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C * = 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 .ft P .fi .UNINDENT .UNINDENT .sp path\-regex: a Python re (regular expression) pattern to match pathnames .sp file\-types: a string of one or more of the following: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C a: all file types b: block device c: character device d: directory p: FIFO (named pipe) f: plain file l: symlink s: socket .ft P .fi .UNINDENT .UNINDENT .sp users: a space and/or comma separated list of user names and/or uids .sp groups: a space and/or comma separated list of group names and/or gids .sp size\-unit: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C b: bytes k: kilobytes m: megabytes g: gigabytes t: terabytes .ft P .fi .UNINDENT .UNINDENT .sp interval: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C [w] [[d]] [h] [m] [s] where: w: week d: day h: hour m: minute s: second .ft P .fi .UNINDENT .UNINDENT .sp print\-opts: a comma and/or space separated list of one or more of the following: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C 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 .ft P .fi .UNINDENT .UNINDENT .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.find / type=f name=\e*.bak size=+10m salt \(aq*\(aq file.find /var mtime=+30d size=+10m print=path,size,mtime salt \(aq*\(aq file.find /var/log name=\e*.[0\-9] mtime=+30d size=+10m delete .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_devmm(name) Get major/minor info from a device .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_devmm /dev/chr .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_diff(minionfile, masterfile, env=\(aqbase\(aq) Return unified diff of file compared to file on master .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_diff /home/fred/.vimrc salt://users/fred/.vimrc .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_gid(path, follow_symlinks=True) Return the id of the group that owns a given file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_gid /etc/passwd .ft P .fi .UNINDENT .UNINDENT .sp Changed in version 0.16.4: \fBfollow_symlinks\fP option added .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_group(path, follow_symlinks=True) Return the group that owns a given file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_group /etc/passwd .ft P .fi .UNINDENT .UNINDENT .sp Changed in version 0.16.4: \fBfollow_symlinks\fP option added .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_hash(path, form=\(aqmd5\(aq, chunk_size=4096) Get the hash sum of a file .INDENT 7.0 .TP .B This is better than \fBget_sum\fP for the following reasons: .INDENT 7.0 .IP \(bu 2 It does not read the entire file into memory. .IP \(bu 2 .INDENT 2.0 .TP .B It does not return a string on error. The returned value of \fBget_sum\fP cannot really be trusted since it is vulnerable to collisions: \fBget_sum(..., \(aqxyz\(aq) == \(aqHash xyz not supported\(aq\fP .UNINDENT .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_hash /etc/shadow .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_managed(name, template, source, source_hash, user, group, mode, env, context, defaults, **kwargs) Return the managed file data for file.managed .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_managed /etc/httpd/conf.d/httpd.conf jinja salt://http/httpd.conf \(aq{hash_type: \(aqmd5\(aq, \(aqhsum\(aq: }\(aq root root \(aq755\(aq base None None .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_mode(path) Return the mode of a file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_mode /etc/passwd .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_selinux_context(path) Get an SELinux context from a given path .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_selinux_context /etc/hosts .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_sum(path, form=\(aqmd5\(aq) Return the sum for the given file, default is md5, sha1, sha224, sha256, sha384, sha512 are supported .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_sum /etc/passwd sha512 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_uid(path, follow_symlinks=True) Return the id of the user that owns a given file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_uid /etc/passwd .ft P .fi .UNINDENT .UNINDENT .sp Changed in version 0.16.4: \fBfollow_symlinks\fP option added .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.get_user(path, follow_symlinks=True) Return the user that owns a given file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.get_user /etc/passwd .ft P .fi .UNINDENT .UNINDENT .sp Changed in version 0.16.4: \fBfollow_symlinks\fP option added .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.gid_to_group(gid) Convert the group id to the group name on this system .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.gid_to_group 0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.group_to_gid(group) Convert the group to the gid on this system .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.group_to_gid root .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.is_blkdev(name) Check if a file exists and is a block device. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.is_blkdev /dev/blk .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.is_chrdev(name) Check if a file exists and is a character device. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.is_chrdev /dev/chr .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.is_fifo(name) Check if a file exists and is a FIFO. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.is_fifo /dev/fifo .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.list_backups(path, limit=None) .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 This function will be available in version 0.17.0. .UNINDENT .UNINDENT .sp Lists the previous versions of a file backed up using Salt\(aqs \fBfile state backup\fP system. .INDENT 7.0 .TP .B path The path on the minion to check for backups .TP .B limit Limit the number of results to the most recent N backups .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.list_backups /foo/bar/baz.txt .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.makedirs(path, user=None, group=None, mode=None) Ensure that the directory containing this path is available. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.makedirs /opt/code .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.makedirs_perms(name, user=None, group=None, mode=\(aq0755\(aq) Taken and modified from os.makedirs to set user, group and mode for each directory created. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.makedirs_perms /opt/code .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.manage_file(name, sfn, ret, source, source_sum, user, group, mode, env, backup, template=None, show_diff=True, contents=None) Checks the destination against what was retrieved with get_managed and makes the appropriate modifications (if necessary). .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.manage_file /etc/httpd/conf.d/httpd.conf \(aq{}\(aq salt://http/httpd.conf \(aq{hash_type: \(aqmd5\(aq, \(aqhsum\(aq: }\(aq root root \(aq755\(aq base \(aq\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.mkdir(dir_path, user=None, group=None, mode=None) Ensure that a directory is available. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.mkdir /opt/jetty/context .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.mknod(name, ntype, major=0, minor=0, user=None, group=None, mode=\(aq0600\(aq) .INDENT 7.0 .INDENT 3.5 Create a block device, character device, or fifo pipe. Identical to the gnu mknod. .sp CLI Examples: .UNINDENT .UNINDENT .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.mknod /dev/chr c 180 31 salt \(aq*\(aq file.mknod /dev/blk b 8 999 salt \(aq*\(aq file.nknod /dev/fifo p .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.mknod_blkdev(name, major, minor, user=None, group=None, mode=\(aq0660\(aq) Create a block device. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.mknod_blkdev /dev/blk 8 999 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.mknod_chrdev(name, major, minor, user=None, group=None, mode=\(aq0660\(aq) Create a character device. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.mknod_chrdev /dev/chr 180 31 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.mknod_fifo(name, user=None, group=None, mode=\(aq0660\(aq) Create a FIFO pipe. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.mknod_fifo /dev/fifo .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.patch(originalfile, patchfile, options=\(aq\(aq, dry_run=False) New in version 0.10.4. .sp Apply a patch to a file .sp Equivalent to: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C patch .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .TP .B originalfile The full path to the file or directory to be patched .TP .B patchfile A patch file to apply to \fBoriginalfile\fP .TP .B options Options to pass to patch. .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.patch /opt/file.txt /tmp/file.txt.patch .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.psed(path, before, after, limit=\(aq\(aq, backup=\(aq.bak\(aq, flags=\(aqgMS\(aq, escape_all=False, multi=False) New in version 0.9.5. .sp Make a simple edit to a file (pure Python version) .sp Equivalent to: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C sed "// s/// " .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .TP .B path The full path to the file to be edited .TP .B before A pattern to find in order to replace with \fBafter\fP .TP .B after Text that will replace \fBbefore\fP .TP .B limit \fB\(aq\(aq\fP An initial pattern to search for before searching for \fBbefore\fP .TP .B backup \fB\&.bak\fP The file will be backed up before edit with this file extension; \fBWARNING:\fP each time \fBsed\fP/\fBcomment\fP/\fBuncomment\fP is called will overwrite this backup .TP .B flags \fBgMS\fP.INDENT 7.0 .TP .B Flags to modify the search. Valid values are: .INDENT 7.0 .IP \(bu 2 \fBg\fP: Replace all occurrences of the pattern, not just the first. .IP \(bu 2 \fBI\fP: Ignore case. .IP \(bu 2 \fBL\fP: Make \fB\ew\fP, \fB\eW\fP, \fB\eb\fP, \fB\eB\fP, \fB\es\fP and \fB\eS\fP dependent on the locale. .IP \(bu 2 \fBM\fP: Treat multiple lines as a single line. .IP \(bu 2 \fBS\fP: Make \fI\&.\fP match all characters, including newlines. .IP \(bu 2 \fBU\fP: Make \fB\ew\fP, \fB\eW\fP, \fB\eb\fP, \fB\eB\fP, \fB\ed\fP, \fB\eD\fP, \fB\es\fP and \fB\eS\fP dependent on Unicode. .IP \(bu 2 \fBX\fP: Verbose (whitespace is ignored). .UNINDENT .UNINDENT .TP .B multi: \fBFalse\fP If True, treat the entire file as a single line .UNINDENT .sp Forward slashes and single quotes will be escaped automatically in the \fBbefore\fP and \fBafter\fP patterns. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.sed /etc/httpd/httpd.conf \(aqLogLevel warn\(aq \(aqLogLevel info\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.remove(path) Remove the named file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.remove /tmp/foo .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.rename(src, dst) Rename a file or directory .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.rename /path/to/src /path/to/dst .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.restore_backup(path, backup_id) .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 This function will be available in version 0.17.0. .UNINDENT .UNINDENT .sp Restore a previous version of a file that was backed up using Salt\(aqs \fBfile state backup\fP system. .INDENT 7.0 .TP .B path The path on the minion to check for backups .TP .B backup_id The numeric id for the backup you wish to restore, as found using \fBfile.list_backups\fP .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.restore_backup /foo/bar/baz.txt 0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.restorecon(path, recursive=False) Reset the SELinux context on a given path .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.restorecon /home/user/.ssh/authorized_keys .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.sed(path, before, after, limit=\(aq\(aq, backup=\(aq.bak\(aq, options=\(aq\-r \-e\(aq, flags=\(aqg\(aq, escape_all=False, negate_match=False) New in version 0.9.5. .sp Make a simple edit to a file .sp Equivalent to: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C sed "// s/// " .ft P .fi .UNINDENT .UNINDENT .INDENT 7.0 .TP .B path The full path to the file to be edited .TP .B before A pattern to find in order to replace with \fBafter\fP .TP .B after Text that will replace \fBbefore\fP .TP .B limit \fB\(aq\(aq\fP An initial pattern to search for before searching for \fBbefore\fP .TP .B backup \fB\&.bak\fP The file will be backed up before edit with this file extension; \fBWARNING:\fP each time \fBsed\fP/\fBcomment\fP/\fBuncomment\fP is called will overwrite this backup .TP .B options \fB\-r \-e\fP Options to pass to sed .TP .B flags \fBg\fP Flags to modify the sed search; e.g., \fBi\fP for case\-insensitve pattern matching .TP .B negate_match False Negate the search command (\fB!\fP) .sp New in version 0.17. .UNINDENT .sp Forward slashes and single quotes will be escaped automatically in the \fBbefore\fP and \fBafter\fP patterns. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.sed /etc/httpd/httpd.conf \(aqLogLevel warn\(aq \(aqLogLevel info\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.sed_contains(path, text, limit=\(aq\(aq, flags=\(aqg\(aq) Return True if the file at \fBpath\fP contains \fBtext\fP\&. Utilizes sed to perform the search (line\-wise search). .sp Note: the \fBp\fP flag will be added to any flags you pass in. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.contains /etc/crontab \(aqmymaintenance.sh\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.set_mode(path, mode) Set the mode of a file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.set_mode /etc/passwd 0644 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.set_selinux_context(path, user=None, role=None, type=None, range=None) Set a specific SELinux label on a given path .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.set_selinux_context path .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.source_list(source, source_hash, env) Check the source list and return the source to use .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.source_list salt://http/httpd.conf \(aq{hash_type: \(aqmd5\(aq, \(aqhsum\(aq: }\(aq base .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.stats(path, hash_type=\(aqmd5\(aq, follow_symlink=False) Return a dict containing the stats for a given file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.stats /etc/passwd .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.symlink(src, link) Create a symbolic link to a file .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.symlink /path/to/file /path/to/link .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.touch(name, atime=None, mtime=None) New in version 0.9.5. .sp Just like the \fBtouch\fP command, create a file if it doesn\(aqt exist or simply update the atime and mtime if it already does. .INDENT 7.0 .TP .B atime: Access time in Unix epoch time .TP .B mtime: Last modification in Unix epoch time .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.touch /var/log/emptyfile .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.uid_to_user(uid) Convert a uid to a user name .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.uid_to_user 0 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.uncomment(path, regex, char=\(aq#\(aq, backup=\(aq.bak\(aq) New in version 0.9.5. .sp Uncomment specified commented lines in a file .INDENT 7.0 .TP .B path The full path to the file to be edited .TP .B regex A regular expression used to find the lines that are to be uncommented. This regex should not include the comment character. A leading \fB^\fP character will be stripped for convenience (for easily switching between comment() and uncomment()). .TP .B char \fB#\fP The character to remove in order to uncomment a line .TP .B backup \fB\&.bak\fP The file will be backed up before edit with this file extension; \fBWARNING:\fP each time \fBsed\fP/\fBcomment\fP/\fBuncomment\fP is called will overwrite this backup .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.uncomment /etc/hosts.deny \(aqALL: PARANOID\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.file.user_to_uid(user) Convert user name to a uid .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq file.user_to_uid root .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.freebsd_sysctl .sp Module for viewing and modifying sysctl parameters .INDENT 0.0 .TP .B salt.modules.freebsd_sysctl.assign(name, value) Assign a single sysctl parameter for this minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sysctl.assign net.inet.icmp.icmplim 50 .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsd_sysctl.get(name) Return a single sysctl parameter for this minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sysctl.get hw.physmem .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsd_sysctl.persist(name, value, config=\(aq/etc/sysctl.conf\(aq) Assign and persist a simple sysctl parameter for this minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sysctl.persist net.inet.icmp.icmplim 50 salt \(aq*\(aq sysctl.persist coretemp_load NO config=/boot/loader.conf .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsd_sysctl.show() Return a list of sysctl parameters for this minion .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq sysctl.show .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.freebsdjail .sp The jail module for FreeBSD .INDENT 0.0 .TP .B salt.modules.freebsdjail.fstab(jail) Display contents of a fstab(5) file defined in specified jail\(aqs configuration. If no file is defined, return False. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq jail.fstab .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdjail.get_enabled() Return which jails are set to be run .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq jail.get_enabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdjail.is_enabled() See if jail service is actually enabled on boot .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq jail.is_enabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdjail.restart(jail=\(aq\(aq) Restart the specified jail or all, if none specified .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq jail.restart [] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdjail.show_config(jail) Display specified jail\(aqs configuration .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq jail.show_config .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdjail.start(jail=\(aq\(aq) Start the specified jail or all, if none specified .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq jail.start [] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdjail.status(jail) See if specified jail is currently running .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq jail.status .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdjail.stop(jail=\(aq\(aq) Stop the specified jail or all, if none specified .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq jail.stop [] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdjail.sysctl() Dump all jail related kernel states (sysctl) .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq jail.sysctl .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.freebsdkmod .sp Module to manage FreeBSD kernel modules .INDENT 0.0 .TP .B salt.modules.freebsdkmod.available() Return a list of all available kernel modules .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq kmod.available .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdkmod.check_available(mod) Check to see if the specified kernel module is available .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq kmod.check_available kvm .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdkmod.load(mod) Load the specified kernel module .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq kmod.load kvm .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdkmod.lsmod() Return a dict containing information about currently loaded modules .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq kmod.lsmod .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdkmod.remove(mod) Remove the specified kernel module .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq kmod.remove kvm .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.freebsdpkg .sp Package support for FreeBSD .INDENT 0.0 .TP .B salt.modules.freebsdpkg.file_dict(*packages) List the files that belong to a package, grouped by package. Not specifying any packages will return a list of _every_ file on the system\(aqs package database (not generally recommended). .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.file_list httpd salt \(aq*\(aq pkg.file_list httpd postfix salt \(aq*\(aq pkg.file_list .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.file_list(*packages) List the files that belong to a package. Not specifying any packages will return a list of _every_ file on the system\(aqs package database (not generally recommended). .sp CLI Examples: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.file_list httpd salt \(aq*\(aq pkg.file_list httpd postfix salt \(aq*\(aq pkg.file_list .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.install(name=None, refresh=False, fromrepo=None, pkgs=None, sources=None, **kwargs) Install the passed package .INDENT 7.0 .TP .B name The name of the package to be installed. .TP .B refresh Whether or not to refresh the package database before installing. .TP .B fromrepo Specify a package repository to install from. .UNINDENT .sp Multiple Package Installation Options: .INDENT 7.0 .TP .B pkgs A list of packages to install from a software repository. Must be passed as a python list. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install pkgs=\(aq["foo","bar"]\(aq .ft P .fi .UNINDENT .UNINDENT .TP .B sources A list of packages to install. Must be passed as a list of dicts, with the keys being package names, and the values being the source URI or local path to the package. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install sources=\(aq[{"foo": "salt://foo.deb"},{"bar": "salt://bar.deb"}]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .sp Return a dict containing the new package names and versions: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: {\(aqold\(aq: \(aq\(aq, \(aqnew\(aq: \(aq\(aq}} .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.install .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.latest_version(*names, **kwargs) Return the latest version of the named package available for upgrade or installation. If more than one package name is specified, a dict of name/version pairs is returned. .sp If the latest version of a given package is already installed, an empty string will be returned for that package. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.latest_version salt \(aq*\(aq pkg.latest_version ... .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.list_pkgs(versions_as_list=False, **kwargs) List the packages currently installed as a dict: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: \(aq\(aq} .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.list_pkgs .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.purge(name=None, pkgs=None, **kwargs) Package purges are not supported, this function is identical to \fBremove()\fP\&. .INDENT 7.0 .TP .B name The name of the package to be deleted. .UNINDENT .sp Multiple Package Options: .INDENT 7.0 .TP .B pkgs A list of packages to delete. Must be passed as a python list. The \fBname\fP parameter will be ignored if this option is passed. .UNINDENT .sp New in version 0.16.0. .sp Returns a dict containing the changes. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.purge salt \(aq*\(aq pkg.purge ,, salt \(aq*\(aq pkg.purge pkgs=\(aq["foo", "bar"]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.refresh_db() Use pkg update to get latest repo.txz when using pkgng. Updating with portsnap is not yet supported. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.refresh_db .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.rehash() Recomputes internal hash table for the PATH variable. Use whenever a new command is created during the current session. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.rehash .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.remove(name=None, pkgs=None, **kwargs) Remove packages. .INDENT 7.0 .TP .B name The name of the package to be deleted. .UNINDENT .sp Multiple Package Options: .INDENT 7.0 .TP .B pkgs A list of packages to delete. Must be passed as a python list. The \fBname\fP parameter will be ignored if this option is passed. .UNINDENT .sp New in version 0.16.0. .sp Returns a dict containing the changes. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.remove salt \(aq*\(aq pkg.remove ,, salt \(aq*\(aq pkg.remove pkgs=\(aq["foo", "bar"]\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.search(pkg_name) Use \fIpkg search\fP if pkg is being used. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.search \(aqmysql\-server\(aq .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.upgrade() Run pkg upgrade, if pkgng used. Otherwise do nothing .sp Return a dict containing the new package names and versions: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C {\(aq\(aq: {\(aqold\(aq: \(aq\(aq, \(aqnew\(aq: \(aq\(aq}} .ft P .fi .UNINDENT .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.upgrade .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdpkg.version(*names, **kwargs) Returns a string representing the package version or an empty string if not installed. If more than one package name is specified, a dict of name/version pairs is returned. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq pkg.version salt \(aq*\(aq pkg.version ... .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.freebsdservice .sp The service module for FreeBSD .INDENT 0.0 .TP .B salt.modules.freebsdservice.available(name) Check that the given service is available. .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.available sshd .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.disable(name, **kwargs) Disable the named service to start at boot .sp Arguments the same as for enable() .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.disable .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.disabled(name) Return True if the named service is enabled, false otherwise .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.disabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.enable(name, **kwargs) Enable the named service to start at boot .INDENT 7.0 .TP .B name service name .TP .B config /etc/rc.conf Config file for managing service. If config value is empty string, then /etc/rc.conf.d/ used. See man rc.conf(5) for details. .sp Also service.config variable can be used to change default. .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.enable .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.enabled(name) Return True if the named service is enabled, false otherwise .INDENT 7.0 .TP .B name Service name .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.enabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.get_all() Return a list of all available services .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.get_all .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.get_disabled() Return what services are available but not enabled to start at boot .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.get_disabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.get_enabled() Return what services are set to run on boot .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.get_enabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.reload_(name) Restart the named service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.reload .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.restart(name) Restart the named service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.restart .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.start(name) Start the specified service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.start .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.status(name, sig=None) Return the status for a service (True or False). .INDENT 7.0 .TP .B name Name of service .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.status .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.freebsdservice.stop(name) Stop the specified service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.stop .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.gem .sp Manage ruby gems. .INDENT 0.0 .TP .B salt.modules.gem.install(gems, ruby=None, runas=None, version=None, rdoc=False, ri=False) Installs one or several gems. .INDENT 7.0 .TP .B gems The gems to install .TP .B ruby None If RVM is installed, the ruby version and gemset to use. .TP .B runas None The user to run gem as. .TP .B version None Specify the version to install for the gem. Doesn\(aqt play nice with multiple gems at once .TP .B rdoc False Generate RDoc documentation for the gem(s). .TP .B ri False Generate RI documentation for the gem(s). .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq gem.install vagrant .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gem.list_(prefix=\(aq\(aq, ruby=None, runas=None) List locally installed gems. .INDENT 7.0 .TP .B prefix : Only list gems when the name matches this prefix. .TP .B ruby None If RVM is installed, the ruby version and gemset to use. .TP .B runas None The user to run gem as. .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq gem.list .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gem.sources_add(source_uri, ruby=None, runas=None) Add a gem source. .INDENT 7.0 .TP .B source_uri The source URI to add. .TP .B ruby None If RVM is installed, the ruby version and gemset to use. .TP .B runas None The user to run gem as. .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq gem.sources_add http://rubygems.org/ .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gem.sources_list(ruby=None, runas=None) List the configured gem sources. .INDENT 7.0 .TP .B ruby None If RVM is installed, the ruby version and gemset to use. .TP .B runas None The user to run gem as. .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq gem.sources_list .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gem.sources_remove(source_uri, ruby=None, runas=None) Remove a gem source. .INDENT 7.0 .TP .B source_uri The source URI to remove. .TP .B ruby None If RVM is installed, the ruby version and gemset to use. .TP .B runas None The user to run gem as. .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq gem.sources_remove http://rubygems.org/ .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gem.uninstall(gems, ruby=None, runas=None) Uninstall one or several gems. .INDENT 7.0 .TP .B gems The gems to uninstall. .TP .B ruby None If RVM is installed, the ruby version and gemset to use. .TP .B runas None The user to run gem as. .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq gem.uninstall vagrant .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gem.update(gems, ruby=None, runas=None) Update one or several gems. .INDENT 7.0 .TP .B gems The gems to update. .TP .B ruby None If RVM is installed, the ruby version and gemset to use. .TP .B runas None The user to run gem as. .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq gem.update vagrant .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gem.update_system(version=\(aq\(aq, ruby=None, runas=None) Update rubygems. .INDENT 7.0 .TP .B version (newest) The version of rubygems to install. .TP .B ruby None If RVM is installed, the ruby version and gemset to use. .TP .B runas None The user to run gem as. .UNINDENT .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq gem.update_system .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.gentoo_service .sp Top level package command wrapper, used to translate the os detected by grains to the correct service manager .INDENT 0.0 .TP .B salt.modules.gentoo_service.disable(name, **kwargs) Disable the named service to start at boot .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.disable .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gentoo_service.disabled(name) Return True if the named service is enabled, false otherwise .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.disabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gentoo_service.enable(name, **kwargs) Enable the named service to start at boot .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.enable .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gentoo_service.enabled(name) Return True if the named service is enabled, false otherwise .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.enabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gentoo_service.get_all() Return all available boot services .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.get_all .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gentoo_service.get_disabled() Return a set of services that are installed but disabled .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.get_disabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gentoo_service.get_enabled() Return a list of service that are enabled on boot .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.get_enabled .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gentoo_service.restart(name) Restart the named service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.restart .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gentoo_service.start(name) Start the specified service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.start .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B 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 .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.status [service signature] .ft P .fi .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B salt.modules.gentoo_service.stop(name) Stop the specified service .sp CLI Example: .INDENT 7.0 .INDENT 3.5 .sp .nf .ft C salt \(aq*\(aq service.stop .ft P .fi .UNINDENT .UNINDENT .UNINDENT .SS salt.modules.gentoolkitmod .sp Support for Gentoolkit .INDENT 0.0 .TP .B salt.modules.gentoolkitmod.eclean_dist(destructive=False, package_names=False, size_limit=0, time_limit=0, fetch_restricted=False, exclude_file=\(aq/etc/eclean/distfiles.exclude\(aq) Clean obsolete portage sources .INDENT 7.0 .TP .B destructive Only keep minimum for reinstallation .TP .B package_names Protect all versions of installed packages. Only meaningful if used with destructive=True .TP .B size_limit Don\(aqt delete distfiles bigger than . is a size specification: "10M" is "ten megabytes", "200K" is "two hundreds kilobytes", etc. Units are: G, M, K and B. .TP .B time_limit