Salt

How To Install Salt on Ubuntu 24.04 or Newer

Welcome back to the Greenhost.cloud blog! Today, we’re diving into the world of configuration management with Salt. Salt, also known as SaltStack, is a powerful tool that automates the management and configuration of servers and applications. Whether you’re managing a single server or thousands, Salt can help streamline your operations, improve consistency, and reduce manual errors.

In this post, we’ll walk you through the steps to install Salt on Ubuntu 24.04 or newer. Let’s get started!

Prerequisites

Before we begin, ensure that you have:

  1. A server running Ubuntu 24.04 or newer.
  2. A user account with sudo privileges.
  3. An active internet connection.

Step 1: Update Your System

It’s always a good idea to start with an updated system. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade -y

This will ensure that all your packages are up to date.

Step 2: Install Salt

Salt is available in the official Ubuntu repositories, but it’s often best to install the latest version directly from the SaltStack repository. Follow these steps:

2.1: Add the SaltStack Repository

First, you need to add SaltStack’s official repository. Run the following commands:

curl -fsSL https://repo.saltproject.io/py3/ubuntu/24.04/amd64/SALTSTACK-GPG-KEY.pub | sudo gpg --dearmor -o /usr/share/keyrings/salt.gpg
echo "deb [signed-by=/usr/share/keyrings/salt.gpg] https://repo.saltproject.io/py3/ubuntu/24.04/amd64/ focal main" | sudo tee /etc/apt/sources.list.d/saltstack.list

2.2: Update Package Index

After adding the repository, update your package index again:

sudo apt update

2.3: Install Salt Master and Minion

You can install both the Salt Master and Salt Minion (the client). If you only need the Salt Minion, you can install just that. For the full setup, run:

sudo apt install salt-master salt-minion -y

If you only want the Minion, use:

sudo apt install salt-minion -y

Step 3: Configure Salt

3.1: Configure the Salt Master

If you installed the Salt Master, you’ll need to configure it. Open the configuration file:

sudo nano /etc/salt/master

In this file, you can set various options. For a basic setup, you might not need to change anything, but you can customize settings like the file roots and the default backend.

3.2: Configure the Salt Minion

Next, configure the Minion. Open the Minion configuration file:

sudo nano /etc/salt/minion

Set the master setting to the hostname or IP address of your Salt Master:

master: <your_master_ip_or_hostname>

Replace <your_master_ip_or_hostname> with the actual IP address or hostname of your Salt Master.

Step 4: Start and Enable Salt Services

Now that everything is configured, start the Salt services and enable them to run at boot:

sudo systemctl start salt-master
sudo systemctl enable salt-master

sudo systemctl start salt-minion
sudo systemctl enable salt-minion

Step 5: Verify the Installation

To ensure that Salt is installed and running correctly, check the status of the services:

sudo systemctl status salt-master
sudo systemctl status salt-minion

You should see that both services are active and running.

Step 6: Testing the Setup

To test the setup, you can use the Salt command on the Master. First, ensure that the Minion has accepted the Master’s key. On the Master, run:

sudo salt-key -L

You should see the Minion listed as ‘unaccepted’. To accept it, run:

sudo salt-key -A

Now, you can send a test command to the Minion:

sudo salt '*' test.ping

If everything is set up correctly, the Minion should respond with True.

Conclusion

Congratulations! You’ve successfully installed Salt on Ubuntu 24.04 or newer. With Salt, you now have a powerful tool to manage your infrastructure efficiently. Explore its extensive capabilities, including remote execution, configuration management, and orchestration.

If you have any questions or need further assistance, feel free to reach out to us at Greenhost.cloud. Stay tuned for more tutorials and tips on managing your cloud infrastructure!

Happy automating!