I believe I’ve done most the initial troubleshooting including things like making sure the junos.device collection is installed as well as the pre-requisites like junos-eznc, ncclient, lxml. I am using netconf as the connection type. I tried ssh and had other errors (errors trying to sftp/scp to the device.) As I understand it netconf is the correct path forward for this collection.
I have verified with local scripts that both netconf and pyez function with the devices.
This is my playbook:
- name: Test NETCONF connectivity with Juniper device
hosts: juniper
gather_facts: no
collections:- juniper.device
tasks: - name: Gather basic facts
juniper.device.facts:
- juniper.device
This is my group_)vars/juniper.yml:
group_vars/juniper.yml
ansible_user: [censored]
ansible_password:[censored]
ansible_connection: netconf
ansible_network_os: junos
The versions I am running are:
ansible [core 2.14.14]
python version = 3.9.18 (main, Jul 3 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
ansible --version
ansible [core 2.14.14]
python version = 3.9.18 (main, Jul 3 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
jinja version = 3.1.2
libyaml = True
pip show junos-eznc
Name: junos-eznc
Version: 2.7.1
ansible-galaxy collection list | grep juniper.device
juniper.device 1.0.5
I get far along but then I have the following traceback and then I’m stuc as it appears that there is some compatibility issue perhaps, unless I’m missing something. Any ideas would be appreciated.
<jnboar1e-er01.diamondstatenetworks.com> EXEC /bin/sh -c ‘rm -f -r /home/emallette/.ansible/tmp/ansible-local-1141073e3fj7b5/ansible-tmp-1723998872.0815227-114111-248625022669254/ > /dev/null 2>&1 && sleep 0’
114111 1723998872.74582: opening command with Popen()
114111 1723998872.75711: done running command with Popen()
114111 1723998872.75721: getting output with communicate()
114111 1723998872.75820: done communicating
114111 1723998872.75823: done with local.exec_command()
114111 1723998872.75830: _low_level_execute_command() done: rc=0, stdout=, stderr=
114111 1723998872.75839: handler run complete
114111 1723998872.75865: attempt loop complete, returning result
114111 1723998872.75869: _execute() done
114111 1723998872.75870: dumping result to json
114111 1723998872.75872: done dumping result, returning
114111 1723998872.75880: done running TaskExecutor() for JNBOAR1E-ER01/TASK: Gather basic facts [1391337c-df50-fd05-b665-000000000004]
114111 1723998872.75882: sending task result for task 1391337c-df50-fd05-b665-000000000004
114111 1723998872.75907: done sending task result for task 1391337c-df50-fd05-b665-000000000004
114111 1723998872.75908: WORKER PROCESS EXITING
114107 1723998872.76075: marking JNBOAR1E-ER01 as failed
114107 1723998872.76085: marking host JNBOAR1E-ER01 failed, current state: HOST STATE: block=2, task=1, rescue=0, always=0, handlers=0, run_state=IteratingStates.TASKS, fail_state=FailedStates.NONE, pre_flushing_run_state=IteratingStates.TASKS, update_handlers=True, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
114107 1723998872.76092: ^ failed state is now: HOST STATE: block=2, task=1, rescue=0, always=0, handlers=0, run_state=IteratingStates.COMPLETE, fail_state=FailedStates.TASKS, pre_flushing_run_state=IteratingStates.TASKS, update_handlers=True, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
114107 1723998872.76095: getting the next task for host JNBOAR1E-ER01
114107 1723998872.76097: host JNBOAR1E-ER01 is done iterating, returning
The full traceback is:
Traceback (most recent call last):
File “/home/emallette/.ansible/tmp/ansible-local-1141073e3fj7b5/ansible-tmp-1723998872.0815227-114111-248625022669254/AnsiballZ_facts.py”, line 107, in
_ansiballz_main()
File “/home/emallette/.ansible/tmp/ansible-local-1141073e3fj7b5/ansible-tmp-1723998872.0815227-114111-248625022669254/AnsiballZ_facts.py”, line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File “/home/emallette/.ansible/tmp/ansible-local-1141073e3fj7b5/ansible-tmp-1723998872.0815227-114111-248625022669254/AnsiballZ_facts.py”, line 47, in invoke_module
runpy.run_module(mod_name=‘ansible_collections.juniper.device.plugins.modules.facts’, init_globals=dict(_module_fqn=‘ansible_collections.juniper.device.plugins.modules.facts’, _modlib_path=modlib_path),
File “/usr/lib64/python3.9/runpy.py”, line 225, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File “/usr/lib64/python3.9/runpy.py”, line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File “/usr/lib64/python3.9/runpy.py”, line 87, in _run_code
exec(code, run_globals)
File “/tmp/ansible_juniper.device.facts_payload_2p1rz62s/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py”, line 367, in
File “/tmp/ansible_juniper.device.facts_payload_2p1rz62s/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py”, line 309, in main
File “/tmp/ansible_juniper.device.facts_payload_2p1rz62s/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py”, line 610, in init
File “/tmp/ansible_juniper.device.facts_payload_2p1rz62s/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py”, line 742, in fail_json
File “/tmp/ansible_juniper.device.facts_payload_2p1rz62s/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py”, line 1213, in close_configuration
AttributeError: ‘JuniperJunosModule’ object has no attribute ‘_pyez_conn’
fatal: [JNBOAR1E-ER01]: FAILED! => {
“changed”: false,
“module_stderr”: “Traceback (most recent call last):\n File "/home/emallette/.ansible/tmp/ansible-local-1141073e3fj7b5/ansible-tmp-1723998872.0815227-114111-248625022669254/AnsiballZ_facts.py", line 107, in \n _ansiballz_main()\n File "/home/emallette/.ansible/tmp/ansible-local-1141073e3fj7b5/ansible-tmp-1723998872.0815227-114111-248625022669254/AnsiballZ_facts.py", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File "/home/emallette/.ansible/tmp/ansible-local-1141073e3fj7b5/ansible-tmp-1723998872.0815227-114111-248625022669254/AnsiballZ_facts.py", line 47, in invoke_module\n runpy.run_module(mod_name=‘ansible_collections.juniper.device.plugins.modules.facts’, init_globals=dict(_module_fqn=‘ansible_collections.juniper.device.plugins.modules.facts’, _modlib_path=modlib_path),\n File "/usr/lib64/python3.9/runpy.py", line 225, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File "/usr/lib64/python3.9/runpy.py", line 97, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code\n exec(code, run_globals)\n File "/tmp/ansible_juniper.device.facts_payload_2p1rz62s/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py", line 367, in \n File "/tmp/ansible_juniper.device.facts_payload_2p1rz62s/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/modules/facts.py", line 309, in main\n File "/tmp/ansible_juniper.device.facts_payload_2p1rz62s/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 610, in init\n File "/tmp/ansible_juniper.device.facts_payload_2p1rz62s/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 742, in fail_json\n File "/tmp/ansible_juniper.device.facts_payload_2p1rz62s/ansible_juniper.device.facts_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py", line 1213, in close_configuration\nAttributeError: ‘JuniperJunosModule’ object has no attribute ‘_pyez_conn’\n”,
“module_stdout”: “”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,
“rc”: 1
}