junipernetworks.junos icon indicating copy to clipboard operation
junipernetworks.junos copied to clipboard

junipernetworks.junos.junos_command should consider the task successful if launched command succeed to execute even though the output includes error keyword.

Open mahoutukaisali opened this issue 1 year ago • 2 comments

SUMMARY

junipernetworks.junos.junos_command module regards the task status as "failed" when request support information command output includes specific keywords like syntax error.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

junipernetworks.junos.junos_command

ANSIBLE VERSION
ansible-core 2.15.2
COLLECTION VERSION
junipernetworks.junos: 5.1.0
STEPS TO REPRODUCE
  • Run the below playbook towards the managed node Junos. As you can see in the execution logs below, the show services advanced-anti-malware command is launched by the request support information command in Junos, but it fails due to a syntax error. While this is likely a bug in Junos, the request support information command itself succeeds, so I believe the Ansible task should be considered successful.
- name: Testing copy software
  hosts: "{{ target }}"

  tasks:
    - name: run show version on remote devices
      junipernetworks.junos.junos_command:
        commands: "request support information"
TASK [run show version on remote devices] **************************************
task path: /path/to/juniper_rsi_junos_command.yml:10
The full traceback is:
  File "/usr/share/ansible/collections/ansible_collections/junipernetworks/junos/plugins/modules/junos_command.py", line 404, in main
    output.append(conn.get(command=cmd))
  File "/usr/local/lib/python3.9/site-packages/ansible/module_utils/connection.py", line 200, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
[WARNING]: arguments wait_for, match, rpcs are not supported when using
transport=cli
fatal: [EXAMPLE.HOST.COM]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "commands": [
                "request support information
            ],
            "display": null,
            "interval": 1,
            "match": "all",
            "retries": 10,
            "rpcs": null,
            "wait_for": null
        }
    },
    "msg":

(...)

show services advanced-anti-malware statistics\r\n\r\n\r\nerror: syntax error, expecting <command>: advanced-anti-malware\r\n\r\n{master}\r\[email protected]> "

PLAY RECAP *********************************************************************
[email protected] : ok=0    changed=0    unreachable=0   failed=1   skipped=0    rescued=0    ignored=0   
Please review the log for errors.
EXPECTED RESULTS
  • The task should be considered successful since the execution of the request support information command itself is successful.
ACTUAL RESULTS
  • Tha task status will be regarded as failed.

mahoutukaisali avatar Dec 24 '23 07:12 mahoutukaisali

@mahoutukaisali , We could not reproduce this , is it possible for you to share the CLI command output?

request support information

rohitthakur2590 avatar Apr 01 '24 12:04 rohitthakur2590