Can’t afford Ansible Tower? Worried about AWX stability (Open Source Ansible Tower’s upstream Project )? Jenkins is more than enough to run the Ansible playbook from GUI. Ansible Tower’s main selling point is RBAC (Role based access control), credentials encryption and REST API. When you use Jenkins, it has plenty of plugins to offer role-based access control, in-built credentials encryption, and API support. In this article, we will walk through how to integrate ansible playbook in Jenkins and test it. At some point, I felt Jenkins is powerful enough on enterprise infrastructure automation.
Required Components on RHEL 7/Cent OS :
- Jenkins
- Ansible Engine
- Internet Connectivity
1. Download and install Jenkins on RHEL 7 /CentOS 7.
2. Download and install Ansible Engine on RHEL 7 / CentOS 7.
Installing and Configuring Ansible plugin for Jenkins:
3. Login to Jenkins portal as an administrator.
4. Search for Ansible plugin and install it.
Navigate to the global tool configuration.
You must update the ansible executable paths in Ansible plugin configuration like below.
Integrating Ansible Playbook in Jenkins Job:
5. Once the ansible plugin is installed, we are good to start creating the freeform style template to invoke ansible playbook.
6. Enter the job name. Here, my playbook will simply check the root filesystem usage on Linux hosts.
7. Update the valid description of the job and click on “Build”.
8. Select “Invoke Ansible Playbook” from “Add build step”.
9. Enter the playbook path and host inventory path. Add credentials if the playbook requires authentication via password.
10. Enter the credentials for ansible client nodes. (remote user)
11. Select the credentials which you have just added on the job and Save the job.
Testing the Jenkins Job:
12. From the job, click on Build to trigger the playbook.
13. When you click the job ID, you will be navigated to the following page.
14. Click on console output to see the Ansible playbook output.
We have successfully integrated ansible playbook in Jenkins. Hope this article is informative to you.
Share it! Comment it!! Be Sociable!!!
Gen Luna says
hi i followed the steps but it cannot find my playbook.
Lingeswaran R says
Ansible & Jenkins should be on same server.
Younes says
Hello,
My Ansible server is not in the same VM as Jenkins. So, how to configure Ansible plugin in Jenkins with the ip adress of the remote ansible server to established the ssh connection ?
Thank you
Lingeswaran R says
I see some challenges doing that. If possible, install ansible engine on jenkins server to make things simple.
Thank you
Lingesh