ansible-collections / community.network

Ansible Community Network Collection
http://galaxy.ansible.com/community/network
Other
124 stars 89 forks source link

Edgeos_command module fail with "command timeout triggered" #98

Closed Akasurde closed 2 years ago

Akasurde commented 4 years ago

From @seby01120 on Jul 31, 2020 01:32

SUMMARY

edgeos_command module fails with timeout error, even though I can connect to the target device by SSH

ISSUE TYPE
COMPONENT NAME

edgeos_command

ANSIBLE VERSION
ansible 2.9.11
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/seb/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.17 (default, Jul 20 2020, 15:37:01) [GCC 7.5.0]
CONFIGURATION
PARAMIKO_LOOK_FOR_KEYS(/etc/ansible/ansible.cfg) = False
OS / ENVIRONMENT

Target device : EdgeSwitch, firmware 1.9.1

STEPS TO REPRODUCE

Launching the playbook below against a EdgeSwitch with version 1.9.1. ansible-playbook -i inventories/hosts ubiquity-test.yml --extra-var "hst=10.240.0.115"

- hosts: "{{ hst }}"

  vars:
    - ansible_network_os: edgeos
    - ansible_connection: network_cli
    - ansible_python_interpreter: /usr/bin/python3

  tasks:

    - name: get version
      edgeos_command:
        commands: show version
EXPECTED RESULTS

Get the result of the command "show version" on an edgeswitch

ACTUAL RESULTS
TASK [get version] **************************************************************************************************************************************************************************************************************************
task path: /usr/share/ansible/ubiquity-test.yml:25
<10.240.0.115> attempting to start connection
<10.240.0.115> using connection plugin network_cli
<10.240.0.115> local domain socket does not exist, starting it
<10.240.0.115> control socket path is /home/seb/.ansible/pc/89775af488
<10.240.0.115> local domain socket listeners started successfully
<10.240.0.115> loaded cliconf plugin edgeos from path /usr/lib/python2.7/dist-packages/ansible/plugins/cliconf/edgeos.py for network_os edgeos
<10.240.0.115>
<10.240.0.115> local domain socket path is /home/seb/.ansible/pc/89775af488
<10.240.0.115> ESTABLISH LOCAL CONNECTION FOR USER: seb
<10.240.0.115> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/seb/.ansible/tmp/ansible-local-1006jsqYL4 `"&& mkdir /home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436 && echo ansible-tmp-1596158837.75-1013-183110654188436="` echo /home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436 `" ) && sleep 0'
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/network/edgeos/__init__.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/network/common/utils.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/network/edgeos/edgeos.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/network/common/parsing.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/network/common/__init__.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/network/__init__.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/_text.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/basic.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/__init__.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/six/__init__.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/_collections_compat.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/network.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/parsing/__init__.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/parsing/convert_bool.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/connection.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/json.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/collections.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/text/formatters.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/validation.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/text/converters.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/pycompat24.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/text/__init__.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/process.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/compat/selectors.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/_utils.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/parameters.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/_json_compat.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/sys_info.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/compat/__init__.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/common/file.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/compat/_selectors2.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/distro/__init__.py
Using module_utils file /usr/lib/python2.7/dist-packages/ansible/module_utils/distro/_distro.py
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/network/edgeos/edgeos_command.py
<10.240.0.115> PUT /home/seb/.ansible/tmp/ansible-local-1006jsqYL4/tmpH0wzd3 TO /home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/AnsiballZ_edgeos_command.py
<10.240.0.115> EXEC /bin/sh -c 'chmod u+x /home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/ /home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/AnsiballZ_edgeos_command.py && sleep 0'
<10.240.0.115> EXEC /bin/sh -c '/usr/bin/python3 /home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/AnsiballZ_edgeos_command.py && sleep 0'
<10.240.0.115> EXEC /bin/sh -c 'rm -f -r /home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/AnsiballZ_edgeos_command.py", line 102, in <module>
    _ansiballz_main()
  File "/home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/AnsiballZ_edgeos_command.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/AnsiballZ_edgeos_command.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.network.edgeos.edgeos_command', 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_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/modules/network/edgeos/edgeos_command.py", line 177, in <module>
  File "/tmp/ansible_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/modules/network/edgeos/edgeos_command.py", line 148, in main
  File "/tmp/ansible_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/module_utils/network/edgeos/edgeos.py", line 74, in run_commands
  File "/tmp/ansible_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/module_utils/network/edgeos/edgeos.py", line 40, in get_connection
  File "/tmp/ansible_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/module_utils/network/edgeos/edgeos.py", line 54, in get_capabilities
  File "/tmp/ansible_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
ansible.module_utils.connection.ConnectionError: command timeout triggered, timeout value is 30 secs.
See the timeout setting options in the Network Debug and Troubleshooting Guide.
fatal: [10.240.0.115]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/AnsiballZ_edgeos_command.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/AnsiballZ_edgeos_command.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/seb/.ansible/tmp/ansible-local-1006jsqYL4/ansible-tmp-1596158837.75-1013-183110654188436/AnsiballZ_edgeos_command.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.network.edgeos.edgeos_command', 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_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/modules/network/edgeos/edgeos_command.py\", line 177, in <module>\n  File \"/tmp/ansible_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/modules/network/edgeos/edgeos_command.py\", line 148, in main\n  File \"/tmp/ansible_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/module_utils/network/edgeos/edgeos.py\", line 74, in run_commands\n  File \"/tmp/ansible_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/module_utils/network/edgeos/edgeos.py\", line 40, in get_connection\n  File \"/tmp/ansible_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/module_utils/network/edgeos/edgeos.py\", line 54, in get_capabilities\n  File \"/tmp/ansible_edgeos_command_payload_8n_h2hwh/ansible_edgeos_command_payload.zip/ansible/module_utils/connection.py\", line 185, in __rpc__\nansible.module_utils.connection.ConnectionError: command timeout triggered, timeout value is 30 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide.\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Copied from original issue: ansible/ansible#71006

ansibullbot commented 3 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 3 years ago

cc @Qalthos @beardymcbeards @samdoran click here for bot help

ansibullbot commented 3 years ago

@Akasurde, just so you are aware we have a dedicated Working Group for network. You can find other people interested in this in #ansible-network on Freenode IRC For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

haught commented 3 years ago

My prompts are: (edgepoint-s16) > (edgepoint-s16) # (edgepoint-s16) (Config)#

and those don't match re.compile(br"[\r\n]?[\w+\-\.:\/\[\]]+(?:\([^\)]+\)){,3}(?:>|#) ?$"), from plugins/terminal/edgeos.py

For my testing I have added re.compile(br"[\r\n]?(?:\([^\)]+\)) (?:\([^\)]+\))?(?:>|#) ?$"), to the list to account for my prompts and it seems to work for me so far.

ansibullbot commented 2 years ago

cc @jplitza @virtualguy click here for bot help

jplitza commented 2 years ago

notabug As you already found out in #183, EdgeOS is the OS of the Edgerouter series, whereas you are trying to manage an Edgeswitch, which is completely different.

oza4h07 commented 11 months ago

How hard could it be to extend current module to support Edgeswitches or to port this module features in another Ansible module ? If I'm not mistaken, both Edgerouter and Edgeswitch use SSH with a configure mode to gain reconfiguration rights (many Network devices also have this mechanism)

virtualguy commented 11 months ago

Unfortunately the shell interface on the Edgeswitch is quite different. It would likely need to be added as a different device type rather than EdgeOS