How to Install SaltStack IT Automation Framework on Debian 12 (2024)

This tutorial exists for these OS versions

  • Debian 12 (Bookworm)
  • Debian 11 (Bullseye)

On this page

  1. Prerequisites
  2. Setup /etc/hosts file
  3. Adding SaltStack repository
  4. Setting up UFW
  5. Installing Salt Master
  6. Installing Salt Minion
  7. Adding Salt Minion to Salt Master
  8. Running arbitrary command via SaltStack
  9. Creating Salt State for LAMP Stack installation
  10. Conclusion

Salt or Saltstack is an open-source IT automation framework written in Python. It allows administrators to execute commands remotely to multiple machines directly.

Salt is designed with Master and Minion architecture. Salt master is the central controller of Salt configuration management, and Minions are servers managed by Salt master, or you named minions as target servers.

This guide'll show you how to install SaltStack on Debian 12 servers. We'll show you how to install Salt Master and Minion, how to run arbitrary commands via Salt, and then create the first Salt state for installing LAMP Stack.

Prerequisites

Before you start, make sure you have the following:

  • Two or three Debian 12 servers - In this example, we'll be using master server on 192.168.5.15 and the minion1 server on 192.168.5.21.
  • A non-root user with administrator privileges.

Setup /etc/hosts file

In this section, you will set up the /etc/hosts file so each server can connect via hostname, which is easier than using an IP address.

Open the /etc/hosts file using the following nano editor.

sudo nano /etc/hosts

Insert details host and IP address into the file. Make sure to change the IP addresses and hostnames with your information.

192.168.5.15 master
192.168.5.21 minion1

Save and exit the file when done.

Adding SaltStack repository

After setting up the/etc/hosts file, you must add the SaltStack repository to all of your Debian servers. The SaltStack provides an official repository for most Linux distributions, including the latest Debian 12.

First, create a new directory /etc/apt/keyrings using the command below.

mkdir /etc/apt/keyrings

Download the GPG key for the SaltStack repository with the command below.

sudo curl -fsSL -o /etc/apt/keyrings/salt-archive-keyring-2023.gpg https://repo.saltproject.io/salt/py3/debian/12/amd64/SALT-PROJECT-GPG-PUBKEY-2023.gpg

Once the GPG key is downloaded, add the SaltStack repository using the following command.

echo "deb [signed-by=/etc/apt/keyrings/salt-archive-keyring-2023.gpg arch=amd64] https://repo.saltproject.io/salt/py3/debian/12/amd64/latest bookworm main" | sudo tee /etc/apt/sources.list.d/salt.list

Now update and refresh your Debian package index.

sudo apt update

You can see below the SaltStack repository added to Debian servers.

Setting up UFW

In this example, you will set up and enable UFW (Uncomplicated Firewall) across your Debian servers. So you'll install UFW, open the SSH port, then start and enable UFW.

Install UFW on your Debian system using the command below.

sudo apt install ufw -y

Once UFW is installed, execute the following command to enable the OpenSSH application profile. You will see output Rules added.

sudo ufw allow OpenSSH

Now enable UFW using the command below. Enter y to confirm, start, and enable UFW.

sudo ufw enable

You will get an output 'Firewall is active ...' once UFW is started and enabled.

Installing Salt Master

After you have completed tasks on top, you're ready to install SaltStack. You will install and configure the Salt Master on the master server.

On the master server, run the command below to install the salt-master package. Input Y to confirm with the installation.

sudo apt install salt-master

After installation is finished, open the default Salt Master configuration /etc/salt/master using the nano editor command below.

sudo nano /etc/salt/master

Change the default interface with your local IP address. In this example, the master server IP address at 192.168.5.15.

interface: 192.168.5.15

Save the file and exit when finished.

Now run the command below to restart the salt-master service and apply your changes.

sudo systemctl restart salt-master

Then verify the salt-master service to ensure that the service is running.

sudo systemctl status salt-master

If running, you will see an output such as active (running).

Next, run the command below to open TCP ports 4505 and 4506 which Salt Master will use.

sudo ufw allow 4505,4506/tcp

Lastly, check the list of ports in your master server using the command below. Make sure access to ports 4505 and 4506 is allowed.

sudo ufw status

Installing Salt Minion

Now that you have configured Salt Master move on to configure Salt Manion on the minion1 server. You will install salt-minion and then configure it to connect to the Salt Master server.

Install the salt-minion package to the minion1 server using the command below. Input Y to confirm the installation.

sudo apt install salt-minion

Once the installation is finished, open the Salt Minion configuration /etc/salt/minion using the nano editor command.

sudo nano /etc/salt/minion

Input your Salt Master IP address to the master parameter like the following:

master: 192.168.5.15

save the file and exit the editor.

Next, run the command below to restart the salt-minion service and apply your changes.

sudo systemctl restart salt-minion

Lastly, verify the salt-minion service to ensure that the service is running. The Salt Minion will automatically register to the Salt Master server.

sudo systemctl status salt-minion

Make sure the salt-minion service is running like the following:

Adding Salt Minion to Salt Master

After configuring Salt Minion, you still need to accept the registration key from the Minion servers.

First, run the command below to verify the list key on the master server.

salt-key --finger-all

If everything goes well, you can see the key for the minion1 server or Salt Minion servers.

Now run the command below to accept the key for the minion1 server. Input Y to confirm and accept the key.

salt-key -a minion1

Next, verify again the list key on the minion1 server. You will see the key for the minion1 server listed in the Accepted Keys section.

salt-key --finger-all

Now you can test the connection to the Salt Minion server using the command. you can specify the target server with the hostname, or you can use the '*' character to target all available Salt Minion servers.

salt minion1 test.ping
salt * test.ping

