Running juniper.device.config with juniper.device.pyez as connection type does not transmit the error message when configuration is bad.
connection: local works as expected.
Steps to reproduce
---
- name: Test juniper. device.config module
hosts: all
gather_facts: no
collections:
- juniper.device
tasks:
- name: "Execute set configuration"
config:
load: "set"
format: "set"
lines: 'delete system login message'
comment: "test"
Expected results
TASK [Execute set configuration] *************************************************************************************************************************************************************************
fatal: [sw0-dc.artem]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/home/slefol/ansible-venv/bin/python3.11"}, "changed": false, "msg": "Failure loading the configuraton: ConfigLoadError(severity: warning, bad_element: None, message: warning: statement not found: login)"}
Actual results
TASK [Execute set configuration] *************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.connection.ConnectionError: 'Connection' object has no attribute 'pyez_exception'
fatal: [sw0-dc.artem]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/slefol/.ansible/tmp/ansible-local-851993dvp7usn/ansible-tmp-1716295990.181573-85202-163164558317835/AnsiballZ_config.py\", line 107, in <module>\n _ansiballz_main()\n File \"/home/slefol/.ansible/tmp/ansible-local-851993dvp7usn/ansible-tmp-1716295990.181573-85202-163164558317835/AnsiballZ_config.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/slefol/.ansible/tmp/ansible-local-851993dvp7usn/ansible-tmp-1716295990.181573-85202-163164558317835/AnsiballZ_config.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.config', init_globals=dict(_module_fqn='ansible_collections.juniper.device.plugins.modules.config', _modlib_path=modlib_path),\n File \"<frozen runpy>\", line 226, in run_module\n File \"<frozen runpy>\", line 98, in _run_module_code\n File \"<frozen runpy>\", line 88, in _run_code\n File \"/tmp/ansible_config_payload_nup0t6n5/ansible_config_payload.zip/ansible_collections/juniper/device/plugins/modules/config.py\", line 1252, in <module>\n File \"/tmp/ansible_config_payload_nup0t6n5/ansible_config_payload.zip/ansible_collections/juniper/device/plugins/modules/config.py\", line 1146, in main\n File \"/tmp/ansible_config_payload_nup0t6n5/ansible_config_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 1512, in load_configuration\n File \"/tmp/ansible_config_payload_nup0t6n5/ansible_config_payload.zip/ansible/module_utils/connection.py\", line 199, in __rpc__\nansible.module_utils.connection.ConnectionError: 'Connection' object has no attribute 'pyez_exception'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
instead of having the error message "Failure loading the configuraton: ConfigLoadError(severity: warning, bad_element: None, message: warning: statement not found: login)", the task returns "'Connection' object has no attribute 'pyez_exception'".
juniper.device.command with juniper.device.pyez works as expected.
---
- name: Test juniper. device.config module
hosts: all
gather_facts: no
collections:
- juniper.device
tasks:
- name: Get uptime
juniper.device.command:
commands: "show system uptime2"
TASK [Get uptime] ****************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.connection.ConnectionError: RpcError(severity: error, bad_element: uptime2, message: syntax error, expecting <command>)
fatal: [sw0-dc.artem]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/slefol/.ansible/tmp/ansible-local-86194ok9prres/ansible-tmp-1716296773.1521301-86197-64237631605524/AnsiballZ_command.py\", line 107, in <module>\n _ansiballz_main()\n File \"/home/slefol/.ansible/tmp/ansible-local-86194ok9prres/ansible-tmp-1716296773.1521301-86197-64237631605524/AnsiballZ_command.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/slefol/.ansible/tmp/ansible-local-86194ok9prres/ansible-tmp-1716296773.1521301-86197-64237631605524/AnsiballZ_command.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.juniper.device.plugins.modules.command', init_globals=dict(_module_fqn='ansible_collections.juniper.device.plugins.modules.command', _modlib_path=modlib_path),\n File \"<frozen runpy>\", line 226, in run_module\n File \"<frozen runpy>\", line 98, in _run_module_code\n File \"<frozen runpy>\", line 88, in _run_code\n File \"/tmp/ansible_juniper.device.command_payload_07orv17r/ansible_juniper.device.command_payload.zip/ansible_collections/juniper/device/plugins/modules/command.py\", line 493, in <module>\n File \"/tmp/ansible_juniper.device.command_payload_07orv17r/ansible_juniper.device.command_payload.zip/ansible_collections/juniper/device/plugins/modules/command.py\", line 406, in main\n File \"/tmp/ansible_juniper.device.command_payload_07orv17r/ansible_juniper.device.command_payload.zip/ansible_collections/juniper/device/plugins/module_utils/juniper_junos_common.py\", line 1780, in get_rpc\n File \"/tmp/ansible_juniper.device.command_payload_07orv17r/ansible_juniper.device.command_payload.zip/ansible/module_utils/connection.py\", line 199, in __rpc__\nansible.module_utils.connection.ConnectionError: RpcError(severity: error, bad_element: uptime2, message: syntax error, expecting <command>)\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
We can see "RpcError(severity: error, bad_element: uptime2, message: syntax error, expecting )"
Issue Type
Module Name
juniper.device.config
juniper.device collection and Python libraries version
OS / Environment
QFX5100 17.3R3-S4.2
Summary
Running juniper.device.config with juniper.device.pyez as connection type does not transmit the error message when configuration is bad. connection: local works as expected.
Steps to reproduce
Expected results
Actual results
instead of having the error message "Failure loading the configuraton: ConfigLoadError(severity: warning, bad_element: None, message: warning: statement not found: login)", the task returns "'Connection' object has no attribute 'pyez_exception'".
juniper.device.command with juniper.device.pyez works as expected.
We can see "RpcError(severity: error, bad_element: uptime2, message: syntax error, expecting)"