ansible-collections/cisco.nxos

nxos_snmp_server : Integration CLI tests failed with The task includes an option with an undefined variable

brahmanim opened this issue · 2 comments

SUMMARY

The Integration tests failed with error: "The task includes an option with an undefined variable", at task Find admin user SNMP localized key (second)

ISSUE TYPE
  • Bug Report
COMPONENT NAME

cisco.nxos.nxos_snmp_server

ANSIBLE VERSION
2.14
COLLECTION VERSION
cisco.nxos 4.0.1
CONFIGURATION
None
OS / ENVIRONMENT
10.0.151.189# show version
Cisco Nexus Operating System (NX-OS) Software
TAC support: http://www.cisco.com/tac
Documents: http://www.cisco.com/en/US/products/ps9372/tsd_products_support_series_home.html
Copyright (c) 2002-2020, Cisco Systems, Inc. All rights reserved.
The copyrights to certain works contained herein are owned by
other third parties and are used and distributed under license.
Some parts of this software are covered under the GNU Public
License. A copy of the license is available at
http://www.gnu.org/licenses/gpl.html.

Nexus 9000v is a demo version of the Nexus Operating System

Software
BIOS: version
NXOS: version 9.3(6)
BIOS compile time:
NXOS image file is: bootflash:///nxos.9.3.6.bin
NXOS compile time: 11/9/2020 23:00:00 [11/10/2020 11:00:21]

Hardware
cisco Nexus9000 C9300v Chassis
with 8014220 kB of memory.
Processor Board ID 96JWKPHN2ZG

Device name: 10.0.151.189
bootflash: 4287040 kB
Kernel uptime is 3 day(s), 11 hour(s), 49 minute(s), 4 second(s)

Last reset
Reason: Unknown
System version:
Service:

plugin
Core Plugin, Ethernet Plugin

Active Package(s):
STEPS TO REPRODUCE

Run integration test, Task Find admin user SNMP localized key (second) failed with error The task includes an option with an undefined variable.

it seems like previous task that tries to Grep admin user SNMP localized key (second), returns empty string.

- name: Grep admin user SNMP localized key (second)
  ansible.builtin.set_fact:
    admin_snmp_passwd_2: "{{ result['stdout'][0] | regex_search('snmp-server user admin auth (md5|sha|sha-256) (\\S+)', '\\2') }}" # noqa var-spacing
EXPECTED RESULTS

admin_snmp_passwd_2 should include value

ACTUAL RESULTS
TASK [/usr/share/ansible/collections/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server : Grep admin user SNMP localized key (second)] ***
task path: /usr/share/ansible/collections/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/main.yaml:16
ok: [10.0.151.189] => {
    "ansible_facts": {
        "admin_snmp_passwd_2": ""
    },
    "changed": false
}
TASK [/usr/share/ansible/collections/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server : Find admin user SNMP localized key (second)] ***
task path: /usr/share/ansible/collections/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/main.yaml:20
fatal: [10.0.151.189]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: ansible.utils.unsafe_proxy.AnsibleUnsafeText object has no element 0. ansible.utils.unsafe_proxy.AnsibleUnsafeText object has no element 0\n\nThe error appears to be in '/usr/share/ansible/collections/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/main.yaml': line 20, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Find admin user SNMP localized key (second)\n  ^ here\n"
}TASK [/usr/share/ansible/collections/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server : Grep admin user SNMP localized key (second)] ***
task path: /usr/share/ansible/collections/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/main.yaml:16
ok: [10.0.151.189] => {
    "ansible_facts": {
        "admin_snmp_passwd_2": ""
    },
    "changed": false
}
TASK [/usr/share/ansible/collections/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server : Find admin user SNMP localized key (second)] ***
task path: /usr/share/ansible/collections/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/main.yaml:20
fatal: [10.0.151.189]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: ansible.utils.unsafe_proxy.AnsibleUnsafeText object has no element 0. ansible.utils.unsafe_proxy.AnsibleUnsafeText object has no element 0\n\nThe error appears to be in '/usr/share/ansible/collections/ansible_collections/cisco/nxos/tests/integration/targets/nxos_snmp_server/tasks/main.yaml': line 20, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Find admin user SNMP localized key (second)\n  ^ here\n"
}

With the changes added in #618 and the updates made to our downstream appliance, this should get resolved now. Please let me know if it works. Thank you.

The Cisco.NXOS downstream integration tests passed successfully.
Jenkins pipeline.
You can close this issue.