Salt stack configuration management
Configuration management is one of the most significant concepts in SaltStack. It is used to create a reusable configuration template, called a state. The state describes everything required to put a system component or an application into a known configuration.
Salt State
Salt state is a reusable configuration for a specific part of a system. States are easier to understand and described using a simple yaml.
Create a Salt State
Salt states are easy to create. Let us create a simple state, create a file named samples.sls and add the following lines in it.
#cat samples.sls
install_network_packages:
pkg.installed:
- pkgs:
- rsync
- lftp
- curl
save the file and run the following command
#salt ubuntu-01 state.apply samples.sls
Here, we installed rsync, lftp, and curl through the pkg.installed module using the Salt state in a salt-minion,
Apply Salt State
we have created a state using the ‘.sls’ file. Salt has a default state file called the top.sls file. The top file is used to apply multiple state files to Salt minions. The top file describes where states should be applied. Well, States and the Top file work together to create the core of SaltStack’s configuration management capability.
create a simple top.sls file in the directory saltstack/salt and add the following
#cat top.sls
base:
'*':
- common
'ubuntu-01':
- samples
Here, the state commonly applies to all system state, samples applies to minion ubuntu-01
Run the Salt master and apply the state as shown below
#salt '*' state.apply
Apply Batch Size
If we have a large number of connected minions, then you can limit how many systems are updated at once. It is performed by using the –batch-size option, which is defined below.
#salt --batch-size 5 '*' state.apply
Relevant Blogs:
AWS multi cloud configuration with vpn
Recent Comments
No comments
Leave a Comment
We will be happy to hear what you think about this post