Salt Quickstart – Salt Stack Master and Slave on Ubuntu Linux

You can control a thousand computers with Salt. And this is how you install Salt.
Slaves, the controlled computers, can be anywhere: behind an NAT, behind a firewall, on an unknown address. And still you can control them. Only the master server needs to have a public server and known address.

These commands have been tested on Xubuntu 16.04, and they probably work similarly on any Ubuntu or Debian.
The network will have one master, and many slaves. The master prompt below is “master$” and slave “minion” prompt is “slave$”.

Install Master

master$ sudo apt-get update
master$ sudo apt-get -y install salt-master
master$ hostname -I
10.0.0.88

If your master has a firewall, the master needs holes 4505/tcp and 4506/tcp. If you haven’t installed a firewall on your test setup, you don’t have to care about it.

Install Slave

slave$ sudo apt-get update
slave$ sudo apt-get -y install salt-minion

The slave must know where the master is. You can also give your slave a name (id), or the name is automatically generated from hostname. Each slave must have a different id, so for a live USB, the id parameter is required.

slave$ sudoedit /etc/salt/minion
master: 10.0.0.88
id: tero

To use your new settings and make slave connect to master, restart the slave (minion) daemon.

slave$ sudo systemctl restart salt-minion.service

Accept Slave Key on Master

master$ sudo salt-key -A
Unaccepted Keys:
tero
Proceed? [n/Y]
Key for minion tero accepted.

Try It Out – Command Slaves

master$ sudo salt '*' cmd.run 'whoami'
tero:
 root

If you got an answer from slaves, well done! You have your first slave. Now you can install as many slaves as you want.
In some versions of salt, the command also prints some unnecessary warnings, which you can ignore: “[WARNING ] Key ‘file_ignore_glob’ with value None has…”.

What Next?

You can now try some other commands on your slaves.

master$ sudo salt '*' cmd.run 'hostname -I'
master$ sudo salt '*' grains.items|less
master$ sudo salt '*' grains.items
master$ sudo salt '*' grains.item virtual
master$ sudo salt '*' pkg.install httpie
master$ sudo salt '*' sys.doc|less

Now that your master-slave infrastructure is working, you can start learning how to write states. They are files that define the target state of your slaves.

See also

Salt Documentation: Tutorial, Running Commands, All Execution Modules.
Leppälahti, Kolkki, Koski, Laine 2017: Arctic CCM: Salt
Hardy 2017: SaltStack Cheatsheet

Adminstrivia

Tested on Xubuntu 16.04 LTS amd64. These commands have been tested by over 40 persons.
Updated: multiple additions to commands and explanations.

Posted in Uncategorized | Tagged , , , , , , , , , , , , , , | Comments Off on Salt Quickstart – Salt Stack Master and Slave on Ubuntu Linux

Comments are closed.