Table of contents
1.
Introduction
2.
Basic Information
3.
Salt Masterless
3.1.
Use
4.
Set Up Salt Masterless
4.1.
Bootstrapping Salt Minion
4.1.1.
Script
4.2.
Instructing SALT to RUN MASTERLESS
4.2.1.
Script
4.3.
Create State Tree
4.4.
Salt Call
5.
Frequently Asked Questions
5.1.
What is Salt Minion?
5.2.
What is Salt Master?
5.3.
What is Salt State?
5.4.
What is the Advantage of SaltStack?
5.5.
Who uses SaltStack?
6.
Conclusion
Last Updated: Mar 27, 2024
Easy

About Salt Masterless

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Hey Ninja!! Today we will learn about the Salt Masterless. If you don’t know about SaltStack, don’t worry!! Let us give you some idea about SaltStack.

salt masterless

SaltStack is an open-source platform. Salt is a Python-based data center orchestration tool. It supports remote execution with a flexible targeting system. As you know what SaltStack is, here we will discuss Salt Masterless and how it works. Without any further delay, let's begin !!

Basic Information

Pillar in Salt

Pillars are Salt’s interface, which provides global values to salt minions.

State in Salt

The state is a reusable declaration to configure a specific system part.


Formula in Salt

Formulas are the collection of Salt states which other Salt users already write.


Salt Master

Salt master is a server that runs the remote execution commands. Salt master commands and controls its minions.

Salt Masterless

Running masterless salt-minion lets us use Salt's configuration management for a single machine. Without calling out to the Salt master on the other machine.

Salt minion can be useful to run it standalone as it contains such vast functionality.

Use

We can use a standalone minion to do several things:

  • Use the salt-call commands on a system without connectivity to a master.
  • Stand up a master server via States (that means Salting a Salt Master).
  • Masterless States run states entirely from files which are local to the minion.

Set Up Salt Masterless

steps

Bootstrapping Salt Minion

The salt-bootstrap script bootstraps a server with Salt simple for any Operating System with the Bourne shell (shell command-line interpreter for computer OS):

Script

curl -L https://bootstrap.saltstack.com -o install_salt.sh
sudo sh install_salt.sh

Instructing SALT to RUN MASTERLESS

To instruct the minion not to look for a salt master, the file_client configuration option needs to be set in the salt minion configuration file. By default, the file_client is set to remote so that the minion gathers pillar data and file server from the salt master. And if we set the file_client option to local, the minion will be configured not to gather this data from the salt master.

Script

file_client: local


Now the salt-minion will assume that the local system has all of the pillar resources, and the file won't look for a master.

Configuration resided in the master configuration (For example. /etc/salt/master) needs to be moved to the salt minion configuration since the minion does not read the master configuration.


Note - Do not run the salt-minion daemon when running Salt in masterless mode. Otherwise, it will fail while attempting to connect to a master. The salt-call command does not need the salt-minion daemon; it stands on its own.

Create State Tree

After we successfully install a salt-minion, our next step is to create a state tree, where the SLS files are stored that comprise the possible states of the minion.

1. Create the top.sls file:

/srv/salt/top.sls:

base:
  '*':
    - webserver


2. Create the webserver state tree:

/srv/salt/webserver.sls:

apache:  			# The ID declaration
  pkg:  			# The state declaration
    - installed 	# The function declaration


Note - The apache package has different names on the different platforms. For example, on Fedora/RHEL it is httpd, on Debian/Ubuntu it is apache2, and on Arch it is apache.

The only thing we are left with is to provision our minion using the salt-call.

Related Article Apache Server

Salt Call

We can use the salt-call command to run remote execution functions locally on the salt minion instead of executing them from the salt master. Usually, the salt-call command checks into the master to retrieve pillar data and file server, but when running a standalone salt-call needs to be instructed not to check the master for this data:

salt-call --local state.highstate 

The --local flag tells the salt-minion to searcg the state tree in the local file system instead of contacting a Salt Master for the instructions.


To provide verbose output, use -l debug:

salt-call --local state.highstate -l debug


The salt minion first checks the top.sls file and finds that it is a part of the group matched by the "*" glob and that webserver SLS should be applied.

It then checks the webserver.sls file and searches the apache state, which installs Apache package. The salt minion should now have the Apache installed, and the next step is to start learning how to write more complex states.

Frequently Asked Questions

What is Salt Minion?

Salt minions are the servers that run applications and services.

What is Salt Master?

Salt master is a server that runs the remote execution commands. Salt master commands and controls its minions.

What is Salt State?

The state is a reusable declaration to configure a specific system part.

What is the Advantage of SaltStack?

SaltStack can be set up in a tiered configuration to achieve load balancing and boast redundancy.

Who uses SaltStack?

Various organizations use SaltStack software to manage and protect digital business infrastructure at scale, including TD Bank, IBM Cloud, LinkedIn, eBay, Lego, First Data, Bloomberg, Adobe, Sanofi, and thousands more.

Conclusion

In this article, we discussed Salt Masterless. We learned how Salt minions run with the help of Salt Master, and then we learned how to run the Salt minion without Salt Master. We discussed making any Salt system masterless and learned about State Tree and salt-call. We stored the states in the local system and installed the apache package in the Salt Minion.

We hope this blog title was helpful. You can also refer to other similar articles.


You may refer to our Guided Path on Code Studios for enhancing your skill set on DSACompetitive ProgrammingSystem Design, etc. Check out essential interview questions, practice our available mock tests, look at the interview bundle for interview preparations, and so much more!

Happy Learning Ninja!

Live masterclass