After SaltStack came with concept of SALT, many of you may be thinking on how you can configure SALT. If you are an IT Administrator handling Linux Server, this blog will help you keep posted. Here, I have updated necessary concepts that would pep up your memory making it easier. Now, let’s start with some SaltStack tutorial basics... Before we go into in depth knowledge, let us first understand SALT
EditSalt Formulas installation and usage instructions
What is SaltStack?
- To make it easier, I am explaining SALT in form of points:
- It is multi OS provisioning and maintenance system.
- It gets all software and configuration into brand new servers automatically.
- It saves time in setting up new server isn’t really good for people like us i.e. IT or Administrator.
- It also standardized what is install on each server.
- You can also automate other common tasks. Some of tasks include updating the server software, running back up scripts; etc
- As of today SALT can be installed on variety of Linux or Unix OS
Basic Components of SaltStack :
- Master and Minions: Master is the SALT server and MINIONS are the target machines. Each Minions will be having Unique IDS assigned. The best part of SALT is that the firewall configuration of Minions. It hardly get to change as Master and does not connect to Minions. Yet its Minions which are open support TCP connection.
- Keys: An important reason for which Linux Machine is known for SECURITY. The component of SALT provides security by generating an asymmetric cryptography key. When approved by master before connecting or working with commands send by minions.
- States: It is the main part of any SALT. It specifies things should be done in certain way only. States are stored on master and passed to minions where they are parsed.
- Grains: They are stored on each minions. It generally holds the OS and Hardware specific information to that minions.
- Pillar: They are optional and stored on master. They are passed to minions which is then parsed when its information is needed. Pillars are usually used to store sensitive data like password, username, etc. Sometimes minion configuration and some variables areo als stored.
EditHow each components are put together?
EditNow we will be moving towards how to create your first SALT Formula:
As we know, it is an 100% open source configuration management, a remote execution tool. It is easy enough to get running within fraction of seconds. They are scalable enough to manage thousands of servers. It is also fast enough to communicate within seconds.
The company which is delivering SALT is SaltStack. Its features are released under the Apache 2.0 license.
EditBefore going forward let us assume the following:
- Hope you know how to install Salt on Ubuntu
- You are already logged in as default root user
We assume that your server name is minion1. Here if you find minion1 then replace your server names. The same can be found by salt-key –L
Now from the first word we are going about knowing
What SALT Formula is?
How to create SALT Formulas?SALT Formulas are simple yaml text files and it resides on your SALT Master in /srv/salt. Going forward we will now take different example with vim, apache web server to install Now we will be creating SALT Formula to make sure that vim is installed
Now add following text to your vim.sls
Vim: (This is ID Declaration. Vim will be used as package name)
Pkg: (This is for state declaration i.e. which state we will be using)
- Installed (Function declaration, it refers to the name of function inside the state module)
Now to apply the state to our server use below command
salt minion1 state.sls vim
In Next example we will be installing Apache server now and create a file name as webserver.sls
Now add following to your webserver.sls
Did you notice in above example the pkgs ? It will pass all the argument together to your OS’s package manager to be installed. It means that only one call to apt or yum will seem to install all those packages one after the other. This is most practical way to install the packages if you have list of packages to install on your OS
Now again apply this formula to your master server
salt ‘minion1’ state.sls webserver
Last but not least we will take now example of installing git, now you must be confident about how to install git here
The contents for git will be as follow
And again to apply the new config execute below command
salt ‘minion1’ state.sls git
Isn’t it easy to create your first salt formula yeah but needs practice on the same. So first we give information about different components on how SALT is installed. First we will construct the idea of how to create your first SALT Formula clear. Then you can easily create the same at any point. This is why the important part was included in the beginning of this article. Hope this makes the concepts clear with SALT thus making it easy then.
Till now we have learned about salt and its different components. We have also known on :
- How we will be creating those sls files for the Apache and vim?
- How we will attaching with the master server state?
- and now in last part we will see the usage of “highstate” concept.The highstate concept: It aids Salt to dynamically decide which Formula is to be assigned on which minion. In order to execute that please use below command:
salt ‘minion1’ state.highstateThe above command aids the Minion to download and check the file from the salt master is called top file. By default it is found from /srv/salt/top.sls When minion is told to execute highstate it will search for matching salt formula and execute the same Now as we have reached the end of the session, i hope you have updated your knowledge on SALT. We have covered the topics of :
- Creating your first SALT Formula
- Understanding the basic components
- How to deploy the state for Master
- Use of highstate which state the MinionsIf you have captured the essence of SALT, then it will give an impact in developing more knowledge. Stay connected for more updates on SALT