Getting Started with Salt Stack-the Other Configuration Management System Built with Python
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.
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.
Using your favorite text editor, open the minion file.
Uncomment the line
# master: saltby removing the
saltwith 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.)
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.)
Restart your minion using
sudo salt-minion -din order for it to read the new configuration settings. The
-dflag 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. Salt automatically
takes care of generating these keys for you, so you simply need to accept the
minion(s) you want.
salt-key -Lto get a list of all pending, accepted and rejected keys.
You should see an unaccepted key for
1st-Salt-Minion(or whatever ID you chose for your minion).
Accept this key using
sudo salt-key -a 1st-Salt-Minion.
Now that you have a salt-master and a salt-minion, and the minion and master
trust one another, you can check the connection by issuing a test ping command
from the master. This will return "True" if your master can communicate with your
salt '*' test.ping, and it should return:
Note that the wild-card
'*' targets every minion, and as
you have only one,
this is basically moot (it's just faster than typing
If you receive a "True" response back from your minion, you have installed Salt Stack successfully and configured your master and minion to communicate properly.
If you don't, you may want to restart your master and minion without the
(dæmon) flag, so you can observe the output. For more information, see the
Salt documentation at http://docs.saltstack.org/en/latest/topics/configuration.html.
The Salt command syntax involves the command, the target(s) and the action. So,
for this example,
'*' targets everything (it's a wild
test.ping is the
You can now execute any available command on any connected and authenticated minion. Important note: these commands must be available on the targeted minion in order to execute them. For instance, a command like:
sudo salt '*' cmd.run "service apache2 restart"
would work only for a distribution that calls the Apache Web server apache2 and that has the Apache Web server installed. For others, you would need to issue the command:
sudo salt '*' cmd.run "service httpd restart"
Some other examples might include querying the amount of time your servers have been running. You can do that with:
sudo salt '*' cmd.run "uptime"
If you had, for example, Apache Bench installed on a master but not on a minion, the command:
sudo salt '*' cmd.run "ab -n 10 -c 2 http://www.google.com:80/index.html"
would fail if you tried to execute it on a minion, since Apache Bench isn't installed on the minion.
The possibilities here are practically limitless. You can reboot all of your machines at once, update system software and check your machines' health from one terminal instead of logging in to each machine and issuing these commands independently.
You also can target specific groups, based upon criteria that you select. See
-G flag documentation at http://saltstack.org for more options.
Very rarely should you ever need to log in to a minion again. All configuration and execution can be handled remotely, quickly and simultaneously.
Now that you've installed Salt and can execute remote commands, why stop there? The second part of Salt's power comes from the configuration management tools included with Salt.
Ben Hosmer is a DEVOP with RadiantBlue Technologies where he develops and maintains Drupal sites and administers various servers. He is an open-source advocate and helps spread the use of Linux and other open-source software within the US government.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- SUSE LLC's SUSE Manager
- My +1 Sword of Productivity
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Non-Linux FOSS: Caffeine!
- Managing Linux Using Puppet
- Doing for User Space What We Did for Kernel Space
- Tech Tip: Really Simple HTTP Server with Python
- SuperTuxKart 0.9.2 Released
- Parsing an RSS News Feed with a Bash Script
- Rogue Wave Software's Zend Server
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide