Quantcast
Viewing all articles
Browse latest Browse all 370

Ansible Engine – Run Playbook using Jenkins – GUI

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.

Image may be NSFW.
Clik here to view.
Install Ansible Plugin - Jenkins
Install Ansible Plugin – Jenkins

 

Navigate to the global tool configuration.

Image may be NSFW.
Clik here to view.
Jenkins - Global Tool configuration - Ansible
Jenkins – Global Tool configuration – Ansible

 

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

Image may be NSFW.
Clik here to view.
Configure Ansible Engine path - Jenkins
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.

Image may be NSFW.
Clik here to view.
Jenkins - Freestyle project for Ansible integration
Jenkins – Freestyle project for Ansible integration

 

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

Image may be NSFW.
Clik here to view.
Freestyle Jenkins Job Name - Ansible
Freestyle Jenkins Job Name – Ansible

 

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

Image may be NSFW.
Clik here to view.
Description of the Jenkins Job
Description of the Jenkins Job

 

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

Image may be NSFW.
Clik here to view.
Jenkins Invoke Ansible Playbook
Jenkins Invoke Ansible Playbook

 

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

Image may be NSFW.
Clik here to view.
Ansible Playbook and Host Path - Jenkins
Ansible Playbook and Host Path – Jenkins

 

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

Image may be NSFW.
Clik here to view.
Credentials - Jenkins
Credentials – Jenkins

 

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

Image may be NSFW.
Clik here to view.
Select the credentials for Ansible Play
Select the credentials for Ansible Play

 

 

Testing the Jenkins Job:

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

Image may be NSFW.
Clik here to view.
Build Jenkins Job - invoke Ansible playbook
Build Jenkins Job – invoke Ansible playbook

 

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

Image may be NSFW.
Clik here to view.
Click on Build Job Number - Jenkins
Click on Build Job Number – Jenkins

 

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

Image may be NSFW.
Clik here to view.
Jenkins Build Job - Ansible console 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!!!

The post Ansible Engine – Run Playbook using Jenkins – GUI appeared first on UnixArena.


Viewing all articles
Browse latest Browse all 370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>