Site icon CentLinux

How to install Salt Minion on CentOS 8

Share on Social Media

Learn how to install Salt Minion on CentOS 8 with our detailed step-by-step guide. Simplify your configuration management and automate your infrastructure efficiently. #centlinux #linux #saltstack

What is Salt Minion?

Salt Minion is a component of the SaltStack infrastructure management platform, which is used for remote execution and configuration management of servers and devices. SaltStack, often referred to simply as Salt, operates on a master-minion architecture, where the Salt Master issues commands and the Salt Minions execute them. Here’s an overview of Salt Minion:

Key Features

How to install Salt Minion on CentOS 8

How Salt Minion Works

Architecture

Communication

State Management

Event-Driven Automation

Use Cases

Benefits

Summary

Salt Minion is a critical component of the SaltStack platform, enabling remote execution and configuration management for efficient and scalable infrastructure automation. By allowing centralized control over multiple systems, Salt Minion simplifies complex administrative tasks and ensures consistent system states across an organization’s IT infrastructure.

Recommended Training: Dive Into Ansible – Beginner to Expert in Ansible – DevOps

Environment Specification

We are setting up Salt Minion on a minimal CentOS 8 virtual machine that is optimized for efficiency and lightweight performance. This virtual machine is configured with the following specifications to ensure a stable and responsive environment for installation and operation. A minimal installation helps reduce resource consumption and improves security by including only the essential components required for running Salt Minion.

Update Linux Software Packages

Connect with saltstack-minion-01.centlinux.com as root user by using a ssh tool.

It is a best practice to update software packages on Linux operating system before installing anything new. Therefore, execute following dnf command to update all CentOS 8 software packages.

# dnf update -y

Install Python on CentOS 8

SaltStack is a Python-based automation and configuration management tool, which means it relies on Python to compile and execute its commands effectively. Since SaltStack is written in Python, having the correct Python version installed is essential for ensuring compatibility and proper functionality.

CentOS 8 and RHEL 8 include Python 3.6 in their default AppStream repository, making the installation process straightforward. We can easily install Python 3.6 and its dependencies using the dnf package manager with the following command:

# dnf install -y python3

This ensures that the required Python environment is set up before proceeding with the installation and configuration of SaltStack Minion.

Install SaltStack Yum Repository

Although SaltStack software packages are available via EPEL (Extra Packages for Enterprise Linux) yum repository.

But if you want to install the latest version of the software, then you have to install SaltStack official yum repository as follows.

# dnf install -y https://repo.saltstack.com/py3/redhat/salt-py3-repo-latest.el8.noarch.rpm

Build cache for newly installed yum repositories.

# dnf makecache
CentOS-8 - AppStream                            5.1 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                 8.8 kB/s | 3.9 kB     00:00
CentOS-8 - Extras                               2.2 kB/s | 1.5 kB     00:00
SaltStack Latest Release Channel Python 3 for R 132 kB/s | 224 kB     00:01
Metadata cache created.

Install Salt Minion on CentOS 8

We have added SaltStack official yum repository, now we can install SaltStack Minion by using the dnf command.

# dnf install -y salt-minion

Configure SaltStack Minion

Default configurations of SaltStack minion works fine, except that you need to tell the Minion about the Master server.

Therefore, edit SaltStack minion configuration file by using vim text editor.

# vi /etc/salt/minion

Locate following directive therein.

#master: salt

and replace the above directive with the following directive.

master: saltstack-master-01.centlinux.com

Where saltstack-master-01.centlinux.com is the SaltStack Master server that we have configured in our previous article. Please refer to How to install Salt Master on CentOS 8.

Enable and start salt-minion service.

# systemctl enable --now salt-minion
Created symlink /etc/systemd/system/multi-user.target.wants/salt-minion.service â /usr/lib/systemd/system/salt-minion.service.

Add SaltStack Minion to Master Server

Connect with saltstack-master-01.centlinux.com as root user by using PuTTY.

Display list of all public keys known to SaltStack master server.

# salt-key -L
Accepted Keys:
saltstack-master-01.centlinux.com
Denied Keys:
Unaccepted Keys:
saltstack-minion-01.centlinux.com
Rejected Keys:

You can see that, there is one unaccepted key i.e. saltstack-minion-01.centlinux.com. It is the public key of our SaltStack minion.

Accept this key by using following command.

# salt-key -A
The following keys are going to be accepted:
Unaccepted Keys:
saltstack-minion-01.centlinux.com
Proceed? [n/Y] Y
Key for minion saltstack-minion-01.centlinux.com accepted.

Remote Execution of commands on SaltStack Minion

Your Minion has been added in SaltStack Master inventory. You can now execute commands on this minion.

For demonstration, we are remotely installing Apache web server on saltstack-minion-01.centlinux.com.

# salt 'saltstack-minion-01.centlinux.com' cmd.run 'dnf install -y httpd'
Remote Command Execution on Salt Minion

Enable and start Apache service on saltstack-minion-01.

# salt 'saltstack-minion-01.centlinux.com' cmd.run 'systemctl enable --now httpd.service'
saltstack-minion-01.centlinux.com:
    Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service -> /usr/lib/systemd/system/httpd.service.

Allow http service in Linux firewall on saltstack-minion-01.

# salt 'saltstack-minion-01.centlinux.com' cmd.run 'firewall-cmd --add-service=http'
saltstack-minion-01.centlinux.com:
    success

Now, access the newly configured web server by using curl command.

# curl -I http://saltstack-minion-01.centlinux.com
HTTP/1.1 403 Forbidden
Date: Tue, 11 Aug 2020 19:25:57 GMT
Server: Apache/2.4.37 (centos)
Content-Location: index.html.zh-CN
Vary: negotiate,accept-language
TCN: choice
Last-Modified: Fri, 14 Jun 2019 03:37:43 GMT
ETag: "fa6-58b405e7d6fc0;5ac9f026acb21"
Accept-Ranges: bytes
Content-Length: 4006
Content-Type: text/html; charset=UTF-8
Content-Language: zh-cn

Apache web server has been installed and configured on your SaltStack minion.

Final Thoughts

Installing SaltStack Minion on CentOS 8 is a straightforward process that involves adding the SaltStack repository, installing the Minion package, and configuring it to communicate with the Salt Master. By following the steps outlined, you can successfully set up the Minion and integrate it into your SaltStack environment for centralized automation and configuration management.

After installation, ensure the Minion is properly configured by verifying its connection with the Salt Master and accepting its key. Once connected, you can start executing remote commands and managing your infrastructure efficiently using SaltStack’s powerful automation capabilities.

Need a dependable Linux system administrator? I specialize in managing, optimizing, and securing Linux servers to keep your operations running flawlessly. Check out my services on Fiverr!

FAQs

What is Salt Minion in SaltStack?
Salt Minion is an agent that runs on managed nodes and receives commands from the Salt Master for automation and configuration management.

How do I install Salt Minion on CentOS 8?
Add the SaltStack repository, install the salt-minion package using dnf, and start the service with systemctl enable --now salt-minion.

How do I configure Salt Minion to connect to the Salt Master?
Edit the Minion configuration file (/etc/salt/minion) and set the master parameter to the Salt Master’s hostname or IP address.

How do I verify that Salt Minion is connected to the Master?
On the Salt Master, run salt-key -L to check if the Minion’s key appears. Accept it using salt-key -A, then test with salt '*' test.ping.

What should I do if Salt Minion fails to connect to the Master?
Ensure network connectivity, verify firewall rules, check the Minion’s configuration, and restart the service using systemctl restart salt-minion.

Exit mobile version