ansible-collections / community.network

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

Can't connect to edgeOS with network_cli #136

Closed NoxInmortus closed 4 years ago

NoxInmortus commented 4 years ago
SUMMARY

Cannot connect to edgeOS 1.10.11 with network_cli

ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
2.9.14
CONFIGURATION
ANSIBLE_PIPELINING(/tmp/test/ansible.cfg) = True
CACHE_PLUGIN(/tmp/test/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/tmp/test/ansible.cfg) = $HOME/.ansible/tmp/cache
CACHE_PLUGIN_TIMEOUT(/tmp/test/ansible.cfg) = 86400
DEFAULT_ACTION_PLUGIN_PATH(/tmp/test/ansible.cfg) = ['/usr/share/ansible_plugins/action_plugins']
DEFAULT_BECOME(/tmp/test/ansible.cfg) = True
DEFAULT_BECOME_METHOD(/tmp/test/ansible.cfg) = sudo
DEFAULT_BECOME_USER(/tmp/test/ansible.cfg) = root
DEFAULT_CALLBACK_PLUGIN_PATH(/tmp/test/ansible.cfg) = ['/usr/share/ansible_plugins/callback_plugins']
DEFAULT_CONNECTION_PLUGIN_PATH(/tmp/test/ansible.cfg) = ['/usr/share/ansible_plugins/connection_plugins']
DEFAULT_FILTER_PLUGIN_PATH(/tmp/test/ansible.cfg) = ['/usr/share/ansible_plugins/filter_plugins']
DEFAULT_FORKS(/tmp/test/ansible.cfg) = 20
DEFAULT_GATHERING(/tmp/test/ansible.cfg) = smart
DEFAULT_HOST_LIST(/tmp/test/ansible.cfg) = ['/tmp/test/hosts']
DEFAULT_LOOKUP_PLUGIN_PATH(/tmp/test/ansible.cfg) = ['/usr/share/ansible_plugins/lookup_plugins']
DEFAULT_MANAGED_STR(/tmp/test/ansible.cfg) = Ansible managed: {file} modified by {uid}
DEFAULT_MODULE_NAME(/tmp/test/ansible.cfg) = shell
DEFAULT_POLL_INTERVAL(/tmp/test/ansible.cfg) = 10
DEFAULT_ROLES_PATH(/tmp/test/ansible.cfg) = ['/tmp/test/roles']
DEFAULT_STRATEGY(/tmp/test/ansible.cfg) = mitogen_linear
DEFAULT_STRATEGY_PLUGIN_PATH(/tmp/test/ansible.cfg) = ['/opt/mitogen-0.2.9/ansible_mitogen/plugins/strategy']
DEFAULT_TIMEOUT(/tmp/test/ansible.cfg) = 10
DEFAULT_TRANSPORT(/tmp/test/ansible.cfg) = smart
DEFAULT_VARS_PLUGIN_PATH(/tmp/test/ansible.cfg) = ['/usr/share/ansible_plugins/vars_plugins']
DEFAULT_VAULT_PASSWORD_FILE(/tmp/test/ansible.cfg) = /tmp/test/vault.sh
DEPRECATION_WARNINGS(/tmp/test/ansible.cfg) = False
INTERPRETER_PYTHON(/tmp/test/ansible.cfg) = /usr/bin/python3
RETRY_FILES_ENABLED(/tmp/test/ansible.cfg) = False
OS / ENVIRONMENT

Orchestrator is Ubuntu 20.04/python3 and host is EdgeMax Router X running edgeOS 1.10.11

STEPS TO REPRODUCE

My playbook:

- hosts: "{{ hostlist | default('edgemax') }}"
  become: false
  gather_facts: false
  connection: network_cli
  remote_user: admin
  port: my-non-standard-ssh-port
  vars:
    ansible_persistent_command_timeout: '30'
    ansible_network_os: edgeos 
    ansible_pass: pass
    ansible_private_key_file: '~/.ssh/mykey'
    ansible_python_interpreter: /usr/bin/python
  tasks:
      - name: Gather facts
        community.network.edgeos_facts:
          gather_subset:
            - config
EXPECTED RESULTS

Working edgeos modules

