Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot pull all facts with nxos_facts #18968

Closed
jean-christophe-manciot opened this issue Dec 8, 2016 · 32 comments
Closed

Cannot pull all facts with nxos_facts #18968

jean-christophe-manciot opened this issue Dec 8, 2016 · 32 comments
Assignees
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. cisco Cisco technologies module This issue/PR relates to a module. networking Network category nxos Cisco NXOS community P2 Priority 2 - Issue Blocks Release
Milestone

Comments

@jean-christophe-manciot
Copy link

jean-christophe-manciot commented Dec 8, 2016

ISSUE TYPE
  • Bug Report
COMPONENT NAME

nxos_facts

ANSIBLE VERSION
ansible --version
2.3.0 (commit c064dce)
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
or
2.2.1.0-1
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION

inventory = ./hosts
gathering = explicit
roles_path = /home/actionmystique/Program-Files/Ubuntu/Ansible/git-Ansible/roles
private_role_vars = yes
log_path = /var/log/ansible.log
fact_caching = redis
fact_caching_timeout = 86400
retry_files_enabled = False

OS / ENVIRONMENT
  • Local host: Ubuntu 16.04 4.4.0
  • Target nodes: NX-OSv 7.3(0)D1(1) (last release available in Cisco VIRL)
SUMMARY

Running nxos_facts triggers a fatal error (connection timeout), whereas I can manually login into the target node with SSH or run nxos-feature on the same targets.

STEPS TO REPRODUCE
- include_vars: "../defaults/{{ os_family }}/http.yml"
- include_vars: "../defaults/{{ os_family }}/connections.yml"

- name: Fetching facts from the remote node
  nxos_facts:
        gather_subset: all
        provider: "{{ connections.nxapi }}"
  register: return
EXPECTED RESULTS

Successful nxos_facts

ACTUAL RESULTS
TASK [nxos_pull_facts : Fetching facts from the remote node] *******************
task path: /home/actionmystique/Program-Files/Ubuntu/Ansible/Roles/roles/nxos_pull_facts/tasks/main.yml:74
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/network/nxos/nxos_facts.py
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/network/nxos/nxos_facts.py
<172.21.100.12> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.21.100.12> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476884246.75-158252726280111 `" && echo ansible-tmp-1476884246.75-158252726280111="` echo $HOME/.ansible/tmp/ansible-tmp-1476884246.75-158252726280111 `" ) && sleep 0'
<172.21.100.11> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.21.100.11> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476884246.75-116017618040720 `" && echo ansible-tmp-1476884246.75-116017618040720="` echo $HOME/.ansible/tmp/ansible-tmp-1476884246.75-116017618040720 `" ) && sleep 0'
<172.21.100.12> PUT /tmp/tmpbsH8md TO /root/.ansible/tmp/ansible-tmp-1476884246.75-158252726280111/nxos_facts.py
<172.21.100.11> PUT /tmp/tmpiPM3JI TO /root/.ansible/tmp/ansible-tmp-1476884246.75-116017618040720/nxos_facts.py
<172.21.100.12> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1476884246.75-158252726280111/ /root/.ansible/tmp/ansible-tmp-1476884246.75-158252726280111/nxos_facts.py && sleep 0'
<172.21.100.11> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1476884246.75-116017618040720/ /root/.ansible/tmp/ansible-tmp-1476884246.75-116017618040720/nxos_facts.py && sleep 0'
<172.21.100.12> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1476884246.75-158252726280111/nxos_facts.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1476884246.75-158252726280111/" > /dev/null 2>&1 && sleep 0'
<172.21.100.11> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1476884246.75-116017618040720/nxos_facts.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1476884246.75-116017618040720/" > /dev/null 2>&1 && sleep 0'
fatal: [NX_OSv_Spine_11]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "auth_pass": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "authorize": false, 
            "gather_subset": [
                "all"
            ], 
            "host": "172.21.100.11", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": 8080, 
            "provider": {
                "auth_pass": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "host": "172.21.100.11", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "port": "8080", 
                "transport": "nxapi", 
                "use_ssl": false, 
                "username": "admin", 
                "validate_certs": false
            }, 
            "ssh_keyfile": null, 
            "timeout": 10, 
            "transport": "nxapi", 
            "use_ssl": false, 
            "username": "admin", 
            "validate_certs": false
        }, 
        "module_name": "nxos_facts"
    }, 
    "msg": "Connection failure: timed out", 
    "status": -1, 
    "url": "http://172.21.100.11:8080/ins"
}
@jean-christophe-manciot
Copy link
Author

This issue has been originally posted in ansible//ansible-modules-core here.

@ansibot ansibot added module This issue/PR relates to a module. plugin affects_2.3 This issue/PR affects Ansible v2.3 networking Network category labels Dec 13, 2016
@ansibot
Copy link
Contributor

ansibot commented Dec 19, 2016

@ansibot ansibot assigned privateip, gundalow and Qalthos and unassigned privateip Dec 19, 2016
@jimi-c jimi-c removed the plugin label Jan 4, 2017
@Qalthos Qalthos removed their assignment Jan 26, 2017
@ktbyers
Copy link

ktbyers commented Feb 16, 2017

Some more information (as I think it is the same issue):

$ ansible --version
ansible 2.2.1.0
  config file = /home/gituser/.ansible.cfg
  configured module search path = Default w/o overrides

This playbook works totally fine:

$ cat nxos_test.yml 
---
- hosts: nxos
  vars: 
    my_creds:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"
      transport: nxapi

  tasks:
    - nxos_facts:
        provider: "{{ my_creds }}"
#        gather_subset: all
        use_ssl: yes
        port: 8443
        validate_certs: False
      register: output

#    - debug: msg="{{ output }}"
$ ansible-playbook nxos_test.yml -i ./ansible-hosts 

PLAY [nxos] ********************************************************************

TASK [setup] *******************************************************************
ok: [spine1]
ok: [spine2]

TASK [nxos_facts] **************************************************************
ok: [spine2]
ok: [spine1]

PLAY RECAP *********************************************************************
spine1                     : ok=2    changed=0    unreachable=0    failed=0   
spine2                     : ok=2    changed=0    unreachable=0    failed=0   

But if I uncomment gather_subset: all it fails:

---
- hosts: nxos
  vars: 
    my_creds:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"
      transport: nxapi

  tasks:
    - nxos_facts:
        provider: "{{ my_creds }}"
        gather_subset: all
        use_ssl: yes
        port: 8443
        validate_certs: False
      register: output

#    - debug: msg="{{ output }}"
$ ansible-playbook -vvvv nxos_test.yml -i ./ansible-hosts 
Using /home/gituser/.ansible.cfg as config file
Loading callback plugin default of type stdout, v2.0 from /home/gituser/VENV/ansible_test/local/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: nxos_test.yml ********************************************************
1 plays in nxos_test.yml

PLAY [nxos] ********************************************************************

TASK [setup] *******************************************************************
Using module file /home/gituser/VENV/ansible_test/local/lib/python2.7/site-packages/ansible/modules/core/system/setup.py
<34.200.66.84> ESTABLISH LOCAL CONNECTION FOR USER: gituser
<34.200.66.84> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1487281161.52-219940831249397 `" && echo ansible-tmp-1487281161.52-219940831249397="` echo ~/.ansible/tmp/ansible-tmp-1487281161.52-219940831249397 `" ) && sleep 0'
Using module file /home/gituser/VENV/ansible_test/local/lib/python2.7/site-packages/ansible/modules/core/system/setup.py
<34.198.59.49> ESTABLISH LOCAL CONNECTION FOR USER: gituser
<34.198.59.49> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1487281161.53-91647933988368 `" && echo ansible-tmp-1487281161.53-91647933988368="` echo ~/.ansible/tmp/ansible-tmp-1487281161.53-91647933988368 `" ) && sleep 0'
<34.200.66.84> PUT /tmp/tmpnNRhp1 TO /home/gituser/.ansible/tmp/ansible-tmp-1487281161.52-219940831249397/setup.py
<34.200.66.84> EXEC /bin/sh -c 'chmod u+x /home/gituser/.ansible/tmp/ansible-tmp-1487281161.52-219940831249397/ /home/gituser/.ansible/tmp/ansible-tmp-1487281161.52-219940831249397/setup.py && sleep 0'
<34.198.59.49> PUT /tmp/tmpvEycoO TO /home/gituser/.ansible/tmp/ansible-tmp-1487281161.53-91647933988368/setup.py
<34.198.59.49> EXEC /bin/sh -c 'chmod u+x /home/gituser/.ansible/tmp/ansible-tmp-1487281161.53-91647933988368/ /home/gituser/.ansible/tmp/ansible-tmp-1487281161.53-91647933988368/setup.py && sleep 0'
<34.200.66.84> EXEC /bin/sh -c '/home/gituser/VENV/ansible_test/bin/python /home/gituser/.ansible/tmp/ansible-tmp-1487281161.52-219940831249397/setup.py; rm -rf "/home/gituser/.ansible/tmp/ansible-tmp-1487281161.52-219940831249397/" > /dev/null 2>&1 && sleep 0'
<34.198.59.49> EXEC /bin/sh -c '/home/gituser/VENV/ansible_test/bin/python /home/gituser/.ansible/tmp/ansible-tmp-1487281161.53-91647933988368/setup.py; rm -rf "/home/gituser/.ansible/tmp/ansible-tmp-1487281161.53-91647933988368/" > /dev/null 2>&1 && sleep 0'
ok: [spine1]
ok: [spine2]

