• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

UnixArena

  • Home
  • kubernetes
  • DevOps
    • Terraform
    • Jenkins
    • Docker
    • Openshift
      • OKD
    • Ansible engine
    • Ansible Tower
      • AWX
    • Puppet
  • Cloud
    • Azure
    • AWS
    • Openstack
    • Docker
  • VMware
    • vCloud Director
    • VMware-Guests
    • Vcenter Appliance 5.5
    • vC OPS
    • VMware SDDC
    • VMware vSphere 5.x
      • vSphere Network
      • vSphere DS
      • vShield Suite
    • VMware vSphere 6.0
    • VSAN
    • VMware Free Tools
  • Backup
    • Vembu BDR
    • Veeam
    • Nakivo
    • Azure Backup
    • Altaro VMBackup
    • Spinbackup
  • Tutorials
    • Openstack Tutorial
    • Openstack Beginner’s Guide
    • VXVM-Training
    • ZFS-Tutorials
    • NetApp cDot
    • LVM
    • Cisco UCS
    • LDOM
    • Oracle VM for x86
  • Linux
    • How to Articles
    • Q&A
    • Networking
    • RHEL7
  • DevOps Instructor-led Training
  • Contact

Jenkins- Ansible -Authenticate Server using Protected Passphrase

July 1, 2019 By Cloud_Devops Leave a Comment

Ansible is the most widely used configuration management tool. A recent challenge was to authenticate the servers using a protected passphrase. We have a set of servers which can be authenticated only using a passphrase. This article will provide a step by step procedure to authenticate ansible clients using a private key and protected passphrase. Jenkins can be used as a front end GUI portal to call the Ansible playbook. Jenkins does more than what AWX/Ansible Tower does.

 

Environment: 

  • Ansible – ansible 2.7.10
  • Jenkins – Jenkins 2.138.3

 

Challenge:

When you run the playbook against the host which are using a protected passphrase, it will prompt for the protected key.

[linadm@ansible-server ~]$ ansible-playbook -i temp test.yml

PLAY [192.168.3.151] *********************************************************************************

TASK [Gathering Facts] *******************************************************************************************************
Enter passphrase for key '/home/linadm/.ssh/id_rsa':

 

Once you have entered the protected key, it will connect to the host and run the required tasks.  How to call this playbook in Jenkins?   Jenkins job won’t be prompted to enter the protected key. How to overcome this issue?

If you are new to Ansible + Jenkins combo, please go through this article. 

 

1. Login to Jenkins portal.

 

2. Configure the job and navigate to the build tab.  In invoking Ansible plugin, click to add credentials.

Ansible Playbook - Jenkins - Passphrase
Ansible Playbook – Jenkins – Passphrase

 

3. In the Jenkins credentials provider, select kind as ” SSH username with private key”

Jenkins - Passing passphrase for Ansible playbook
Jenkins – Passing passphrase for Ansible playbook

 

4. Enter a user name, the private key of the ansible host and protected the key value and save it.

Jenkins Global Credential - Passphrase
Jenkins Global Credential – Passphrase

 

5. Select the newly created credentials in Jenkins job which is actually calling the ansible playbook.

Select the newly created credentials - Jenkins Ansible
Select the newly created credentials – Jenkins Ansible

 

6. Build the job and check the ansible playbook results.  Here, we can see the complete ansible command with private key switch.

Build Jenkins Job - Check the execution
Build Jenkins Job – Check the execution

 

We have successfully used the protected passphrase for invoking ansible playbook using Jenkins. There is another workaround documented in StackOverflow using ssh agent.

Hope this article is informative to you.

Filed Under: Ansible engine, Configuration Management, Jenkins Tagged With: Ansible, ansible tutorial, Jenkins, Jenkins - Ansible integration

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Follow UnixArena

  • Facebook
  • LinkedIn
  • Twitter

Copyright © 2025 · UnixArena ·

Go to mobile version