Re: [ansible-project] Re: Ansible & Jenkins integration issue

2018-02-02 Thread GornerM
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.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4d1302c7-fc5b-4d92-94ce-0f0609e41b92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Ansible & Jenkins integration issue

2018-02-01 Thread GornerM
I have launched empty Ubuntu 16.04 system and installed ansible & required 
ansible modules in following way:
-
sudo su
apt-get install python-pip
apt-get install python-dev libxml2-dev libxslt-dev libssl-devlibffi-dev
pip install junos-eznc
apt-get install ansible
ansible-galaxy install Juniper.junos  
ansible-galaxy install --roles-path . Juniper.jenkins
ansible-galaxy install --roles-path /etc/ansible/roles Juniper.jenkins
ansible-galaxy install Juniper.jenkins
pip install -U jxmlease
pip install ncclient
---
Possibly is it required to install additional packages for ansible?

Ansible project (ansible.cfg, hosts, test2.yml) has been installed in three 
different directories: /ets/ansible, /root/.ansible ; 
/root/Project_22.01.2018

Now each time when I run playbook from different directories I receive the 
same error output:


root@Jenkins:~/Project_22.01.2018# /usr/bin/ansible-playbook test2.yml -f 1 
--private-key ~/.ssh/id_rsa -u root -v
Using /root/Project_22.01.2018/ansible.cfg as config file
Loaded callback jsnapy of type aggregate, v2.0
Loaded callback default of type stdout, v2.0
1 plays in test2.yml

PLAY [GET] 
*

TASK [CHECK-NETCONF] 
***
task path: /root/Project_22.01.2018/test2.yml:14
ESTABLISH LOCAL CONNECTION FOR USER: root
10.10.10.11 EXEC mkdir -p "$( echo 
$HOME/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332 )" && echo "$( 
echo $HOME/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332 )"
10.10.10.11 PUT /tmp/tmpukU7TW TO 
/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/wait_for
10.10.10.11 EXEC LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 
LC_MESSAGES=en_US.UTF-8 /usr/bin/python 
/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/wait_for; rm 
-rf "/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/" > 
/dev/null 2>&1
ok: [10.10.10.11] => {"changed": false, "elapsed": 0, "invocation": 
{"module_args": {"connect_timeout": 5, "delay": 0, "exclude_hosts": null, 
"host": "10.219.167.11", "path": null, "port": "830", "search_regex": null, 
"state": "started", "timeout": "5"}, "module_name": "wait_for"}, "path": 
null, "port": 830, "search_regex": null, "state": "started"}

TASK [Retrive information from devices running Junos OS] 
***
task path: /root/Project_22.01.2018/test2.yml:17
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=1changed=0unreachable=0failed=1


Here is my test ansible project:
root@Jenkins:~/Project_22.01.2018# pwd
/root/Project_22.01.2018
root@Jenkins:~/Project_22.01.2018# ll
total 60
drwxr-xr-x 5 root root  4096 Feb  1 14:56 ./
drwx-- 7 root root  4096 Feb  1 14:56 ../
-rw-r--r-- 1 root root   338 Feb  1 14:56 ansible.cfg
drwxr-xr-x 8 root root  4096 Feb  1 14:46 .git/
-rw-r--r-- 1 root root69 Feb  1 14:46 hosts
drwxr-xr-x 4 root root  4096 Feb  1 14:46 roles/
-rw-r--r-- 1 root root   567 Feb  1 14:46 test2.yml
root@Jenkins:~/Project_22.01.2018#

--- ansible.cfg
[defaults]
inventory=./hosts
remote_user=root
ask_pass=False
transport = netconf
host_key_checking = False
roles_path = 
/etc/ansible/roles:/root/.ansible/roles:/root/Project_22.01.2018/roles
library = 
/etc/ansible/roles/Juniper.junos/library:/root/.ansible/roles/Juniper.junos/library:/root/Project_22.01.2018/roles/Juniper.junos/library
- hosts
[vsrx]
10.219.167.11 ansible_ssh_user=root ansible_connection=local
- test2.yml
---
- name: GET
  hosts: vsrx
  roles:
  - Juniper.junos
  connection: local
  gather_facts: no
  vars:
ansible_python_interpreter: /usr/bin/python

  # Execute tasks (plays) this way "ansible-playbook /GET.yml --tags 
"
  tasks:
  # Check if a device is NETCONF-aware
  - name: CHECK-NETCONF
wait_for: host={{ inventory_hostname }} port=830 timeout=5

  - name: Retrive information from devices running Junos OS
juniper_junos_facts:
  host: "{{ inventory_hostname }}"
register: junos

  - name: version
debug:
  var: junos


-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6159a7bd-2cdf-4abb-b898-3eed5bfdeaaf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Ansible & Jenkins integration issue

2018-02-01 Thread GornerM
root@Jenkins:~/Project_22.01.2018# pwd
/root/Project_22.01.2018
root@Jenkins:~/Project_22.01.2018# ll
total 60
drwxr-xr-x 5 root root  4096 Feb  1 14:56 ./
drwx-- 7 root root  4096 Feb  1 14:56 ../
-rw-r--r-- 1 root root   338 Feb  1 14:56 ansible.cfg
drwxr-xr-x 8 root root  4096 Feb  1 14:46 .git/
-rw-r--r-- 1 root root69 Feb  1 14:46 hosts
drwxr-xr-x 4 root root  4096 Feb  1 14:46 roles/
-rw-r--r-- 1 root root   567 Feb  1 14:46 test2.yml

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3e76ca79-9592-42b0-8254-fcf9f2ffdfa2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Ansible & Jenkins integration issue

