Learn Getting Started With SaltStack on Ubuntu 17.04

April 5, 2019

Table of Contents

SaltStack is a python-based configuration management program which is optimized for the automation of configuration files, deployments and anything else under the software-defined datacenter topic. In this guide, you will learn how to get started with SaltStack, adding your first nodes and writing your first formula.


  • IT Web Services instance running Ubuntu 17.04 ( master )
  • IT Web Services instance running Ubuntu 17.04 ( minion )


SaltStack uses a few keywords which represent a particular device or configuration, as explained below:


This is the master instance which connects to all servers added to your SaltStack “cluster”, thus also running any commands / communication to your servers.


The servers which are added to your SaltStack are called minions. Any actions are either performed on one, a group, or all of your minions.


A formula represents a file or a set of files which introduces the minions which commands that should be performed. This can be the installation of a single application such as nginx or rolling out configuration files, etc.


A pillar is a file which stores information related to a group of minions or a single minion. As an example, you would use this sort of file for storing the “Virtual-Hosts” for Nginx for a particular minion.

Server setup


First, we will start with setting up the master for our SaltStack cluster:

apt-get update
apt-get dist-upgrade
apt-get install salt-master

By default, the SaltStack master is not listening on any interfaces, as the master is usually communicating with the minions over the public internet though. We have to make a little change in the configuration file which can be found at /etc/salt/master:

# The address of the interface to bind to:

After the changes have been written to the file, restart the master service:

service salt-master restart


We can now proceed with adding our first minion. Go straight ahead and install the required packages:

apt-get update
apt-get dist-upgrade
apt-get install salt-minion

Next, we need to make another little change in the minion’s SaltStack configuration which can be found at /etc/salt/minion:

# Set the location of the salt master server. If the master server cannot be
# resolved, then the minion will fail to start.
master: <master_server_ip>

Replace <master_server_ip> with the IP address of your master server as setup earlier. Ideally, you would set up a DNS record for this though, in order to make changing the master server easier.

Afterwards, we have to restart the minion service for the changes to become active:

service salt-minion restart

SaltStack master operations

We now have a working master and minion set up, so we can directly go ahead and work with a small set of the SaltStack commands on the master.

Showing all minions

# salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
Rejected Keys:

Note: We have already told the minion to which master server it should connect. Therefore, if you have followed this guide, you would already see the minion under the Unaccepted Keys: section.

Accepting an unaccepted minion

# salt-key -a <minion_id>

Accepting all unaccepted minions

# salt-key -A

Removing a minion

# salt-key -d <minion_id>

Note: <minion_id> usually represents the UNIX hostname of your minion(s) and is stored in the /etc/salt/minion_id file on the minion(s).

Creating your first formula

After adding our minion to the master, we can continue with writing our first formula. Initially, we have to create the folder that stores our formulas:

mkdir -p /srv/salt/

Create the folder for our first formula:

mkdir -p /srv/salt/nginx

Basically, any instructions for a formula are stored in the init.sls file, for example, /srv/salt/nginx/init.sls. As there is an immense amount of operations that can be performed through a formula, we will write a small formula which installs Nginx:

    - installed

Running your first formula

After writing into the init.sls file as explained above, we can go ahead and run it:

salt '*' state.sls nginx

Note: nginx represents the name of the folder we have previously created.


SaltStack is a very good software for automating any sort of configuration files, service deployments, initial server roll-outs and similar. Because of the fact that SaltStack is based on Python, you can easily add your own modules too, if you are fluent with the language. Happy automating!

Need help?

Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!