Skip to content
New issue

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

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

Already on GitHub? # to your account

show_lldp_neighbors.template failing when switch + domain name is > 19 characters #375

Closed
jvanderaa opened this issue Feb 24, 2019 · 0 comments · Fixed by #376
Closed

show_lldp_neighbors.template failing when switch + domain name is > 19 characters #375

jvanderaa opened this issue Feb 24, 2019 · 0 comments · Fixed by #376

Comments

@jvanderaa
Copy link
Contributor

ISSUE TYPE
  • Bug Report
TEMPLATE USING

cisco_ios_show_lldp_neighbors

Value Required NEIGHBOR (\S+)
Value Required LOCAL_INTERFACE (\S+)
Value Required NEIGHBOR_INTERFACE (\S+)

Start
  ^Device.*ID -> LLDP

LLDP
  ^${NEIGHBOR}\s+${LOCAL_INTERFACE}\s+\d+\s+(\S+)*\s+${NEIGHBOR_INTERFACE} -> Record
  ^${NEIGHBOR}
  ^\s+${LOCAL_INTERFACE}\s+\d+\s+(\S+)*\s+${NEIGHBOR_INTERFACE} -> Record
SAMPLE COMMAND OUTPUT
#show lldp neigh
Capability codes:
    (R) Router, (B) Bridge, (T) Telephone, (C) DOCSIS Cable Device
    (W) WLAN Access Point, (P) Repeater, (S) Station, (O) Other

Device ID           Local Intf     Hold-time  Capability      Port ID
long_name_swt.josh-vGi0/2          120        R               Gi0/0

Total entries displayed: 1
SUMMARY

When the hostname + domain name gets long the lldp neighbor output truncates at 20 characters. The result is no record being created and getting a blank completion.

Sample output of NTC Templates with network engine as is:

TASK [CLI >> Get LLDP neighbors] *********************************************************************************************************************************************************************************
ok: [rtr01]

TASK [SYS >> Parse LLDP Information] *****************************************************************************************************************************************************************************
ok: [rtr01]

TASK [DEBUG >> LLDP Neighbors] ***********************************************************************************************************************************************************************************
ok: [rtr01] => {
    "msg": []
}

PLAY RECAP *******************************************************************************************************************************************************************************************************
rtr01                      : ok=3    changed=0    unreachable=0    failed=0
STEPS TO REPRODUCE
- name: Switch config
  connection: network_cli
  hosts: cisco_routers
  gather_facts: no
  become: yes
  become_method: enable
  roles:
    - ansible-network.network-engine

  tasks:

    - name: CLI >> Get LLDP neighbors
      ios_command:
        commands:
          - show lldp neighbors
      register: command_output

    - name: SYS >> Parse LLDP Information
      textfsm_parser:
        file: "/opt/ntc-templates/templates/cisco_ios_show_lldp_neighbors.template"
        content: "{{ command_output.stdout[0] }}"
        name: lldp_facts

    - name: DEBUG >> LLDP Neighbors
      debug:
        msg: "{{ ansible_facts.lldp_facts }}"
EXPECTED RESULTS

I expect to see a neighbor in the output

ACTUAL RESULTS

I got a blank facts set as shown above.

jmcgill298 pushed a commit that referenced this issue Feb 25, 2019
Fix template not accounting for neighbor name running into interface name.

TEMPLATE UPDATES:
  - Limit `NEIGHBOR` capture group to first 20 non-space characters.
  - Change space capture from being required to being allowed

TEST UPDATES:
  - Add new raw/parsed files to account for additional output
jvanderaa added a commit that referenced this issue Nov 10, 2021
Fix template not accounting for neighbor name running into interface name.

TEMPLATE UPDATES:
  - Limit `NEIGHBOR` capture group to first 20 non-space characters.
  - Change space capture from being required to being allowed

TEST UPDATES:
  - Add new raw/parsed files to account for additional output
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant