Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pipeline {
- agent { label 'DCEMA100TOL13-Ansible'}
- environment {
- PROJECT_FOLDER = "AnsiblePlaybook"
- //SUDO_PASSWORD = ""
- //PLAYBOOK_NAME = "upgrade.yaml"
- ANSIBLE_HOST_KEY_CHECKING = 'False'
- ANSIBLE_SCP_IF_SSH = 'True'
- }
- stages {
- /*stage('Build') {
- steps {
- echo "Building.."
- sh '''
- pip3 install --break-system-packages -r ${PROJECT_FOLDER}/requirements.txt
- '''
- }
- }*/
- stage('Run') {
- steps {
- echo "Running"
- /*sh '''
- cd ${PROJECT_FOLDER}
- ansible myhosts -m ping -i inventory.ini --private-key=${SSH_KEY}
- '''*/
- withCredentials([usernamePassword(credentialsId: env.Credentials, passwordVariable: 'SUDO_PASSWORD')]) {
- ansiblePlaybook colorized: false,
- credentialsId: Credentials,
- disableHostKeyChecking: true,
- inventory: "${PROJECT_FOLDER}/inventory.ini",
- playbook: "${PROJECT_FOLDER}/${Playbook_File}",
- extraVars: [ansible_become_pass: SUDO_PASSWORD]
- }
- }
- }
- }
- post {
- always {
- echo 'Finished'
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement