Skip to content

Commit

Permalink
Use Ansible Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ikambarov committed Jan 14, 2022
1 parent 54b469e commit e26b843
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions Oct-2021/flaskex.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ properties([
])
])

node {
stage("Pull Ansible Repo"){
git 'https://github.com/ikambarov/ansible-Flaskex.git'
}

stage("Run Ansible"){
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-master-key', keyFileVariable: 'SSH_KEY', usernameVariable: 'SSH_USER')]) {
withEnv(['FLASKEX_REPO=https://github.com/ikambarov/Flaskex.git', 'FLASKEX_BRANCH=master']) {
sh """
export ANSIBLE_HOST_KEY_CHECKING=False
ansible-playbook --private-key $SSH_KEY -i '${params.HOSTIP},' main.yml -u $SSH_USER
"""
if( params.HOSTIP.length() >= 7 ) {
node {
stage("Pull Ansible Repo"){
git 'https://github.com/ikambarov/ansible-Flaskex.git'
}

stage("Run Ansible"){
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-master-key', keyFileVariable: 'SSH_KEY', usernameVariable: 'SSH_USER')]) {
withEnv(['FLASKEX_REPO=https://github.com/ikambarov/Flaskex.git', 'FLASKEX_BRANCH=master']) {
ansiblePlaybook credentialsId: 'jenkins-master-key', disableHostKeyChecking: true, inventory: "${params.HOSTIP},", playbook: 'main.yml'
}
}
}
}
}
}
else {
error 'Please enter valid IP'
}

0 comments on commit e26b843

Please sign in to comment.