If the connection to Salt Minion is successful, you will see an output 'True'.

Lastly, verify the Salt version using the command below.

salt minion1 test.version

In this example, the Salt Minion 3007.0 is installed.

Running arbitrary command via SaltStack

With everything configured, you will test your SaltStack installation by running the arbitrary command on the minion1 server from the master server.

Run the command below to update the repository package index for Minion servers.

salt '*' pkg.refresh_db

Now run the command below to package updates on the target server.

salt '*' pkg.list_upgrades

Next, run the following command to show information about the apache2 package.

salt '*' pkg.show apache2

To check running services on the Minion server, run the command below.

salt '*' service.get_running
salt '*' service.execs

Creating Salt State for LAMP Stack installation

In this section, you will learn how to create the first SaltState for installing LAMP Stack (Apache, MariaDB, and PHP) to the minion1 server.

First, create a new directory /srv/salt/lamp using the command below.

mkdir -p /srv/salt/lamp

Now create a new Salt state init file /srv/salt/lamp/init.sls using the following nano editor.

nano /srv/salt/lamp/init.sls

Add the configuration below to the file. With this, you will install LAMP Stack (Apache, MariaDB, and PHP) on the target server.

lamp_stack:
pkg.installed:
- pkgs:
- apache2
- mariadb-server
- php
- libapache2-mod-php

apache2:
service.running:
- enable: True
- reload: True

mariadb:
service.running:
- enable: True
- reload: True

Save the file and exit.

Now run the command below to verify your Salt state configuration against Salt Minion. Make sure you don't have any errors.

sudo salt * state.show_sls lamp

Next, run the command below to apply the Salt state 'lamp' to the minion1 server.

sudo salt minion1 state.apply lamp

When the process complete, you will get the following output:

Lastly, run the command below to verify Apache and MariaDB services on the minion1 server.

salt '*' service.get_running

Make sure both apache2 and mariadb services are running.

Conclusion

Congratulations! You have completed the installation of SaltStack (Salt Master and Minion) on Debian 12 servers. You also learned how to run the arbitrary command against Minion servers and created the first Salt state for installing LAMP Stack (Apache2, MariaDB, and PHP).

How to Install SaltStack IT Automation Framework on Debian 12 (2024)

FAQs

How to Install SaltStack IT Automation Framework on Debian 12? ›

You can post . sls files, scripts, configuration files and files that you may want to distribute to minions. You can also create them in a variety of scripting languages such as YAML, python, json etc. These files can be accessed via jobs or ad-hoc commands from within SaltStack Config.

How to install salt minion on Debian 12? ›

Install Salt on Debian 12 (Bookworm) arm64
  1. Run sudo apt-get update to update your packages.
  2. sudo apt-get install salt-master sudo apt-get install salt-minion sudo apt-get install salt-ssh sudo apt-get install salt-syndic sudo apt-get install salt-cloud sudo apt-get install salt-api.

How do I install and configure SaltStack? ›

  1. Install the license key.
  2. Install and configure the Master Plugin.
  3. Check the RaaS configuration file.
  4. Log in for the first time and change default credentials.
  5. Accept the Salt master key and back up data.
  6. Set up SSL certificates.
  7. Set up Single Sign-On (SSO)
  8. Configure SaltStack SecOps.
Feb 3, 2023

How to install stuff on Debian? ›

Run sudo apt-get install packageName to install the package.
  1. If additional dependencies are required for the package to install, follow the on-screen instructions to choose whether to install them now.
  2. To remove an installed package, use sudo apt-get remove packageName . X Research source
Nov 26, 2023

What scripting languages does SaltStack config use? ›

You can post . sls files, scripts, configuration files and files that you may want to distribute to minions. You can also create them in a variety of scripting languages such as YAML, python, json etc. These files can be accessed via jobs or ad-hoc commands from within SaltStack Config.

How to check if Salt is installed? ›

The final step in the Salt installation process is to verify that the installation was successful by sending a test ping from the Salt master to the connected Salt minions.

How to install configure in Linux? ›

Configure Linux
  1. Verify the root User Path.
  2. Enable the Linux Firewall iptables.
  3. Disable SELinux.
  4. Remove SELinux Permissions.
  5. Set Up the Network Proxy.
  6. Setup yum (optional)
  7. Install Required Linux Packages.
  8. Setup SSH.

How to install custom kernel in Debian? ›

Options include thumb drives that you mount or on web servers that you access with wget. At the end of the installation process, after the GRUB install but before reboot, open a virtual terminal, get the kernel deb, chroot into /target, and install the kernel deb manually with dpkg -i. Finally, reboot.

How to install Gnome shell on Debian? ›

Installing GNOME Desktop in Debian using tasksel
  1. Launch a terminal window. Employ the keyboard shortcut Ctrl+Alt+T to open a terminal window.
  2. Update package lists. Before installing any software, it's crucial to ensure your package lists are up-to-date. ...
  3. Install GNOME desktop environment.
Mar 13, 2024

How to install aptitude in Debian 11? ›

In Debian-based distributions like Ubuntu, you can install 'aptitude' by running the command sudo apt-get install aptitude . For using it, a simple command would be sudo aptitude install [package-name] . sudo apt-get update sudo apt-get install aptitude sudo aptitude install nano # Output: # Reading package lists...

How to install Angular in Debian 11? ›

Follow the steps below to get Angular up and running on your system:
  1. Step 1: Install Node. js and npm.
  2. Step 2: Install Angular CLI Globally.
  3. Step 3: Run Angular CLI Commands.
  4. Step 4: Create an Initial Workspace for the Application.
  5. Step 5: Run the Angular Application in Your Browser.
Dec 1, 2023

References

Top Articles
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 5863

Rating: 4.9 / 5 (69 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.