Do you think IIT Guwahati certified course can help you in your career?
No
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.
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
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.
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.