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

  • Remote Execution: Allows the Salt Master to execute commands on Salt Minions, enabling administrators to perform tasks across multiple systems simultaneously.
  • Configuration Management: Facilitates the automation of configuration management by ensuring that systems maintain a specified state defined by Salt States (SLS files).
  • Real-Time Communication: Uses a high-speed, bi-directional communication channel (ZeroMQ or TCP) between the master and minions for real-time interaction.
  • Scalability: Designed to manage thousands of nodes efficiently, making it suitable for large-scale infrastructure.
  • Flexibility and Extensibility: Supports a wide range of modules for different tasks, such as package management, service management, and user management. Extensible with custom modules to suit specific needs.

How Salt Minion Works

Architecture

  • Salt Master: Central controller that manages Salt Minions, sends commands, and receives data.
  • Salt Minion: Agent installed on each managed system that receives and executes commands from the master.

Communication

  • The Salt Minion establishes a connection with the Salt Master, allowing the master to push configurations and commands to the minion.
  • Communication is secured using cryptographic keys to ensure data integrity and confidentiality.

State Management

  • Salt Minions apply configurations defined in Salt State files, ensuring that each system matches the desired state.
  • State files use YAML to define configuration states, making them easy to read and write.

Event-Driven Automation

  • Minions can generate events based on specific conditions, triggering automated responses from the master.

Use Cases

  • System Administration: Automates routine administrative tasks, such as software installation, updates, and system monitoring.
  • Configuration Enforcement: Ensures that systems comply with specified configurations, automatically correcting deviations.
  • Orchestration: Manages complex deployments and workflows by coordinating tasks across multiple systems.
  • Monitoring and Reporting: Collects data from minions for monitoring purposes and generates reports on system states and compliance.

Benefits

  • Efficiency: Streamlines system management, reducing the time and effort required to maintain large-scale infrastructures.
  • Consistency: Ensures uniform configurations across all managed systems, reducing the risk of configuration drift.
  • Scalability: Capable of managing thousands of systems, making it suitable for enterprise environments.
  • Flexibility: Adaptable to various environments and use cases with support for custom modules and extensible features.

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 Online Training: SaltStack for the Absolute Beginners – Practical DevOps

5808644 ea29 2show?id=oLRJ54lcVEg&offerid=1074530.5808644&bids=1074530

Environment Specification

We are using a minimal CentOS 8 virtual machine with following specification.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – CentOS Linux 8.2
  • Hostname โ€“ saltstack-minion-01.centlinux.com
  • IP Address – 192.168.116.228 /24

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 Python-based software, therefore it requires Python language support to compile and execute SaltStack commands.

Python 3.6 is available in default CentOS / RHEL 8 AppStream, therefore, we can easily install it by using dnf command.

# dnf install -y python3

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
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

In this article, you have learned, how to install SaltStack Minion on CentOS 8 server and remotely execute commands on it. Before you start to use SaltStack, we strongly recommend you to purchase and read Mastering SaltStack – Second Edition (PAID LINK) by Joseph Hall. This book will guide you about the Saltstack architecture, basic concepts and practical examples.

Leave a Reply