Hi there,
I would like to get system information about my juniper equipment while using ansible (2.4.2) and juniper.junos role.
I can assume this:
I can't connect to internet that's why I downloaded manually the role (
https://github.com/Juniper/ansible-junos-stdlib) without git nor ansible-galaxy , and I pasted the folders in /etc/ansible/roles/Juniper.junos/
In the Juniper.Junos repository, I ussed source env-setup
I have installed the required packages.
ansible 2.4.2
pyserial
netaddr
scp>=0.7.0
jxmlease >= 1.0.1
paramiko>=1.15.2
jinja2>=2.7.1
PyYAML>=3.10
python-sixI set the role path in /etc/ansible/ansible.cfg :
roles_path = /etc/ansible/roles/Juniper.junos/library/juniper_junos_rpc.py
Below my playbook.yaml :
---
- name: Get system info
hosts: Juniper
roles:
- Juniper.junos
connection: local
gather_facts: no
tasks:
- name: checking Netconf connectivity
wait_for: host=10.142.21.138 port=22 timeout=10
- name: get interface information
juniper_junos_rpc:
host: 10.142.21.138
username: myuser
password: mypass
port: 22
rpcs: get-interface-information
# register: response
kwargs:
interface-em0: Internal
media: True
dest: savedfile.conf
- name: Print configuration
debug: mgs= "{{ junos.rpc_reply }}"
delegate_to: localhost
Below the output of my playbook
Using module file /usr/lib/python2.7/site-packages/ansible-2.4.3.0-py2.7.egg/ansible/modules/utilities/logic/wait_for.py
<10.142.21.138> ESTABLISH LOCAL CONNECTION FOR USER: root
<10.142.21.138> EXEC /bin/sh -c 'echo ~ && sleep 0'
<10.142.21.138> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690 `" && echo ansible-tmp-1522859464.57-245909329780690="` echo /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690 `" ) && sleep 0'
<10.142.21.138> PUT /tmp/tmpuXKQoy TO /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690/wait_for.py
<10.142.21.138> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690/ /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690/wait_for.py && sleep 0'
<10.142.21.138> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690/wait_for.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1522859464.57-245909329780690/" > /dev/null 2>&1 && sleep 0'
ok: [pulse-secure] => {
"changed": false,
"elapsed": 0,
"invocation": {
"module_args": {
"active_connection_states": [
"ESTABLISHED",
"FIN_WAIT1",
"FIN_WAIT2",
"SYN_RECV",
"SYN_SENT",
"TIME_WAIT"
],
"connect_timeout": 5,
"delay": 0,
"exclude_hosts": null,
"host": "10.142.21.138",
"msg": null,
"path": null,
"port": 22,
"search_regex": null,
"sleep": 1,
"state": "started",
"timeout": 10
}
},
"path": null,
"port": 22,
"search_regex": null,
"state": "started"
}
TASK [get interface information] ******************************************************************************************************************
task path: /images/juniper/startup-conf.yaml:11
Using module file /etc/ansible/roles/Juniper.junos/library/juniper_junos_rpc.py
<10.142.21.138> ESTABLISH LOCAL CONNECTION FOR USER: root
<10.142.21.138> EXEC /bin/sh -c 'echo ~ && sleep 0'
<10.142.21.138> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637 `" && echo ansible-tmp-1522858141.92-41570732472637="` echo /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637 `" ) && sleep 0'
<10.142.21.138> PUT /tmp/tmptwLsK0 TO /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637/juniper_junos_rpc.py
<10.142.21.138> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637/ /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637/juniper_junos_rpc.py && sleep 0'
<10.142.21.138> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637/juniper_junos_rpc.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1522858141.92-41570732472637/" > /dev/null 2>&1 && sleep 0'
fatal: [pulse-secure]: FAILED! => {
"changed": false,
"module_stderr": "No handlers could be found for logger \"ncclient.transport.session\"\nTraceback (most recent call last):\n File \"/tmp/ansible_GbggM7/ansible_module_juniper_junos_rpc.py\", line 662, in <module>\n main()\n File \"/tmp/ansible_GbggM7/ansible_module_juniper_junos_rpc.py\", line 648, in main\n junos_module.exit_json(**results[0])\n File \"/etc/ansible/roles/Juniper.junos/module_utils/juniper_junos_common.py\", line 755, in exit_json\n self.close()\n File \"/etc/ansible/roles/Juniper.junos/module_utils/juniper_junos_common.py\", line 1287, in close\n dev.close()\n File \"/usr/lib/python2.7/site-packages/junos_eznc-2.1.7-py2.7.egg/jnpr/junos/device.py\", line 1314, in close\n self._conn.close_session()\n File \"build/bdist.linux-x86_64/egg/ncclient/manager.py\", line 162, in wrapper\n File \"build/bdist.linux-x86_64/egg/ncclient/manager.py\", line 232, in execute\n File \"build/bdist.linux-x86_64/egg/ncclient/operations/session.py\", line 28, in request\n File \"build/bdist.linux-x86_64/egg/ncclient/operations/rpc.py\", line 343, in _request\nncclient.operations.errors.TimeoutExpiredError: ncclient timed out while waiting for an rpc reply.\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}
to retry, use: --limit @/images/juniper/startup-conf.retry
to retry, use: --limit @/images/juniper/startup-conf.retry
PLAY RECAP *************************************************************************************************************************************************
pulse-secure : ok=1 changed=0 unreachable=0 failed=1
I had a look at /usr/lib/python2.7/site-packages/junos_eznc-2.1.7-py2.7.egg/jnpr/junos/device.py and changed the port 830 to 22 as I was able to join the juniper pulse with the command
ssh
myuser@10.142.21.138 -p 830 -s netconf
I can't use pip install cryptography as my VM can't access to internet but I have cryptography1.3.1 installed
Can you guide to fix this bug.
Thanks in advance