Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2024
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.44 KB | None | 0 0
  1. pipeline {
  2.     agent { label 'DCEMA100TOL13-Ansible'}
  3.     environment {
  4.         PROJECT_FOLDER = "AnsiblePlaybook"
  5.         //SUDO_PASSWORD  = ""
  6.         //PLAYBOOK_NAME = "upgrade.yaml"
  7.         ANSIBLE_HOST_KEY_CHECKING = 'False'
  8.         ANSIBLE_SCP_IF_SSH = 'True'
  9.        
  10.  
  11.     }
  12.     stages {
  13.         /*stage('Build') {
  14.             steps {
  15.                 echo "Building.."
  16.                 sh '''
  17.                 pip3 install --break-system-packages  -r ${PROJECT_FOLDER}/requirements.txt
  18.                 '''
  19.             }
  20.         }*/
  21.         stage('Run') {
  22.             steps {
  23.                
  24.                 echo "Running"
  25.                 /*sh '''
  26.                 cd ${PROJECT_FOLDER}
  27.                 ansible myhosts -m ping -i inventory.ini --private-key=${SSH_KEY}
  28.                 '''*/        
  29.                 withCredentials([usernamePassword(credentialsId: env.Credentials, passwordVariable: 'SUDO_PASSWORD')]) {
  30.                     ansiblePlaybook colorized: false,
  31.                         credentialsId: Credentials,
  32.                         disableHostKeyChecking: true,
  33.                         inventory: "${PROJECT_FOLDER}/inventory.ini",
  34.                         playbook: "${PROJECT_FOLDER}/${Playbook_File}",
  35.                         extraVars: [ansible_become_pass: SUDO_PASSWORD]
  36.                 }
  37.             }
  38.         }
  39.     }
  40.     post {
  41.         always {
  42.             echo 'Finished'
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement