Salt or SaltStack Tutorial

What is Salt or SaltStack?

SaltStack is a powerful and versatile configuration management tool that has gained popularity among organizations.

It offers a combination of push and pull features, making it a valuable addition to any organization’s configuration management needs.

SaltStack is an open-source configuration management tool with a remote execution engine.

It has a server and an agent, with a master as the server and minions as the nodes. SaltStack is a push-based configuration management tool, similar to Ansible, where the server pushes configuration onto the nodes.

However, in SaltStack, the agent runs on the nodes, allowing for a combination of push and pull communication.

Why to use SaltStack?

SaltStack, a configuration management tool that can be configured as either a node agent or an agent cluster configuration management tool.

The agent is responsible for running the configuration from the server, while the agent node is a small software installed on the server.

The difference between a puppet node and an agent node is that the agent runs the configuration taken from the server.

In SaltStack, the server and node can communicate through SSH protocol or API, with TCP IP communication being the preferred method. If SSH is not desired, there must be an API or protocol for communication between the server and node.

SaltStack can be configured to be an agentless configuration management tool, but by default, it has an agent running on all minions. This is how the SaltStack works.

The server puts information into the message queue, and the agent pulls the information from the message queue. If the agent is agentless, the information will be SSH into, copied into, or executed in the minion. For agentless configuration, SaltStack requires some configuration or tweaking.

SaltStack also offers Salt SSH, which provides an agentless system for management.

SaltStack Features

SaltStack offers several advantages over other tools, such as being easier to have a cluster of masters, good fault tolerance, fall stall tolerance, and the ability to connect salt minions to multiple masters at once.

SaltStack also allows for different types of configurations, such as agent servers, server-only configurations, and parallel execution.

SaltStack is based on the Python API, making it easier to set up compared to Chef and Puppet.

In addition to its flexibility, SaltStack provides a simple deployment model-driven configuration management and command execution framework.

It does not require learning any new programming language, and tasks are executed sequentially, similar to Ansible.

SaltStack Training

SaltStack Architecture

Salt architecture contains several components which includes the salt master, salt slaves, and salt minions.

It has two types of modules: execution modules and state modules.

Execution modules are used to execute modules in dark mode, while state modules are used to put modules inside a configuration file and execute them.

In Ansible, these modules are called package dot installed and package node installed, respectively. The name of the module changes depending on whether it is used for execution or state modules.

The salt master is a demon running on the server, which controls everything. Each minion has a unique ID generated at the time when connecting the minion to the Salt Master.

The minion receives the configuration from the server executed on the node and sends the report back to the Salt Master. The minions and the master open a TCP connection and must maintain this connection.

The next dumpster is an interface that provides information specific to a minion, such as Ohio facts. Greens is equal to the facts or output of a high command.

Pillar is a separate folder where variables are stored based on nodes, and when the node executes any formula or state file, it loads the data from the pillar folder.

The top five files in SaltStack are the top file, which defines what configuration should be executed on the nodes.

These files are similar to site.pp files and TOC files, and they define the data that is sent out to the node. State files are the heart of SaltStack, used to manage all resources and modules defined within the state file.

Few Concepts in SaltStack

The purpose of facts in Puppet and Chef is to provide information about nodes, CPU, operating system, memory, IP, and network details.

These facts are obtained from grains, which are modules located inside the Salt Master that perform tasks such as getting job status, connecting, status reading data from external APIs, and using salt minions.

Runners are modules that manage configuration on various nodes and check the status of nodes. They push data configuration to the node and check API connections.

Returners are small software programs or modules that send data back to the server after executing the configuration data.

Reactors are responsible for triggering events, such as successful installation or errors.

Salt Cloud is a module that allows the Salt Master to talk to an interface or talk to a node on the cloud. Salt SSH is another module used to set up an agentless architecture or configuration management tool.

SaltStack Training

SaltStack configuration

To create a simple SaltStack configuration, one can create a sample dot SLS file, which will end with the dot SLS. For example, the name of the package Wim is Wim, and the state of BIM is PKG dot installed. This is called the state state module or the state execution of a module, specifically Pavan.

To apply the SaltDot Apply command on the current machine, one must do sol star and then do state DOT apply. The SLS file name is Wim, and the path is Wim. Salt Dot Apply applies the application to the node, but it requires connecting nodes to the server.

To connect nodes to the server, one must use the SaltDot Apply command, which is different from the Puppet Apply command. Puppet Apply applies the application to the current machine, while Salt Dot Apply applies it to the node.

 How to set up a minion service?

Setting up a minion service is a simple process that requires a few steps. The Puppet Agent uses a salt key to generate and send keys to the server, and the minion agent uses a salt key to send the request to the specified host.

Importance of having a top dot SLS file

The top dot SLS file is structured as follows:

1. Environment name: The default environment for nginx configurations is the base environment.

2. Target: The name or regex to match minions.

3. Target: The environment, the target, and the list of state files.

4. SLS file: The SLS file name or folder name.importance of having a top dot SLS file within the salt folder to define formulas for different nodes.

SaltStack Course Price

Saniya
Saniya

Author

“Life Is An Experiment In Which You May Fail Or Succeed. Explore More, Expect Least.”