how to setup saltstack on rocky linux 8 centos 8

Salt stack is an open source configuration management tool based on Python. Just like Ansible, Salt stack can be used to automate your infrastructure management through configuration management, remote execution, data-driven orchestration e.t.c.

Salt stack uses a Server-Client architecture where the configuration management is done from the Saltstack Master and the clients, normally refered to as Minions connect to the master through an agent installed to them.

The Saltstack master holds the inventory and the public keys for the SaltStack Minions which is necessary for remote execution.

This guide will highlight how to setup and configure SaltStack Master and MInion, then demonstrate how to automate your infrastructure using this stack.

In our guide, we shall setup a SaltStack Master on Rocky Linux 8, then join nodes to it.

Install SaltStack Master on Rocky Linux 8/CentOS 8

Follow the steps below to setup SaltStack Master:

Step 1. Install Python

As we had mentioned before, SaltStack is based on Python. This means that for every system that we intend to include in our environment should have Python installed.

Make sure your system packages are up-to-date before we can proceed with the installations

sudo dnf update -y

Reboot your system to apply some of the changes after update

sudo reboot now

Let’s proceed to install Python 3 on our SaltStack Master node

sudo dnf install python3 -y

Step 2. Install SaltStack Yum Repository

We need to install SaltStack yum repository to download the download the latest version of SaltStack.

dnf install -y

Update your system cache

sudo dnf makecache
dnf -y update

Step 3. Install SaltStack Master on CentOS 8

Download and install SaltStack Master and the required dependencies

 dnf install -y salt-master salt-minion salt-ssh salt-syndic salt-cloud salt-api

The command above installs both SaltStack Master and SaltStack Minion on the host. This is necessary because the SaltStack minion is responsible for collection of system metrics and sends the metrics to the Master, this also applies for the SaltStack Master.

Step 4. Configure SaltStack Master on CentOS 8/Rocky Linux 8

After a successful installation of the required packages. The next step will be to configure our host to act as the Master. SaltStack configuration files are at /etc/salt/ directory.

Edit the /etc/salt/minion file and add the hostname of the Master server.

vi /etc/salt/minion

Find the line below:

#master: salt

Uncomment the line and add the hostname of the Master


Make sure that the hostname is DNS resolvable or you can map a static hostname in the /etc/hosts.

echo "<master-ip>  <master-hostname>" >> /etc/hosts


echo "" >> /etc/hosts

Start SaltStack Master and Minion services on the SaltStack Master host.

systemctl enable --now salt-master salt-minion

Allow SaltStack ports through the firewall for Minion connections

sudo firewall-cmd --zone=public --permanent --add-port={4505,4506}/tcp
sudo firewall-cmd --reload

Install SaltStack Minion on Rocky Linux 8 / CentOS 8

We need to install SaltStack Minion agent on the nodes that we wish to include in our environment. In this guide we shall use a host running CentOS 8. The installation steps are as follows:

Install Python 3

We need to install Python 3 on our CentOS 8 node. Before you can do that, make sure that your system is updated .

sudo dnf -y update

Install Python 3.

sudo dnf -y install python 3

Install SaltStack Minion

Setup SaltStack repo on the node to download the latest version of SaltStack

sudo dnf install -y

Update your cache then install SaltStack Minion.

sudo dnf update
sudo dnf install salt-minion -y

Configure SaltStack Minion

We need to configure the SaltStack Minion to communicate with the SaltStack Master. SaltStack Master and Minion connects using Public/Private keys.

This means that the SaltStack Minion has to send the key to the Master and the key be accepted by the master for them to communicate.

Make sure that the SaltStack Minion can communicate with the Master using the DNS name or a statically assigned hostname.

To add the hostname of the master to static DNS of the SaltStack Minion, add it in the /etc/hosts file as shown below:

echo "<master-ip>  <master-hostname>" | sudo tee -a /etc/hosts

Make sure that the Master’s hostname is reachable through ping from the Minion.

Edit the file at /etc/salt/minion and add the hostname of the SaltStack Master as shown:


Relace the hostname with the hostname of your SaltStack Master.

Then finally start and enable salt-minon service.

systemctl enable --now salt-minion

Connect SaltStack Minion to SaltStack Master

To connect the SaltStack Minion to the SaltStack Master, we will need to accept the public key of the minion that was sent to the master when the minion service was started.

On the SaltStack Master, check the availabe public keys that are yet to be accepted.

salt-key -L

The output informs us that there are two unaccepted keys:

$ sudo salt-key -L
Accepted Keys:
Denied Keys:
Unaccepted Keys:
Rejected Keys:

This is because the SaltStack Master also has a running salt-minion service and therefore the service has sent the key for authentication.

We can the accept the keys by:

$ salt-key -A
The following keys are going to be accepted:
Unaccepted Keys:
Proceed? [n/Y] y
Key for minion node02 accepted.
Key for minion node02 accepted.

We have now connected two minion servers to our Master. We now need to test if the minions are reachable:

$ salt '*'

That confirms that the two nodes are both reachable through ping.

We can now start issuing remote commands to the minions for automation an orchestration.

Execute Remote commands to Minon nodes

With the SaltStack Master and Minion setup complete, we can now issue remote commands to the minions and get things done without necessarly having to access the minion hosts.

Below are examples of some of the commands you can execute remotely through the SaltStack Master.

The general syntax is:

salt 'remote-host' 'command-you-want-to-execute'


salt 'node02' 'yum -y install nginx'
install saltstack on rocky linux 8

You can also start and enable the service on the node.

$ salt 'node02' 'systemctl enable --now nginx'
    Created symlink /etc/systemd/system/ -> /usr/lib/systemd/system/nginx.service.

To run commands on all availabe nodes, the syntax used is:

salt '*' 'command-you-want-to-execute'


$ salt '*' 'systemctl status nginx'
    * nginx.service - The nginx HTTP and reverse proxy server
       Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
      Drop-In: /usr/lib/systemd/system/nginx.service.d
       Active: active (running) since Wed 2021-07-14 15:44:45 EDT; 2min 44s ago
      Process: 3310 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
      Process: 3308 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
      Process: 3307 ExecStartPre=/usr/bin/rm -f /run/ (code=exited, status=0/SUCCESS)
     Main PID: 3312 (nginx)
        Tasks: 2 (limit: 4938)
       Memory: 6.1M
       CGroup: /system.slice/nginx.service
               |-3312 nginx: master process /usr/sbin/nginx
               `-3313 nginx: worker process
    Jul 14 15:44:45 node02 systemd[1]: Starting The nginx HTTP and reverse proxy server...
    Jul 14 15:44:45 node02 nginx[3308]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    Jul 14 15:44:45 node02 nginx[3308]: nginx: configuration file /etc/nginx/nginx.conf test is successful
    Jul 14 15:44:45 node02 systemd[1]: nginx.service: Failed to parse PID from file /run/ Invalid argument
    Jul 14 15:44:45 node02 systemd[1]: Started The nginx HTTP and reverse proxy server.
    * nginx.service - The nginx HTTP and reverse proxy server
       Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
      Drop-In: /usr/lib/systemd/system/nginx.service.d
       Active: inactive (dead)


SaltStack is a very useful orchestration tool that is widely used for automation of infrastructure and configuration management, just like Ansible.

The only difference is that it requires a master node to be setup and clients to connect to the node (Minions) for one to be able to manage their infrastructure. It is however much more easy to use as the commands are straight forward.

Check out more interesting articles on this site:

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here