TASK [nxos_facts] **************************************************************
task path: /home/gituser/ansible_test/nxos_test.yml:11
Using module file /home/gituser/VENV/ansible_test/local/lib/python2.7/site-packages/ansible/modules/core/network/nxos/nxos_facts.py
<34.200.66.84> ESTABLISH LOCAL CONNECTION FOR USER: gituser
<34.200.66.84> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1487281163.27-16555670391879 `" && echo ansible-tmp-1487281163.27-16555670391879="` echo ~/.ansible/tmp/ansible-tmp-1487281163.27-16555670391879 `" ) && sleep 0'
Using module file /home/gituser/VENV/ansible_test/local/lib/python2.7/site-packages/ansible/modules/core/network/nxos/nxos_facts.py
<34.198.59.49> ESTABLISH LOCAL CONNECTION FOR USER: gituser
<34.198.59.49> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1487281163.27-194136649114366 `" && echo ansible-tmp-1487281163.27-194136649114366="` echo ~/.ansible/tmp/ansible-tmp-1487281163.27-194136649114366 `" ) && sleep 0'
<34.200.66.84> PUT /tmp/tmpl5kEK8 TO /home/gituser/.ansible/tmp/ansible-tmp-1487281163.27-16555670391879/nxos_facts.py
<34.200.66.84> EXEC /bin/sh -c 'chmod u+x /home/gituser/.ansible/tmp/ansible-tmp-1487281163.27-16555670391879/ /home/gituser/.ansible/tmp/ansible-tmp-1487281163.27-16555670391879/nxos_facts.py && sleep 0'
<34.198.59.49> PUT /tmp/tmpa50nS7 TO /home/gituser/.ansible/tmp/ansible-tmp-1487281163.27-194136649114366/nxos_facts.py
<34.198.59.49> EXEC /bin/sh -c 'chmod u+x /home/gituser/.ansible/tmp/ansible-tmp-1487281163.27-194136649114366/ /home/gituser/.ansible/tmp/ansible-tmp-1487281163.27-194136649114366/nxos_facts.py && sleep 0'
<34.200.66.84> EXEC /bin/sh -c '/home/gituser/VENV/ansible_test/bin/python /home/gituser/.ansible/tmp/ansible-tmp-1487281163.27-16555670391879/nxos_facts.py; rm -rf "/home/gituser/.ansible/tmp/ansible-tmp-1487281163.27-16555670391879/" > /dev/null 2>&1 && sleep 0'
<34.198.59.49> EXEC /bin/sh -c '/home/gituser/VENV/ansible_test/bin/python /home/gituser/.ansible/tmp/ansible-tmp-1487281163.27-194136649114366/nxos_facts.py; rm -rf "/home/gituser/.ansible/tmp/ansible-tmp-1487281163.27-194136649114366/" > /dev/null 2>&1 && sleep 0'
fatal: [spine2]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "auth_pass": null, 
            "authorize": false, 
            "gather_subset": [
                "all"
            ], 
            "host": "34.200.66.84", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": 8443, 
            "provider": {
                "host": "34.200.66.84", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "transport": "nxapi", 
                "username": "pyclass"
            }, 
            "ssh_keyfile": null, 
            "timeout": 10, 
            "transport": "nxapi", 
            "use_ssl": true, 
            "username": "pyclass", 
            "validate_certs": false
        }, 
        "module_name": "nxos_facts"
    }, 
    "msg": "Connection failure: ('The read operation timed out',)", 
    "status": -1, 
    "url": "https://34.200.66.84:8443/ins"
}
fatal: [spine1]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "auth_pass": null, 
            "authorize": false, 
            "gather_subset": [
                "all"
            ], 
            "host": "34.198.59.49", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": 8443, 
            "provider": {
                "host": "34.198.59.49", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "transport": "nxapi", 
                "username": "pyclass"
            }, 
            "ssh_keyfile": null, 
            "timeout": 10, 
            "transport": "nxapi", 
            "use_ssl": true, 
            "username": "pyclass", 
            "validate_certs": false
        }, 
        "module_name": "nxos_facts"
    }, 
    "msg": "Connection failure: ('The read operation timed out',)", 
    "status": -1, 
    "url": "https://34.198.59.49:8443/ins"
}
	to retry, use: --limit @/home/gituser/ansible_test/nxos_test.retry

