Le Quotidien Shaarli

Tous les liens d'un jour sur une page.

05/26/2020

Note: Jenkins - Ansible : Une ligne pour pinger une VM

Le Jenkinsfile utilisé :

pipeline {

    agent {
        node { label 'With-Ansible' }
    }

    environment {
        VM_CREDENTIALS = credentials('my-vm-credentials')
        VM_USER = "${VM_CREDENTIALS_USR}"
        VM_KEY = "${VM_CREDENTIALS_PSW}"

        HOST_NAME = "my-vm-host"
    }

    stages {

        stage('PING MACHINE') {
            steps {
                script {
                    println " ========== PING ${HOST_NAME} ========== "
                    sh "ansible all -i ${HOST_NAME}, -m ping -u ${VM_USER} --extra-vars=\"ansible_ssh_pass=${VM_KEY} ansible_connection=ssh ansible_port='22' ansible_ssh_common_args='-o StrictHostKeyChecking=no'\""
                }
            }
        }

    }

}

Il faut laisser la virgule :)