Operations 4 min read

Installing SaltStack and Integrating with Jenkins for Automated Deployment

This guide walks through installing SaltStack components (salt‑master, salt‑minion, and salt‑api) on CentOS, configuring them, testing the API, and then integrating SaltStack with Jenkins by creating Jenkinsfiles that invoke Salt commands via the API or direct CLI for automated deployments.

DevOps Cloud Academy
DevOps Cloud Academy
DevOps Cloud Academy
Installing SaltStack and Integrating with Jenkins for Automated Deployment

1. Install SaltStack

For detailed SaltStack principles, refer to the official SaltStack documentation.

1.1 Install salt-master (Jenkins)

yum -y install salt-master
service salt-master start
chkconfig salt-master on

1.2 Install salt-minion (application deployment machines)

yum -y install salt-minion
service salt-minion start
chkconfig salt-minion on

# Edit /etc/salt/minion to set the master address
master: 192.168.0.41

# Authenticate the client on the master node
salt-key -L
salt-key -a clientName

1.3 Install salt-api (Jenkins)

yum -y install salt-api
service salt-api start
chkconfig salt-api on

# Add a system user for API operations
useradd saltapi
passwd saltapi

# Edit /etc/salt/master
file_roots:    # allow Salt to serve files
  base:
    - /srv/salt
rest_cherrypy:  # salt-api configuration
  port: 9000
  disable_ssl: True
  debug: True
external_auth:
  pam:
    saltapi:
      - .*
      - '@wheel'
      - '@runner'

service salt-master restart
service salt-api start

1.4 Test

curl http://127.0.0.1:9000/login -d username='saltapi' -d password='123456' -d eauth='pam'

If a token is returned, the test succeeded.

2. Integrate Jenkins

2.1 Test Salt (saltapi method)

Install the SaltStack plugin in Jenkins.

Generate a Jenkinsfile via Project → Pipeline Syntax → Snippet Generator.

Jenkinsfile example:

#!groovy

// Build parameters
String targetHosts = "${env.targetHosts}"

// Salt API template
def Salt(salthost, saltfunc, saltargs) {
    result = salt(authtype: 'pam',
                clientInterface: local(arguments: saltargs,
                                        function: saltfunc,
                                        target: salthost,
                                        targettype: 'list'),
                credentialsId: "f89abde3-49f0-4b75-917e-c4e49c483f4f",
                servername: "http://0.0.0.0:9000")
    println(result)
    PrintMes(result,'blue')
    return result
}

node("master") {
    stage("Deploy") {
        Salt("${targetHosts}", "cmd.run", "ls")
    }
}

2.2 Test Salt (command method)

Jenkinsfile:

node {
   stage("Deploy") {
       sh "salt * test.ping"
   }
}

Build the pipeline to verify the Salt command execution.

automationconfiguration managementDevOpsJenkinsSaltStack
DevOps Cloud Academy
Written by

DevOps Cloud Academy

Exploring industry DevOps practices and technical expertise.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.