ACTUAL RESULTS
TASK [Gather facts] *****************************************************************************************************************************************
task path: /home/me/test/playbooks/edgemax.yml:28
<edge02> attempting to start connection
<edge02> using connection plugin network_cli
<edge02> local domain socket does not exist, starting it
<edge02> control socket path is /home/me/.ansible/pc/ba1a4c49c7
<edge02> local domain socket listeners started successfully
<edge02> loaded cliconf plugin edgeos from path /home/alban/.local/lib/python3.8/site-packages/ansible/plugins/cliconf/edgeos.py for network_os edgeos
<edge02> 
<edge02> local domain socket path is /home/me/.ansible/pc/ba1a4c49c7
Using module file /home/alban/.ansible/collections/ansible_collections/community/network/plugins/modules/edgeos_facts.py
Pipelining is enabled.
<edge02> ESTABLISH LOCAL CONNECTION FOR USER: me
<edge02> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "<stdin>", line 102, in <module>
  File "<stdin>", line 94, in _ansiballz_main
  File "<stdin>", line 40, in invoke_module
  File "/usr/lib/python2.7/runpy.py", line 188, in run_module
    fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeos_facts.py", line 305, in <module>                                                                                                       
  File "/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeos_facts.py", line 293, in main                                                                                                           
  File "/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeos_facts.py", line 115, in populate                                                                                                       
  File "/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeos_facts.py", line 104, in populate                                                                                                       
  File "/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/module_utils/network/edgeos/edgeos.py", line 78, in run_commands
  File "/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/module_utils/network/edgeos/edgeos.py", line 44, in get_connection
  File "/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/module_utils/network/edgeos/edgeos.py", line 58, in get_capabilities
  File "/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
ansible.module_utils.connection.ConnectionError: timed out
fatal: [edge02]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 102, in <module>\n  File \"<stdin>\", line 94, in _ansiballz_main\n  File \"<stdin>\", line 40, in invoke_module\n  File \"/usr/lib/python2.7/runpy.py\", line 188, in run_module\n    fname, loader, pkg_name)\n  File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\n    mod_name, mod_fname, mod_loader, pkg_name)\n  File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\n    exec code in run_globals\n  File \"/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeos_facts.py\", line 305, in <module>\n  File \"/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeos_facts.py\", line 293, in main\n  File \"/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeos_facts.py\", line 115, in populate\n  File \"/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/modules/edgeos_facts.py\", line 104, in populate\n  File \"/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/module_utils/network/edgeos/edgeos.py\", line 78, in run_commands\n  File \"/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/module_utils/network/edgeos/edgeos.py\", line 44, in get_connection\n  File \"/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible_collections/community/network/plugins/module_utils/network/edgeos/edgeos.py\", line 58, in get_capabilities\n  File \"/tmp/ansible_community.network.edgeos_facts_payload_pdhPnf/ansible_community.network.edgeos_facts_payload.zip/ansible/module_utils/connection.py\", line 185, in __rpc__\nansible.module_utils.connection.ConnectionError: timed out\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
felixfontein commented 4 years ago

It could be that this was fixed in #120 by @ganeshrn. The fix will be included in the next community.network release (scheduled for end of November).

NoxInmortus commented 4 years ago

Hello @felixfontein is there a way to test it ?

felixfontein commented 4 years ago

@NoxInmortus the easiest is probably to create a directory collections/ansible_collections/community/ relative to your playbook, and inside there clone this repository as network (i.e. it is checked out as collections/ansible_collections/community/network/, and there for example is a file collections/ansible_collections/community/network/galaxy.yml) (if you have git installed: run git clone https://github.com/ansible-collections/community.network.git network in the collections/ansible_collections/community/ directory). When running your playbook, ansible will then use the local copy of the collection instead of the one installed. When you're done testing, you can also just delete that directory again.

NoxInmortus commented 4 years ago

Hello @felixfontein,

it did not work but I had more details in the stderr and it seems that the root of my problem was a DNS issue. After fixing it and testing my playbook again with the latest release (and not the current master branch), it worked as well.

Resolved then.

thanks for the help

felixfontein commented 4 years ago

@NoxInmortus I'm glad it's now working for you :)