FEATURE Getting Started with Salt Stack
edition either. With Salt, the version you get is the version everyone else gets too—whether you’ve paid money or not. There are plans for an enterprise version, but it merely will be less bleeding-edge and will be subjected to a higher amount of testing and quality assurance, and it possibly will include training as well.
Tools like Salt, Puppet and Chef allow you to issue commands on
multiple machines at once, and install and configure software too. Salt
has two main aspects: configuration management and remote execution.
Salt Stack is a command-line tool.
There isn’t anything to click on with your mouse, and the feedback is presented as text that is returned on your screen.
This is good. It keeps things lean, and most servers don’t include a graphical user interface anyway. (Note: I use the terms Salt and Salt interchangeably throughout this article. They mean the same thing in this context.)
In this article, I cover the two tools included with Salt. The first is remote execution, although there isn’t any clear delineation or any different way to interact with Salt if you want to work with configuration management or remote execution. This allows you to log in to a master machine and
then execute commands on one or many other machines at once. With Salt, you simply type your command once on your master machine, and it executes on every machine, or even a targeted group of machines.
Second, Salt is capable of storing configuration directives, and then instructing other machines to follow those directives by doing things like installing software, making configuration changes to the software, and then reporting back on the progress and success or failures of the installation.
Later, I demonstrate using Salt to install an additional package on one, or even 1,000 machines, and then configure that package by issuing just one command.
Installing Salt
Salt is a constantly evolving
organism. Possibly by the time you read this, some things may have changed. You always can find the most current documentation here:
http://docs.saltstack.org/en/
latest/index.html.
You do need a few prerequisites before installing Salt:
1. A Linux server.
2. sudo or root access to this server.
3. An Internet connection to this server.
4. Knowledge of your server’s IP address (it can be a public or private address).
Even though Salt is designed to interact with multiple servers, for this tutorial, you actually can accomplish everything on one machine.
Use your package manager to install Salt, and follow the
installation guide found in the Salt Docs for your particular distribution (http://docs.saltstack.org/en/latest/
topics/installation/index.html). You’ll also need sudo or root privileges to use Salt and install these packages.
The benefits of using a package manager or installing from source are a constant source of on-line and water-cooler debates. Depending on your distribution, you may
have to install the packages from source instead of using your
package manager.
If you’d like to install from source, you can find the latest Salt source files in the Salt Project’s GitHub repository (https://github.com/saltstack/salt).
After following the instructions
for installing both a salt-master and salt-minion, hopefully, everything went well and you didn’t receive any errors. If things didn’t work out quite right, support is generally available quickly from the Salt Stack mailing list (http://saltstack.org/
learn/#tab-mailinglist) and the
#salt IRC channel.
Configure Your Master and Minion(s)
The terms master and minion refer to the controller and the controlled.
The master essentially is the central coordinator for all of the minions—
similar to a client/server configuration where the master is the server, and the minion is the client.
Minion Configuration
For this tutorial, I cover issuing salt-master and salt-minion
commands on the same machine.
If you are configuring multiple machines, choose one to be the master, and all the others will be minions. The choice of master or minion is yours, and there are many reasons to configure one machine as the master. I explain how to set one as a master and the other(s) as minions next.
FEATURE Getting Started with Salt Stack
Salt’s configuration files are located in /etc/salt. By default, these files are named minion and master. If you’ve installed the salt-master and salt-minion on the same machine, you will see two respective files, master and minion.
You first need to tell your minion how to locate and communicate with your master. Even though you are running both on the same server, you still need to tell your minion where your master is.
1. Using your favorite text editor, open the minion file.
2. Uncomment the line # master:
salt by removing the # and replacing salt with the your master’s IP address. It now should look like this: master:
your.ip.address.here. (If you’re doing this locally on the same
machine, you can add 127.0.0.1.) 3. Give your minion a nickname.
Locate the line #id:, and again remove the # and add a name id: 1st-Salt-Minion. (This name can be anything you want.)
4. Restart your minion using sudo salt-minion -d in order for it to read the new configuration settings. The -d flag dæmonizes the process and starts the minion in the background, so you still can access your command-line to issue more commands.
Accept Your Minion’s Keys Now that your minion knows where your master is, it’s time for them to authenticate
one another. Salt uses public key encryption to secure the communication between master and minions. You need to notify the master and minion that they can trust each other by accepting the minion’s keys on the master.
Accept your minion’s keys using the salt-key command.