Skip to content

Instantly share code, notes, and snippets.

@farahfa
Created June 27, 2017 05:25
Show Gist options
  • Save farahfa/0fc1751fdd27ae8b0f037cba21530452 to your computer and use it in GitHub Desktop.
Save farahfa/0fc1751fdd27ae8b0f037cba21530452 to your computer and use it in GitHub Desktop.
Ansible jenkins pipeline 2
stage( 'Switch to master' ) {
agent {
node {
label 'ansible'
}
}
when {
environment name: "SERVER", value: "master"
}
steps {
withEnv(["INSTANCE_ID_TO_REGISTER=${env.JENKINS_MASTER_ID}", "INSTANCE_ID_TO_DEREGISTER=${env.JENKINS_BACKUP_ID}"]) {
ansiblePlaybook("${env.WORKSPACE}/switch.yml") {
forks(5) //Equivalent to 'Number of parallel processes'
unbufferedOutput(true)
hostKeyChecking(false)
additionalParameters("-e 'ansible_python_interpreter=/usr/bin/python2.7' -c paramiko")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment