cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2083
Views
25
Helpful
5
Replies

Ansible gather_subset for NXOS failing with command timeout triggered

secureB00T
Level 1
Level 1

Hi all, 

Hopefully someone might be able to help out. I've been wrestling with this for a while.  I'm fairly new to ansible and trying to run a playbook against a pair of nexus switches that will change the description of ports based on the information it gets from cisco.nxos.nxos_facts ( using cdp neighbor information).  I've run this in a lab environment successfully but when running against our live environment, it fails.  

This is the playbook i'm trying to run:

********************************************************************************************************************************

---
- name: Set interface description based on CDP/LLDP discovery
  hosts: SDS
  gather_facts: yes
  connection: network_cli

  tasks:

  - name: GATHER ALL NXOS LEGACY FACTS
    cisco.nxos.nxos_facts:
      gather_subset:
        - all
      gather_network_resources:
        - all

# log messages to specified folder
    vars:
      ansible_persistent_log_messages: True

  - name: VIEW facts gathered
    debug:
      var: ansible_facts.keys()

  - name: VIEW CDP/LLDP NEIGHBORS
    debug:
      var: ansible_facts.net_neighbors

#  - name:  SET NXOS INTERFACE DESCRIPTIONS
#    nxos_config:
#      lines:
#        - description {{item.value[0].host.split('.').0}}:{{item.value[0].port[0:3]}}{{item.value[0].port.split('t')[-1]}}
#      parents: interface {{item.key}}
#      save_when:  changed
#    with_dict:  "{{ansible_facts.net_neighbors}}"
#    when: ansible_network_os == 'nxos'
 
********************************************************************************************************************************
 
I've commented out the bottom portion until I get the 'gather_subset' part working.  in the meantime, the error messages I get are these:
 
********************************************************************************************************************************

The full traceback is:
File "/home/administrator/.ansible/collections/ansible_collections/cisco/nxos/plugins/module_utils/network/nxos/nxos.py", line 127, in run_commands
out = connection.run_commands(commands, check_rc)
File "/usr/lib/python3/dist-packages/ansible/module_utils/connection.py", line 200, in __rpc__
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [SDS01]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"available_network_resources": false,
"gather_network_resources": [
"all"
],
"gather_subset": [
"all"
]
}
},
"msg": "command timeout triggered, timeout value is 30 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide.",
"warnings": [
"** 'feature telemetry' is not enabled. Module will auto-enable feature telemetry ** "
]
}
<172.17.252.72> ANSIBLE_NETWORK_IMPORT_MODULES: complete
The full traceback is:
File "/home/administrator/.ansible/collections/ansible_collections/cisco/nxos/plugins/module_utils/network/nxos/nxos.py", line 127, in run_commands
out = connection.run_commands(commands, check_rc)
File "/usr/lib/python3/dist-packages/ansible/module_utils/connection.py", line 200, in __rpc__
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [SDS02]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"available_network_resources": false,
"gather_network_resources": [
"all"
],
"gather_subset": [
"all"
]
}
},
"msg": "command timeout triggered, timeout value is 30 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide.",
"warnings": [
"** 'feature telemetry' is not enabled. Module will auto-enable feature telemetry ** "
]
}

 ********************************************************************************************************************************

 

Sorry for the long information but hope this helps.  If you need some more information to assist, I'll be happy to provide it.  I've looked at documentation but like I said, I'm very new to ansible and still learning.  Thanks in advanced for your help.  

Roberto

2 Accepted Solutions

Accepted Solutions

Marcel Zehnder
Spotlight
Spotlight

Hi

Increase the command timeout, see https://docs.ansible.com/ansible/latest/network/getting_started/network_connection_options.html

I prefer using a local ansible.cfg in the root of every project folder:

[persistent_connection]
command_timeout = 240

But all the options described in the link above will work.

HTH

View solution in original post

Hi the ansible_network_os is 'cisco.nxos.nxos' not 'nxos'.

hth

Marcel

View solution in original post

5 Replies 5

Marcel Zehnder
Spotlight
Spotlight

Hi

Increase the command timeout, see https://docs.ansible.com/ansible/latest/network/getting_started/network_connection_options.html

I prefer using a local ansible.cfg in the root of every project folder:

[persistent_connection]
command_timeout = 240

But all the options described in the link above will work.

HTH

Hi @Marcel Zehnder ,

Thank you for your response!  I had actually tried this method of changing the time, and before i went up to 120.  I changed as you suggested to 'command_timeout = 240' and it worked!! So thank you for that, one step closer.  I guess it needed more time to gather facts since they are connected to A LOT of devices. 

Now the next step, is changing the ports description.  I uncommented those sections and the script gathered all the information but ended up 'skipping' the part for changing the ports. 

Here's a small snippet of a few interfaced that failed to change and the reason why:

skipping: [SDS-01] => (item={'key': 'Ethernet8/40', 'value': [{'port': 'TenGigabitEthernet1/1/4', 'host': 'SBS-I-20.company.com', 'sysname': 'SBS-I-20.company.com'}]}) => {
"ansible_loop_var": "item",
"changed": false,
"item": {
"key": "Ethernet8/40",
"value": [
{
"host": "SBS-I-20.company.com",
"port": "TenGigabitEthernet1/1/4",
"sysname": "SBS-I-20.company.com"
}
]
},
"skip_reason": "Conditional result was False"
}
skipping: [SDS-01] => (item={'key': 'Ethernet8/41', 'value': [{'port': 'TenGigabitEthernet1/1/3', 'host': 'SBS-K-10.company.com', 'sysname': 'SBS-K-10.company.com'}]}) => {
"ansible_loop_var": "item",
"changed": false,
"item": {
"key": "Ethernet8/41",
"value": [
{
"host": "SBS-K-10.company.com",
"port": "TenGigabitEthernet1/1/3",
"sysname": "SBS-K-10.company.com"
}
]
},
"skip_reason": "Conditional result was False"
}

***************************************

So basically, something in this task (shown below) is throwing off a condition and skipping the rest, but the only condition I can think of is "when: ansible_network_os == 'nxos'" .  

 

  - name:  SET NXOS INTERFACE DESCRIPTIONS
    nxos_config:
      lines:
        - description {{item.value[0].host.split('.').0}}:{{item.value[0].port[0:3]}}{{item.value[0].port.split('t')[-1]}}
      parents: interface {{item.key}}
      save_when:  changed
    with_dict:  "{{ansible_facts.net_neighbors}}"
    when: ansible_network_os == 'nxos'

Hi the ansible_network_os is 'cisco.nxos.nxos' not 'nxos'.

hth

Marcel

secureB00T
Level 1
Level 1

@Marcel Zehnder  

That was it!! Wow, just one little piece of syntax.  Awesome, got my script to run successfully, and ports labeled accordingly based on their cdp info.  I was working on it for quite a while, thanks a lot for your help, much appreciated!!

i'm glad if i could help.