×
Deploying packages through SaltStack
Automation Blog

Deploying packages through SaltStack

Deploying packages through SaltStack:

This blog will helps you with step by step instruction to Deploying packages through SaltStack . There  are two ways to install packages.

1 -> Single Command & State File

INSTALLING PACKAGES THROUGH SINGLE COMMAND

  • First, execute the command salt ‘saltclient‘ pkg.install net-tools
  • In this demo, We are going to installing ‘netstat’ and ‘lsof’ commands from the salt-master using ‘Single command’.
  • Then execute salt ‘saltclient’ pkg.installed lsof
  • Before installing status:

Deploying packages through SaltStack:

  • Installing from salt-master:

Deploying packages through SaltStack:

  • After installing/verifying on the ‘saltclient’ VM:

Deploying packages through SaltStack:

2 -> 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
  • # vi /etc/salt/master

Deploying packages through SaltStack:

  • Restart the service using systemctl restart salt-master command
  • We have created ‘apache.sls’ under the /srv/salt, lets check the contents,

Deploying packages through SaltStack:

Syntax:

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 a correct version. If the package is already available it shows ‘Package already installed and its version’ else it will perform the installation.
  • Before executing the state file on our minion we need to verify status.

Deploying packages through SaltStack:

Deploying packages through SaltStack:

  • Well, we can start the installation from salt-master using below command.

       # salt ‘saltclient‘ state.sls apache

  • In meantime, we got the below result on the saltclient’s process using top command.

Deploying packages through SaltStack:

  • Installed result on salt-master:

Deploying packages through SaltStack:

Deploying packages through SaltStack:

  • After executing the state file on our minion:

Deploying packages through SaltStack:

  • Once Apache installed, we need to start the service.
  • We are going to trigger the state file ( apache.sls ) on the minion again to check the pkg.installed function’s result if the pkg already installed on the target/minion.

Deploying packages through SaltStack:

Thanks for visiting this article. We hope it will be useful for your to install the packages through SALT application.

One thought on “Deploying packages through SaltStack”

  1. Hi Ranjithkumar, this is Ravi.

    I need support on saltstack can u help me on that.

    Regards
    Ravi
    9164369075

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.