# Ansible & Jenkins integration issue

**URL:** <https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596>\
**Category:** Ansible Project\
**Created:** [January 30, 2018, 9:12am UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596 "2018-01-30T09:12:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![GornerM](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@GornerM](https://forum.ansible.com/u/GornerM)\
**Post date:** [January 30, 2018, 9:12am UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/1 "2018-01-30T09:12:33Z")

</div>

Ansible playbooks passes without any issues, when I run it directly from cli (also inside of Jenkins workspace)  
But I receives the following error  
"FAILED! =\> {“failed”: true, “msg”: “ERROR! the handler ‘juniper\_junos\_facts’ was not found”  
when ansible runs by execution of Jenkins job.

juniper\_junos\_facts is the task of Juniper.junos role.

I have specifide library path in ansible configuration and exported ANSIBLE\_LIBRARY variable.

Do you have any ideas, why ansible can not find tasks iside of Jenkins?

---

<div class="post-metadata">

**Author:** ![Malcolm\_Hussain-Gamb](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@Malcolm\_Hussain-Gamb](https://forum.ansible.com/u/Malcolm_Hussain-Gamb)\
**Post date:** [January 30, 2018, 7:46pm UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/2 "2018-01-30T19:46:39Z")

</div>

Are you using the ansible plugin within Jenkins?  
Or running it as a cli within jenkins?  
I’ve had no issues (yet) using the ansible plugin.

---

<div class="post-metadata">

**Author:** ![GornerM](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@GornerM](https://forum.ansible.com/u/GornerM)\
**Post date:** [January 31, 2018, 8:16am UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/3 "2018-01-31T08:16:34Z")

</div>

I’ve received the same error result with or without ansible plagin.  
Here is the last jenkins output log with ansible plugin:

```auto
[Job_gitlab_ansible_2] $ /usr/bin/ansible-playbook test2.yml -i hosts -f 5 --private-key /tmp/ssh1443101965150836988.key -u root

PLAY [GET] *********************************************************************

TASK [CHECK-NETCONF] ***********************************************************
ok: [10.10.10.11]

TASK [Retrive information from devices running Junos OS] ***********************
fatal: [10.10.10.11]: FAILED! => {"failed": true, "msg": "ERROR! the handler 'juniper_junos_facts' was not found"}

PLAY RECAP *********************************************************************
10.10.10.11 : ok=1 changed=0 unreachable=0 failed=1   

FATAL: command execution failed
hudson.AbortException: Ansible playbook execution failed
	at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:236)
	at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:207)
	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
	at hudson.model.Build$BuildExecution.build(Build.java:206)
	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
	at hudson.model.Run.execute(Run.java:1724)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:421)
ERROR: Ansible playbook execution failed
Finished: FAILURE

```

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [January 31, 2018, 8:40am UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/4 "2018-01-31T08:40:19Z")

</div>

31 janvier 2018 09:17 “GornerM” \<didger2@gmail.com\> a écrit:

> I’ve received the same error result with or without ansible plagin.  
> Here is the last jenkins output log with ansible plugin:
> 
> ```auto
> [Job_gitlab_ansible_2] $ /usr/bin/ansible-playbook test2.yml -i hosts -f 5 --private-key /tmp/ssh1443101965150836988.key -u root PLAY [GET] *********************************************************************TASK [CHECK-NETCONF]*********************************************************** ok: [10.10.10.11] TASK [Retrive information from devices running Junos OS] ***********************fatal: [10.10.10.11]: FAILED! => {"failed": true, "msg": "ERROR! the handler 'juniper_junos_facts' was not found"} PLAY RECAP********************************************************************* 10.10.10.11 : ok=1 changed=0 unreachable=0 failed=1 FATAL: command execution failed hudson.AbortException: Ansible playbook execution failed at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:236) at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:207) at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744) at hudson.model.Build$BuildExecution.build(Build.java:206) at hudson.model.Build$BuildExecution.doRun(Build.java:163) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504) at hudson.model.Run.execute(Run.java:1724) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:97) at hudson.model.Executor.run(Executor.java:421) ERROR: Ansible playbook execution failed Finished: FAILURE
> 
> ```
> 
> –  
> You received this message because you are subscribed to the Google Groups “Ansible Project” group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [ansible-project+unsubscribe@googlegroups.com](mailto:ansible-project+unsubscribe@googlegroups.com).  
> To post to this group, send email to [ansible-project@googlegroups.com](mailto:ansible-project@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/ansible-project/785bdd9b-a0c5-4bcc-bc71-e675351011e5%40googlegroups.com](https://groups.google.com/d/msgid/ansible-project/785bdd9b-a0c5-4bcc-bc71-e675351011e5%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

Hi,

It seems to me that juniper\_junos\_facts is not a standard module, as you can see here :  
[http://docs.ansible.com/ansible/latest/list\_of\_network\_modules.html#junos](http://docs.ansible.com/ansible/latest/list_of_network_modules.html#junos)

juniper\_junos\_facts seems an external module as you can see here :  
[http://junos-ansible-modules.readthedocs.io/en/2.0.0/juniper\_junos\_facts.html](http://junos-ansible-modules.readthedocs.io/en/2.0.0/juniper_junos_facts.html)  
[https://github.com/Juniper/ansible-junos-stdlib](https://github.com/Juniper/ansible-junos-stdlib)

So did you properly modify ansible.cfg to be able to use these external modules ?

Regards,

JYL

---

<div class="post-metadata">

**Author:** ![GornerM](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@GornerM](https://forum.ansible.com/u/GornerM)\
**Post date:** [January 31, 2018, 11:01am UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/5 "2018-01-31T11:01:18Z")

</div>

Yes, juniper\_junos\_facts is external module.  
The roles directory is contained Juniper.junos role ([https://github.com/Juniper/ansible-junos-stdlib](https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FJuniper%2Fansible-junos-stdlib&sa=D&sntz=1&usg=AFQjCNHfT4va0j3DPka-QVtIvLd-9sdwPg))

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [January 31, 2018, 12:39pm UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/6 "2018-01-31T12:39:56Z")

</div>

31 janvier 2018 12:02 "GornerM" \<didger2@gmail.com\> a écrit:

> Yes, juniper\_junos\_facts is external module.  
> The roles directory is contained Juniper.junos role  
> ([https://github.com/Juniper/ansible-junos-stdlib](https://github.com/Juniper/ansible-junos-stdlib))
> 
> -------
> 
> Here is my ansible configuration:
> 
> [defaults]
> 
> inventory=./hosts
> 
> remote\_user=root
> 
> ask\_pass=False
> 
> transport = netconf  
> host\_key\_checking = False  
> roles\_path = ./roles/  
> library= ./roles/Juniper.junos/library
> 
> ------
> 
> Possible is it required additional specifications in ansible.cfg?  
> But it works properly without jenkins.

Hi,

Where's your file ?  
For the record ansible look for config file in this order :  
\* ANSIBLE\_CONFIG (an environment variable)  
\* ansible.cfg (in the current directory)  
\* .ansible.cfg (in the home directory)  
\* /etc/ansible/ansible.cfg

as written in documentation here :  
[http://docs.ansible.com/ansible/latest/intro\_configuration.html](http://docs.ansible.com/ansible/latest/intro_configuration.html)

Regards,

JYL

---

<div class="post-metadata">

**Author:** ![GornerM](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@GornerM](https://forum.ansible.com/u/GornerM)\
**Post date:** [January 31, 2018, 1:29pm UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/7 "2018-01-31T13:29:55Z")

</div>

ansible.cfg can be found in the current directory,

so my test ansible project currently looks like:

> 

> - ansible.cfg
> - hosts
> - test2.yml
> - roles - Juniper.junos - library - juniper\_junos\_facts.py

All of this files also are located in jenkins workspace.

---

<div class="post-metadata">

**Author:** ![jean-yves](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jean-yves](https://forum.ansible.com/u/jean-yves)\
**Post date:** [January 31, 2018, 1:58pm UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/8 "2018-01-31T13:58:01Z")

</div>

31 janvier 2018 14:31 “GornerM” \<didger2@gmail.com\> a écrit:

> ansible.cfg can be found in the current directory,
> 
> so my test ansible project currently looks like:
> 
> > - ansible.cfg
> > - hosts
> > - test2.yml
> > - roles - Juniper.junos - library - juniper\_junos\_facts.py
> 
> All of this files also are located in jenkins workspace.

Just guessing… you need to do some make and try to make some progress in this issue you encounter :

Perhaps the default path is not the same if you call ansible-playbook from jenkins and from command line…  
Are the files in the homedir of the user you use to execute ansible or in another directory ?

You have to try one or more of these things :  
Did you try with absolute paths instead of relative in your ansible.cfg file ?  
Did you try to put all files in the homedir of the user ? (you need to rename ansible.cfg in .ansible.cfg with a beginning dot ) ?

Regards,

JYL

---

<div class="post-metadata">

**Author:** ![Malcolm\_Hussain-Gamb](https://avatars.discourse-cdn.com/v4/letter/m/90db22/32.png) [@Malcolm\_Hussain-Gamb](https://forum.ansible.com/u/Malcolm_Hussain-Gamb)\
**Post date:** [January 31, 2018, 6:52pm UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/9 "2018-01-31T18:52:28Z")

</div>

> From the cli version, try running two commands pwd and ls -l

So you can see if it's putting you in the directory you think you are

---

<div class="post-metadata">

**Author:** ![GornerM](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@GornerM](https://forum.ansible.com/u/GornerM)\
**Post date:** [February 1, 2018, 12:50pm UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/10 "2018-02-01T12:50:17Z")

</div>

I have launched empty Ubuntu 16.04 system and installed ansible & required ansible modules in following way:

---

<div class="post-metadata">

**Author:** ![GornerM](https://avatars.discourse-cdn.com/v4/letter/g/ebca7d/32.png) [@GornerM](https://forum.ansible.com/u/GornerM)\
**Post date:** [February 2, 2018, 8:30am UTC](https://forum.ansible.com/t/ansible-jenkins-integration-issue/26596/11 "2018-02-02T08:30:44Z")

</div>

Jenkins and cli used different ansible versions.

To avoid this error I just updated version of ansible from 2.0.0.2 to 2.4.3.0 inside of Jenkins.

Thank you for supporting.