2018-02-01 Thread GornerM
I have launched empty Ubuntu 16.04 system and installed ansible & required 
ansible modules in following way:


sudo apt-get install python-pip

sudo apt-get install python-dev libxml2-dev libxslt-dev libssl-dev 
   libffi-dev

sudo pip install junos-eznc

apt-get install ansible

ansible-galaxy install Juniper.junos

ansible-galaxy install --roles-path /etc/ansible/roles Juniper.junos

ansible-galaxy install --roles-path . Juniper.junos

pip install -U jxmlease

pip install -U jxmlease

pip install ncclient
===
Possible is it required installation some additional packets for ansible?

Python version is 2.7.12.

I installed test ansible project (ansible.cfg, test2.yml, hosts), 
Juniper.junos module at different directories: /etc/ansible 
; /root/.ansible/ ; /root/Project_22.01.2018/roles/

And now the issue is reproduced each time when I run playbook from cli.


 
Here is my test ansible project

[defaults]
inventory=./hosts
remote_user=root
ask_pass=False
transport = netconf
host_key_checking = False
roles_path = 
/etc/ansible/roles:/root/.ansible/roles:/root/Project_22.01.2018/roles
library = 
/etc/ansible/roles/Juniper.junos/library:/root/.ansible/roles/Juniper.junos/library:/root/Project_22.01.2018/roles/Juniper.junos/library

#test2.yml
---
- name: GET
  hosts: vsrx
  roles:
  - Juniper.junos
  connection: local
  gather_facts: no
  vars:
ansible_python_interpreter: /usr/bin/python

  # Execute tasks (plays) this way "ansible-playbook /GET.yml --tags 
"
  tasks:
  # Check if a device is NETCONF-aware
  - name: CHECK-NETCONF
wait_for: host={{ inventory_hostname }} port=830 timeout=5

  - name: Retrive information from devices running Junos OS
juniper_junos_facts:
  host: "{{ inventory_hostname }}"
register: junos

  - name: version
debug:
  var: junos

#hosts
[vsrx]
10.10.10.11 ansible_ssh_user=root ansible_connection=local
ansible_python_interpreter=/usr/bin/python
---
---

Here is cli output:

root@Jenkins:~/Project_22.01.2018# /usr/bin/ansible-playbook test2.yml -f 1 
--private-key ~/.ssh/id_rsa -u root -v
Using /root/Project_22.01.2018/ansible.cfg as config file
Loaded callback jsnapy of type aggregate, v2.0
Loaded callback default of type stdout, v2.0
1 plays in test2.yml

PLAY [GET] 
*

TASK [CHECK-NETCONF] 
***
task path: /root/Project_22.01.2018/test2.yml:14
ESTABLISH LOCAL CONNECTION FOR USER: root
10.219.167.11 EXEC mkdir -p "$( echo 
$HOME/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332 )" && echo "$( 
echo $HOME/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332 )"
10.219.167.11 PUT /tmp/tmpukU7TW TO 
/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/wait_for
10.219.167.11 EXEC LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 
LC_MESSAGES=en_US.UTF-8 /usr/bin/python 
/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/wait_for; rm 
-rf "/root/.ansible/tmp/ansible-tmp-1517486840.38-200303031568332/" > 
/dev/null 2>&1
ok: [10.219.167.11] => {"changed": false, "elapsed": 0, "invocation": 
{"module_args": {"connect_timeout": 5, "delay": 0, "exclude_hosts": null, 
"host": "10.219.167.11", "path": null, "port": "830", "search_regex": null, 
"state": "started", "timeout": "5"}, "module_name": "wait_for"}, "path": 
null, "port": 830, "search_regex": null, "state": "started"}

TASK [Retrive information from devices running Junos OS] 
***
task path: /root/Project_22.01.2018/test2.yml:17
fatal: [10.219.167.11]: FAILED! => {"failed": true, "msg": "ERROR! the 
handler 'juniper_junos_facts' was not found"}

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





-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e270f49e-e4ae-4e7e-b8f5-6f25d4197b38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Ansible & Jenkins integration issue

2018-01-31 Thread GornerM
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.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c63711b9-b787-4f87-a874-41cdf87b7611%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Ansible & Jenkins integration issue

2018-01-31 Thread GornerM
Yes, juniper_junos_facts is external module.
The roles directory is contained Juniper.junos role (
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.


-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b1c38ed1-1016-46da-bc59-c5bc867dc672%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible & Jenkins integration issue

2018-01-31 Thread GornerM
I've received the same error result with or without ansible plagin.
Here is the last jenkins output log with ansible plugin:



[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=1changed=0unreachable=0failed=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+unsubscr...@googlegroups.com.
To post to this group, send email to 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.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Ansible & Jenkins integration issue

2018-01-31 Thread GornerM
I've received the same error result with or without ansible plagin.
Here is the last jenkins output log with ansible plugin:



[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.219.167.11]

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

PLAY RECAP *
10.219.167.11  : ok=1changed=0unreachable=0failed=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+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/50c990f4-8822-4086-bd56-631d619288a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible & Jenkins integration issue

2018-01-30 Thread GornerM
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?

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0a407fe1-be5b-4e00-9d88-2b0ab80826f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.