Closed tb90ka closed 4 years ago
Hi @tb90ka You will need to upgrade junos-eznc. juniper.junos 2.4.0 requires junos-eznc >= 2.5.0. https://github.com/Juniper/ansible-junos-stdlib/releases/tag/2.4.0 .
your current junos-eznc version is 2.1.7. upgrade it and tell if it works fine for you.
Hello @rahkumar651991 first of all thanks for your support!
I've upgraded junos-eznc as described:
$ pip freeze | grep junos
junos-eznc==2.5.1
But unfortunately I'm still getting the same error when running the playbook:
The full traceback is:
Traceback (most recent call last):
File "/home/username/.ansible/tmp/ansible-tmp-1596613954.85-9682-31691744305487/AnsiballZ_juniper_junos_system.py", line 102, in <module>
_ansiballz_main()
File "/home/username/.ansible/tmp/ansible-tmp-1596613954.85-9682-31691744305487/AnsiballZ_juniper_junos_system.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/username/.ansible/tmp/ansible-tmp-1596613954.85-9682-31691744305487/AnsiballZ_juniper_junos_system.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible.modules.juniper_junos_system', init_globals=None, run_name='__main__', alter_sys=True)
File "/usr/lib/python3.6/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/ansible_juniper_junos_system_payload_ea2otdnh/ansible_juniper_junos_system_payload.zip/ansible/modules/juniper_junos_system.py", line 399, in <module>
File "/tmp/ansible_juniper_junos_system_payload_ea2otdnh/ansible_juniper_junos_system_payload.zip/ansible/modules/juniper_junos_system.py", line 356, in main
AttributeError: 'JuniperJunosModule' object has no attribute 'sw'
fatal: [gw-mx204-test]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/home/username/.ansible/tmp/ansible-tmp-1596613954.85-9682-31691744305487/AnsiballZ_juniper_junos_system.py\", line 102, in <module>\n _ansiballz_main()\n File \"/home/username/.ansible/tmp/ansible-tmp-1596613954.85-9682-31691744305487/AnsiballZ_juniper_junos_system.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/username/.ansible/tmp/ansible-tmp-1596613954.85-9682-31691744305487/AnsiballZ_juniper_junos_system.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible.modules.juniper_junos_system', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib/python3.6/runpy.py\", line 205, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.6/runpy.py\", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File \"/usr/lib/python3.6/runpy.py\", line 85, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_juniper_junos_system_payload_ea2otdnh/ansible_juniper_junos_system_payload.zip/ansible/modules/juniper_junos_system.py\", line 399, in <module>\n File \"/tmp/ansible_juniper_junos_system_payload_ea2otdnh/ansible_juniper_junos_system_payload.zip/ansible/modules/juniper_junos_system.py\", line 356, in main\nAttributeError: 'JuniperJunosModule' object has no attribute 'sw'\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
I've also tried to remove the role and install it again (via ansible-galaxy) but then I had to patch the roles ( .ansible/roles/Juniper.junos/library/juniper_junos_system.py) code again:
< if action == 'reboot' and vmhost is True:
> if action != 'reboot' and vmhost is True:
Thanks @rahkumar651991 for fixing this! I've overwritten the old roles via ansible-galaxy:
$ sudo ansible-galaxy install git+https://github.com/Juniper/ansible-junos-stdlib.git,roles,Juniper.junos --force
Reboot now seems to work, even though I still get a (somewhat strange) error message:
fatal: [gw-mx204-test]: FAILED! => {
"action": "reboot",
"all_re": false,
"changed": false,
"invocation": {
"module_args": {
"action": "reboot",
"all_re": false,
"at": null,
"attempts": null,
"baud": null,
"console": null,
"cs_passwd": null,
"cs_user": null,
"host": "gw-gsp.nwlab.bs.kae.de.oneandone.net",
"in_min": 0,
"level": null,
"logdir": null,
"logfile": null,
"media": false,
"mode": null,
"other_re": false,
"passwd": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 22,
"ssh_config": null,
"ssh_private_key_file": null,
"timeout": 120,
"user": "$username",
"vmhost": true
}
},
"media": false,
"msg": "Did not find expected RPC response.",
"other_re": false,
"reboot": true,
"vmhost": true
}
The playbook fails, but the device is still rebooting. Could you please check what's wrong here?
The respective task for this:
- name: Reboot switch after upgrade
juniper_junos_system:
provider: "{{ connection_settings }}"
vmhost: true
in_min: 0
all_re: false
action: "reboot"
register: swreboot
Thanks in advance, tb90ka
@tb90ka - Can you share the netconf trace on the device for this issue. you may unicast it to jnpr-community-netdev@juniper.net . Will check more and get back. Also share the output displayed by the playbook with -v(verbose mode) option.
For enabling netconf trace on device, refer this. https://www.juniper.net/documentation/en_US/junos/topics/example/netconf-traceoptions-configuring.html
@rahkumar651991 information has been provided as requested.
@tb90ka https://github.com/Juniper/py-junos-eznc/pull/1066/files the change is in PyEZ(junos-eznc) for this. this should fix it. We will release new version for both with the fixes soon.
This issues has been fixed meanwhile.
Thanks for your support!
Issue Type
Module Name
juniper_junos_system
Ansible roles version
Juniper.Junos, Version 2.4.0
OS / Environment
JUNOS 19.3R1.8
Summary
When trying to reboot a Juniper MX204 router using ansible, it first failed with an error:
After I patched the .ansible/roles/Juniper.junos/library/juniper_junos_system.py role to:
... the playbook failed with below error message:
Steps to reproduce
inventory file: lab
group_vars/all
reboot.yaml
Run playbook:
Expected results
Device reboots and playbook ends.
Actual results
Playbook fails: