Automation and customization with Python’s Salt library – How Python Integrates with IaC Concepts

Automation and customization with Python’s Salt library

We talk about all of these fancy architectures and frameworks that we want to make; we talk about all of these different tools that we want to use, all of these workflows, and they are fun. They are very exciting, but the thing that a lot of DevOps still boils down to is server management; the Ops side of DevOps. It is still important and relevant in today’s world and will be for as long as people use it, which is likely forever.

Server management in the modern day requires the creation of modern, custom environments based on the requirements of the application being hosted. It also requires a lot of automation features to be maintained and to stay in an optimized state based on present circumstances.

The radio was never replaced by the television, and television in turn probably won’t be replaced by streaming completely. Everything changes, evolves, or reduces down, but the thing itself and the skills needed to use it will be relevant in one way or another. This is why the tools for server management will always be there and they will evolve.

That’s what the Salt library (used interchangeably with SaltStack) is used for. In essence, it consists of a central server that can be used to send commands to all servers connected to it. The requirements are that the minion (server to be managed) is configured to receive commands from the master (server that does the managing). It’s a pretty simple concept, executed using only the finest Python code.

So, let’s get into it. We will start with the installation of a Salt server and a minion, and then, we will see how we can customize the Python code that comprises Salt if needed.

The architecture of the Salt library consists of, as we said, a master and several minions. So, let’s start by creating servers that mirror this configuration:

  1. We will create one master server and a minion in GCP, and one minion in AWS to show cross-cloud functionality. For this exercise, we are using Ubuntu as our primary operating system (OS), but other OSs will work just as well. We will make a minion and a master Salt instance in GCP:

Figure 12.1 – Salt instances in GCP

2. We will also add a minion instance in AWS:

Figure 12.2 – Salt instance in AWS

3. Now, we can SSH into the salt-master instance and install the Salt master library:

sudo apt install salt-master

After this, you can run salt-master –version to run a check on the installation and get the version, similar to the following:

Figure 12.3 – Salt master version

  • Next, install the Salt minion library in both of the minion instances using the following command:

sudo apt install salt-minion

Then, run salt-minion –version in order to verify installation and get the version, similar to the following:

Figure 12.4 – Salt minion version

Ti Ja

Leave a Reply

Your email address will not be published. Required fields are marked *

Careers ,Privacy Policy ,Terms of Use, Copyright Policy ,Inclusion Statement, Accessibility, Site Map