Qadry
unixcop Admin

How to Install SaltStack Minion on CentOS 8/ RHEL 8

Introduction

Salt (sometimes referred to as SaltStack) is Python-based, open-source software for event-driven IT automation, remote task execution, and configuration management. Supporting the “infrastructure as code” approach to data center system and network deployment and management, configuration automation, SecOps orchestration, vulnerability remediation, and hybrid cloud control.

SaltStack minion is the agent software that is installed on the managed node.

Used to execute and run the commands on that node and report back to SaltStack master server.

Kindly visit this installation guide below to get_started with installation of Saltstack master.

So in this tutorial, we will show you how to install and configure the saltstack minion and executing the commands from master to the minions on your CentOS & RHEL 8.

Installation

Just follow the steps and Notes below

  • Update your system
dnf update -y
  • SaltStack requires Python language support for compilation and execution of SaltStack commands. So Install Python3
dnf install python3 -y
  • Install SaltStack which is available via EPEL yum repo.
dnf install https://repo.saltstack.com/py3/redhat/salt-py3-repo-latest.el8.noarch.rpm -y
  • Then build the cache for the new repo added.
dnf makecache
  • Then Install SaltStack Minion.
dnf install salt-minion -y

Configuration

  • You need to adjust SaltStack Minion configurations before starting the service.
vim /etc/salt/minion
  • Search on this directive
#master: salt
  • Then replace it with following.
master: saltstack-master.unixcop.com

Note: Where saltstack-master.unixcop.com is the SaltStack Master server that we have configured in Installing Saltstack master article.

Note: Also The SaltStack minion hostname must be resolvable on saltstack master server . So do this by using Local DNS Resolver by modifying the IP of minion server and its hostname in /etc/hosts file on the master server as shown.

  • Enable and start salt-minion.
systemctl enable --now salt-minion
  • Go to Saltstack-Master Server then list all of the public keys known to SaltStack master server.
salt-key -L

Note: You can see that there is one unaccepted key which is the client(this is the hostname of my saltstack-Minion server). It is the public key of our SaltStack minion.

  • Accept this key.
salt-key -A
  • So your Minion has been added in SaltStack Master inventory as shown in the screenshot below.
  • You can now execute commands on this minion Server.

Executing commands on SaltStack Minion

  • For example: To install nginx web service and enable it on Salt minion server.
salt 'client' cmd.run 'dnf install nginx -y'
OR
salt 'saltstack-minion.unixcop.com' cmd.run 'dnf install nginx -y'
salt 'client' cmd.run 'systemctl enable --now nginx.service'
OR
salt 'saltstack-minion.unixcop.com' cmd.run 'systemctl enable --now nginx.service'
  • Also you can check and verify that nginx has been installed in the minion server before and after adding it in the Saltstack-master server as shown.

Before

After

  • Also access the new web server by using curl.
curl -I 192.168.13.140       #the ip of minion server
OR
curl -I http://saltstack-minion-unixcop.com

Conclusion

In this tutorial, we illustrated how to install and configure SaltStack Minion on CentOS / RHEL 8 server and remotely execute commands after adding the minion Public ip to the salt-master server.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

x