Salt stack package deploying

Installing Package Through Single command
Setp1:Single Command & State File
We are going to install ‘netstat’ and ‘lsof’ commands from the salt-master using ‘Single command’.
First, execute the command
#salt ‘minion1‘ pkg.install net-tools
Then execute
#salt ‘minion1’ pkg.installed lsof

After installing/verifying on the ‘minion1’ client VM
#which netstat
#which lsof

step2:Installing Packages Through state file
A base environment is required to house the top file/state files, so we need to set the ‘file_roots’ in the salt-master configuration file (/etc/salt/master) and restart the salt-master service.Also we need to create directory ‘salt’ under ‘/srv’ ( /srv/salt )
Execute this command:
#cd /srv/
#mkdir salt

Restart the service using systemctl restart salt-master command

create ‘apache.sls’ under the /srv/salt, and lets check the contents,
#cat apache.sls
- name: httpd
apache: # ID declaration
pkg: # state declaration
– installed # function declaration

On the apache.sls, we have used ‘pkg.installed’ instead of ‘pkg.install’ for Apache installation. Pkg.installed in the state file will help us to ensure that the package is installed with the correct version. If the package is already available it shows ‘Package already installed and its version’ else it will perform the installation.

we can start the installation from salt-master using the below command.
#salt ‘minion1‘ state.sls apache

Once Apache is installed, we need to start the service.

Recent Comments

No comments

Leave a Comment