Skip to content

Jenkins Ansible CI CD

ghdrako edited this page Dec 11, 2023 · 3 revisions

Integrate Ansible Playbooks with Jenkins

  1. First, you must install and configure the Ansible plugin for Jenkins to use Ansible inside the Jenkins pipeline job. Refer to the documentation at
  1. Then, you must install and configure Ansible and its required packages on the Jenkins server (or the Jenkins agent machine) as the Ansible playbook will be executed from the Jenkins machine.
  • Navigate to "Manage Jenkins" > "Global Tool Configuration."
  • Scroll down to the Ansible section and click "Add Ansible."
  • Provide a name for the configuration and the path to the Ansible installation.
  • Save the configuration.
  1. To trigger the Jenkins pipeline job, the build trigger must be configured on the Jenkins job

Once the Ansible plugin has been installed and configured, an Ansible playbook can be executed from the Jenkins server (or the agent) by calling it inside the pipeline stages.

pipeline {
  agent any
  stages {
    stage("Fetch Ansible content") {
      steps {
        git ""
      }
    }
    stage("Deploy application using Ansible") {
      steps {
        ansiblePlaybook credentialsId: 'private-key', disableHostKeyChecking: true, installation: 'Ansible', inventory: 'prod.inventory', playbook: 'deploy-web.yaml'
      }
    }
  }
}



Test

Clone this wiki locally