PLAY RECAP *********************************************************************
spine1                     : ok=1    changed=0    unreachable=0    failed=1   
spine2                     : ok=1    changed=0    unreachable=0    failed=1 

@gundalow gundalow added this to the 2.3.0 milestone Feb 16, 2017
@jean-christophe-manciot
Copy link
Author

The module documentation talks about a new timeout field which should be increased with NXAPI, especially when trying to gather all facts.

Unfortunately, we cannot test that with the last devel version (2.3.0~git20170220.7bc7f1385) which cannot even establish a correct NXAPI connection with the target with exactly the same parameters as the ones used with 2.2.1.0-1:
Using the following provider:

        nxapi:
          transport: nxapi
          host: "{{ ansible_host }}"
          # ansible_port
          port: "{{ http.port }}"
          # ansible_user
          username: admin
          password: ************
          # enable_secret_password
          auth_pass: ************
          # http or https
          use_ssl: no
          validate_certs: "{{ https.validate_certs }}"
          timeout: 60
  1. With 2.3.0~git20170220.7bc7f1385
TASK [nxos_pull_facts : Fetching facts from the remote node] ****************************************************************************************************************
task path: /home/actionmystique/Program-Files/Ubuntu/Ansible/Roles/roles/nxos_pull_facts/tasks/main.yml:77
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/network/nxos/nxos_facts.py
<172.21.100.11> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.21.100.11> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
fatal: [NX_OSv_Spine_11]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "auth_pass": null, 
            "authorize": false, 
            "gather_subset": [
                "all"
            ], 
            "host": "172.21.100.11", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": 8080, 
            "provider": {
                "host": "172.21.100.11", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "port": "8080", 
                "timeout": 60, 
                "use_ssl": false, 
                "username": "admin", 
                "validate_certs": true
            }, 
            "ssh_keyfile": null, 
            "timeout": 60, 
            "transport": null, 
            "username": "admin"
        }
    }, 
    "msg": "Unknown transport or no default transport specified"
}
  1. With 2.2.1.0-1
TASK [nxos_pull_facts : Fetching facts from the remote node] *******************
task path: /home/actionmystique/Program-Files/Ubuntu/Ansible/Roles/roles/nxos_pull_facts/tasks/main.yml:77
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/core/network/nxos/nxos_facts.py
<172.21.100.11> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.21.100.11> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
fatal: [NX_OSv_Spine_11]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "auth_pass": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "authorize": false, 
            "gather_subset": [
                "all"
            ], 
            "host": "172.21.100.11", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": 8080, 
            "provider": {
                "auth_pass": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "host": "172.21.100.11", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "port": "8080", 
                "timeout": 60, 
                "transport": "nxapi", 
                "use_ssl": false, 
                "username": "admin", 
                "validate_certs": false
            }, 
            "ssh_keyfile": null, 
            "timeout": 60, 
            "transport": "nxapi", 
            "use_ssl": false, 
            "username": "admin", 
            "validate_certs": false
        }, 
        "module_name": "nxos_facts"
    }, 
    "msg": "Connection failure: timed out", 
    "status": -1, 
    "url": "http://172.21.100.11:8080/ins"
}

@privateip
Copy link
Contributor

privateip commented Feb 23, 2017

#21811

Please confirm the fix and either close or update the issue

@jean-christophe-manciot
Copy link
Author

jean-christophe-manciot commented Feb 23, 2017

Unfortunately, it's not solved with:

- name: Fetching facts from the remote node
  nxos_facts:
        gather_subset: all
        provider: "{{ connections.nxapi }}"
  register: facts
TASK [nxos_pull_facts : Fetching facts from the remote node] ****************************************************************************************************************
task path: /home/actionmystique/Program-Files/Ubuntu/Ansible/Roles/roles/nxos_pull_facts/tasks/main.yml:77
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/network/nxos/nxos_facts.py
<172.21.100.11> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.21.100.11> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
fatal: [NX_OSv_Spine_11]: FAILED! => {
    "changed": false, 
    "clierror": "       4096    Feb 25 20:49:04 2016  .patch/\n        383    Nov 16 17:59:15 2016  NX_OSv_Spine_11_rsakey.pub\n        401    Nov 16 17:59:19 2016  ********_rsakey.pub\n      16384    Feb 25 20:44:49 2016  lost+found/\n       4096    Feb 26 10:11:16 2016  scripts/\n   336153********    Feb 11 13:19:49 2016  titanium-d1-kickstart.7.3.0.D1.1.bin\n  139230420    Feb 11 13:19:50 2016  titanium-d1.7.3.0.D1.1.bin\n       4096    Feb 25 20:49:07 2016  virtual-instance/\n\nUsage for bootflash://\n  369967104 bytes used\n 2839994368 bytes free\n 3209961472 bytes total\n", 
    "code": "501", 
    "failed": true, 
    "input": "dir", 
    "invocation": {
        "module_args": {
            "gather_subset": [
                "all"
            ], 
            "host": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "provider": {
                "host": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "port": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "timeout": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "transport": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "use_ssl": false, 
                "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "validate_certs": true
            }, 
            "ssh_keyfile": null, 
            "timeout": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "transport": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "use_ssl": false, 
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "validate_certs": true
        }
    }, 
    "msg": "Structured output unsupported", 
    "output": {
        "clierror": "       4096    Feb 25 20:49:04 2016  .patch/\n        383    Nov 16 17:59:15 2016  NX_OSv_Spine_11_rsakey.pub\n        401    Nov 16 17:59:19 2016  ********_rsakey.pub\n      16384    Feb 25 20:44:49 2016  lost+found/\n       4096    Feb 26 10:11:16 2016  scripts/\n   336153********    Feb 11 13:19:49 2016  titanium-d1-kickstart.7.3.0.D1.1.bin\n  139230420    Feb 11 13:19:50 2016  titanium-d1.7.3.0.D1.1.bin\n       4096    Feb 25 20:49:07 2016  virtual-instance/\n\nUsage for bootflash://\n  369967104 bytes used\n 2839994368 bytes free\n 3209961472 bytes total\n", 
        "code": "501", 
        "input": "dir", 
        "msg": "Structured output unsupported"
    }, 
    "url": "http://********:********/ins"
}

@ansibot ansibot closed this as completed Feb 23, 2017
@jean-christophe-manciot
Copy link
Author

@privateip There's even an issue with your bot.

@gundalow gundalow reopened this Feb 23, 2017
@gundalow
Copy link
Contributor

@jean-christophe-manciot It was closed as the PR was merged. I've reopen it noe

@ansibot ansibot closed this as completed Feb 23, 2017
@gundalow gundalow reopened this Feb 23, 2017
@privateip
Copy link
Contributor

I was able to replicate the issue merged #21954 to fix it. All nxos_facts integration tests are now passing

@jean-christophe-manciot
Copy link
Author

The issue is still there when trying to pull all facts with a Structured output unsupported error msg:

TASK [nxos_pull_facts : Fetching facts from the remote node] ****************************************************************************************************************
task path: /home/actionmystique/Program-Files/Ubuntu/Ansible/Roles/roles/nxos_pull_facts/tasks/main.yml:77
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/network/nxos/nxos_facts.py
<172.21.100.12> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.21.100.12> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
fatal: [NX_OSv_Spine_12]: FAILED! => {
    "changed": false, 
    "clierror": "       4096    Feb 25 20:49:04 2016  .patch/\n        383    Feb 23 18:29:38 2017  NX_OSv_Spine_12_rsakey.pub\n        401    Feb 23 18:29:43 2017  ********_rsakey.pub\n      16384    Feb 25 20:44:49 2016  lost+found/\n       4096    Feb 26 10:11:16 2016  scripts/\n   336153********    Feb 11 13:19:49 2016  titanium-d1-kickstart.7.3.0.D1.1.bin\n  139230420    Feb 11 13:19:50 2016  titanium-d1.7.3.0.D1.1.bin\n       4096    Feb 25 20:49:07 2016  virtual-instance/\n\nUsage for bootflash://\n  369967104 bytes used\n 2839994368 bytes free\n 3209961472 bytes total\n", 
    "code": "501", 
    "failed": true, 
    "input": "dir", 
    "invocation": {
        "module_args": {
            "gather_subset": [
                "all"
            ], 
            "host": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "provider": {
                "host": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "port": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "timeout": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "transport": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "use_ssl": false, 
                "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "validate_certs": true
            }, 
            "ssh_keyfile": null, 
            "timeout": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "transport": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "use_ssl": false, 
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "validate_certs": true
        }
    }, 
    "msg": "Structured output unsupported", 
    "output": {
        "clierror": "       4096    Feb 25 20:49:04 2016  .patch/\n        383    Feb 23 18:29:38 2017  NX_OSv_Spine_12_rsakey.pub\n        401    Feb 23 18:29:43 2017  ********_rsakey.pub\n      16384    Feb 25 20:44:49 2016  lost+found/\n       4096    Feb 26 10:11:16 2016  scripts/\n   336153********    Feb 11 13:19:49 2016  titanium-d1-kickstart.7.3.0.D1.1.bin\n  139230420    Feb 11 13:19:50 2016  titanium-d1.7.3.0.D1.1.bin\n       4096    Feb 25 20:49:07 2016  virtual-instance/\n\nUsage for bootflash://\n  369967104 bytes used\n 2839994368 bytes free\n 3209961472 bytes total\n", 
        "code": "501", 
        "input": "dir", 
        "msg": "Structured output unsupported"
    }, 
    "url": "http://********:********/ins"
}

@gundalow gundalow added the P2 Priority 2 - Issue Blocks Release label Mar 6, 2017
@wrouesnel
Copy link
Contributor

+1 I can confirm this is a problem as well when using the cli module on the current devel head.

Additionally, it looks like the devel head has some very broken commits in it (global name out) not found.

@privateip
Copy link
Contributor

PR #22923 should fix up these issues

@calfonso
Copy link
Contributor

@jean-christophe-manciot @wrouesnel the PR is merged, do you have time to take it for a spin and report on if the issue is resolved?

@wrouesnel
Copy link
Contributor

I can test with an NX 9000 next week.

@gundalow
Copy link
Contributor

@wrouesnel Thank would be great, thanks

@jean-christophe-manciot
Copy link
Author

jean-christophe-manciot commented Mar 27, 2017

@privateip @gundalow @calfonso
Yes, finally 🙂
With latest ansible from pip install git+git://github.com/ansible/ansible.git@devel:

# ansible --version
ansible 2.4.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
  python version = 2.7.12+ (default, Sep 17 2016, 12:08:02) [GCC 6.2.0 20160914]

On NX-OSv 7000 7.3(0)D1(1)
I am able to pull all facts:

{
    "ansible_net_all_ipv4_addresses": [
        "172.21.100.11"
    ],
    "ansible_net_all_ipv6_addresses": [],
    "ansible_net_config": "!Command: show running-config
!Time: Mon Mar 27 16:21:35 2017
version 7.3(0)D1(1)
...
    "ansible_net_filesystems": [
        "bootflash:"
    ],
    "ansible_net_gather_subset": [
        "hardware",
        "default",
        "interfaces",
        "legacy",
        "config"
    ],
    "ansible_net_hostname": "NX_OSv_Spine_11",
    "ansible_net_image": "bootflash:///titanium-d1.7.3.0.D1.1.bin",
    "ansible_net_interfaces": {
...

Same success on NX-OSv 9000 7.0(3)I5(1).

As far as I'm concerned, this issue is solved.
However, we should probably wait for @wrouesnel for tests on physical Nexus 93xx or 95xx before closing this.

@gundalow
Copy link
Contributor

@jean-christophe-manciot Thank you for testing this.

Will wait for final confirmation from @wrouesnel

@calfonso
Copy link
Contributor

@wrouesnel Any feedback on this fix?

@wrouesnel
Copy link
Contributor

Checking PR 21811, it looks like the module isn't working at all?

My test playbook:

---
- hosts: tor-switches
  connection: local
  gather_facts: false

  tasks:
  - name: gather facts
    nxos_facts:
      gather_subset: all
      host: #censored, an ip address#
      username: will
      ssh_keyfile: /home/will/.ssh/id_rsa
      transport: cli
      port: 22

Blows up with a traceback:

An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_byAPHm/ansible_module_nxos_facts.py", line 184, in <module>
    from ansible.module_utils.network_common import exec_command
ImportError: cannot import name exec_command

fatal: [sop-sw-n5-2]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_byAPHm/ansible_module_nxos_facts.py\", line 184, in <module>\n    from ansible.module_utils.network_common import exec_command\nImportError: cannot import name exec_command\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

My ansible working dir:

~/src/ansible-work/ansible $ git status
HEAD detached at upstream/pr/21811/head
nothing to commit, working tree clean

@wrouesnel
Copy link
Contributor

Similarly with the current @devel HEAD:

The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_gEC6tF/ansible_module_nxos_facts.py", line 517, in <module>
    main()
  File "/tmp/ansible_gEC6tF/ansible_module_nxos_facts.py", line 500, in main
    inst.populate()
  File "/tmp/ansible_gEC6tF/ansible_module_nxos_facts.py", line 299, in populate
    self.facts['neighbors'] = self.populate_neighbors(data)
  File "/tmp/ansible_gEC6tF/ansible_module_nxos_facts.py", line 323, in populate_neighbors
    data = data['TABLE_nbor']['ROW_nbor']
TypeError: string indices must be integers, not str

fatal: [sop-sw-n6-1]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_gEC6tF/ansible_module_nxos_facts.py\", line 517, in <module>\n    main()\n  File \"/tmp/ansible_gEC6tF/ansible_module_nxos_facts.py\", line 500, in main\n    inst.populate()\n  File \"/tmp/ansible_gEC6tF/ansible_module_nxos_facts.py\", line 299, in populate\n    self.facts['neighbors'] = self.populate_neighbors(data)\n  File \"/tmp/ansible_gEC6tF/ansible_module_nxos_facts.py\", line 323, in populate_neighbors\n    data = data['TABLE_nbor']['ROW_nbor']\nTypeError: string indices must be integers, not str\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

@ansibot
Copy link
Contributor

ansibot commented Mar 29, 2017

@privateip
Copy link
Contributor

@wrouesnel what is PR 21811?

PR #22923 is the one that fixes nxos_facts although now its merged so you can run directly from devel or stable-2.3

I see the error in the second comment and will address shortly

@wrouesnel
Copy link
Contributor

Apparently I'm an idiot and pulled entirely the wrong thing this morning, so ignore that first part. The second error is from devel though so is definitely real.

@jean-christophe-manciot
Copy link
Author

@wrouesnel Have you tried with transport: nxapi?

@wrouesnel
Copy link
Contributor

Our switches don't have the nxapi switched on at the moment. The module claims to support the cli transport, which is what we'd like to use. If it doesn't support this the error should definitely be more specific.

@privateip
Copy link
Contributor

@wrouesnel replicated and fixing it now ... should have a PR posted in the next hour or so

@wrouesnel
Copy link
Contributor

Awesome. It'll be about 10 hours before I'm on the same network as our nx9ks again.

@privateip
Copy link
Contributor

@wrouesnel #23134

@privateip
Copy link
Contributor

PR has been merged into devel and will be part of the next 2.3 RC

@wrouesnel
Copy link
Contributor

Fixed with the cli provider and Cisco 9k switch - thanks!

@calfonso
Copy link
Contributor

@wrouesnel thanks for testing, closing the issue.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@dagwieers dagwieers added nxos Cisco NXOS community cisco Cisco technologies labels Feb 22, 2019
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. cisco Cisco technologies module This issue/PR relates to a module. networking Network category nxos Cisco NXOS community P2 Priority 2 - Issue Blocks Release
Projects
None yet
Development

No branches or pull requests