Site icon UnixArena

Ansible Engine – Run Playbook using Jenkins – GUI

Ansible - Jenkins logo - UnixArena

Ansible - Jenkins logo - UnixArena

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 :

 

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.

Install Ansible Plugin – Jenkins

 

Navigate to the global tool configuration.

Jenkins – Global Tool configuration – Ansible

 

You must update the ansible executable paths in Ansible plugin configuration like below.

Configure Ansible Engine path – Jenkins

 

 

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.

Jenkins – Freestyle project for Ansible integration

 

6. Enter the job name. Here, my playbook will simply check the root filesystem usage on Linux hosts.

Freestyle Jenkins Job Name – Ansible

 

7. Update the valid description of the job and click on “Build”.

Description of the Jenkins Job

 

8. Select “Invoke Ansible Playbook” from “Add build step”.

Jenkins Invoke Ansible Playbook

 

9. Enter the playbook path and host inventory path. Add credentials if the playbook requires authentication via password.

Ansible Playbook and Host Path – Jenkins

 

10. Enter the credentials for ansible client nodes.  (remote user)

Credentials – Jenkins

 

11. Select the credentials which you have just added on the job and Save the job.

Select the credentials for Ansible Play

 

 

Testing the Jenkins Job:

12. From the job, click on Build to trigger the playbook.

Build Jenkins Job – invoke Ansible playbook

 

13. When you click the job ID, you will be navigated to the following page.

Click on Build Job Number – Jenkins

 

14. Click on console output to see the Ansible playbook output.

Jenkins Build Job – Ansible console output

 

We have successfully integrated ansible playbook in Jenkins. Hope this article is informative to you.

Share it! Comment it!! Be Sociable!!!

Exit mobile version