ansible-collections / cisco.ios

Ansible Network Collection for Cisco IOS
GNU General Public License v3.0
283 stars 168 forks source link

ios_command output duplicate lines #681

Open t-r3xous opened 1 year ago

t-r3xous commented 1 year ago
SUMMARY

Running a playbook task like:

tasks:
- name: Show configuration
cisco.ios.ios_command:
commands:
- 'show running-config'
register: show_run

For 3-4 routers out of 600 in inventory the first 100 to 500 lines are duplicated in the output {{ show_run.stdout[0] }}:

starting line1:

version 15.1
service timestamps debug datetime msec
service timestamps log datetime msec
service password encryption
!
hostname ....

and then line 107:
track102 ip sla 2
!
crypto keyring INTER_COUNTY
!
version 15.1
service timestamps debug datetime msec
service timestamps log datetime msec
service password encryption
!
hostname ....

I checked and this happens on routers running ios 12.x,15.x,16.x,17.x

ISSUE TYPE
COMPONENT NAME

ios_command

ANSIBLE VERSION
ansible [core 2.13.5]
  config file = /opt/ansible/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/ansible/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = ../bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
# /opt/ansible/lib/python3.9/site-packages/ansible_collections
Collection Version
---------- -------
cisco.ios  3.3.2  

# /root/.ansible/collections/ansible_collections
Collection Version
---------- -------
cisco.ios  4.0.0 
CONFIGURATION
DEFAULT_ACTION_PLUGIN_PATH(/opt/ansible/ansible/ansible.cfg) = ['/opt/ansible/lib/python3.9/site-packages/ara/plugins/action']
DEFAULT_CALLBACK_PLUGIN_PATH(/opt/ansible/ansible/ansible.cfg) = ['/opt/ansible/lib/python3.9/site-packages/ara/plugins/callback']
DEFAULT_GATHER_TIMEOUT(/opt/ansible/ansible/ansible.cfg) = 30
DEFAULT_HOST_LIST(/opt/ansible/ansible/ansible.cfg) = ['/opt/ansible/ansible/inventory.yml']
DEFAULT_REMOTE_USER(/opt/ansible/ansible/ansible.cfg) = ansible
DEFAULT_STDOUT_CALLBACK(/opt/ansible/ansible/ansible.cfg) = yaml
DEFAULT_TIMEOUT(/opt/ansible/ansible/ansible.cfg) = 300
HOST_KEY_CHECKING(/opt/ansible/ansible/ansible.cfg) = False
INVENTORY_ENABLED(/opt/ansible/ansible/ansible.cfg) = ['yaml', 'script', 'constructed']
PERSISTENT_COMMAND_TIMEOUT(/opt/ansible/ansible/ansible.cfg) = 300
PERSISTENT_CONNECT_TIMEOUT(/opt/ansible/ansible/ansible.cfg) = 300
RETRY_FILES_ENABLED(/opt/ansible/ansible/ansible.cfg) = False
OS / ENVIRONMENT

ios 12.2, 15.1, 16.9, 17.3

STEPS TO REPRODUCE
    - name: Show configuration
      cisco.ios.ios_command:
        commands:
          - 'show running-config'
      register: show_run
EXPECTED RESULTS

router config

ACTUAL RESULTS
router config file with duplicated first 100-500 lines
KB-perByte commented 1 year ago

Hey @t-r3xous do you mean that the output is duplicated instead of being unique to the appliance? And not the whole output some set of lines out of the whole set of output? Regards

t-r3xous commented 1 year ago

Hello,

It's like it writes the first n lines of configuration and and at that point it starts again from the first line and this time writes the full config. For ex: ! ! version 16.9 no service pad service tcp-keepalives-in service tcp-keepalives-out service timestamps debug datetime msec localtime service timestamps log datetime msec localtime service password-encryption service sequence-numbers platform qfp utilization monitor load 80 no platform punt-keepalive disable-kernel-core platform hardware crypto-throughput level 8-16g ! hostname INTRANET_ASR2 ! boot-start-marker boot system flash bootflash:/asr1000-universalk9.16.09.03.SPA.bin boot-end-marker ! ! vrf definition Mgmt-intf ! address-family ipv4 exit-address-family ! address-family ipv6 exit-address-family ! security authentication failure rate 10 log security passwords min-length 6 logging buffered 65535 logging persistent logging console critical ! aaa new-model ! ! aaa session-id common process cpu threshold type total rising 80 interval 60 falling 60 interval 30 clock timezone EET 2 0 clock summer-time EET recurring last Sun Mar 3:00 last Sun Oct 3:00 no ip source-route no ip gratuitous-arps

! no ip bootp server no ip domain lookup ip domain name example.com ! ! ! login block-for 30 attempts 5 within 5 login on-success log ! no subscriber templating ! crypto pki trustpoint TP-self-signed-1859211069 enrollment selfsigned subject-name cn=IOS-Self-Signed-Certificate-1859211069 revocation-check none rsakeypair TP-self-signed-1859211069 ! ! crypto pki certificate chain TP-self-signed-1859211069 ! license accept end user agreement no license smart enable file prompt quiet ! spanning-tree mode pvst spanning-tree logging spanning-tree extend system-id no diagnostic bootup level archive log config logging enable logging size 1000 notify syslog contenttype plaintext hidekeys ! username test privilege 15 password 7 1111111111111111 ! redundancy mode none ! cdp run ! ! HERE THE CONFIG RESTARTS !!! ! version 16.9 no service pad service tcp-keepalives-in service tcp-keepalives-out service timestamps debug datetime msec localtime service timestamps log datetime msec localtime service password-encryption service sequence-numbers platform qfp utilization monitor load 80 no platform punt-keepalive disable-kernel-core platform hardware crypto-throughput level 8-16g ! hostname INTRANET_ASR2 ! boot-start-marker boot system flash bootflash:/asr1000-universalk9.16.09.03.SPA.bin boot-end-marker ! ! vrf definition Mgmt-intf ! address-family ipv4 exit-address-family ! address-family ipv6 exit-address-family ! security authentication failure rate 10 log security passwords min-length 6 logging buffered 65535 logging persistent logging console critical ! aaa new-model

...the rest of the config

KB-perByte commented 1 year ago

Hey @t-r3xous I tried reproducing this on my end. could you please try adding a meta-reset task after your play?

    - name: Reset ssh connection 
      ansible.builtin.meta: reset_connection

Regards.

t-r3xous commented 1 year ago

Hello,

I tried that and no change (still 4-5 out of 600 have that duplication in their config).

The playbook now is: