ansible.netcommon
ansible.netcommon copied to clipboard
Fix: Preserve AS-DOT ASN string formatting in ansible_collections utils.Template()
SUMMARY
- BGP ASNs using asdot notation and ending with trailing zeroes 65000.1000 are being misrepresented. Trailing zeroes are being stripped, returning 65000.1
ISSUE TYPE
- Bugfix Pull Request
COMPONENT NAME
- ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils
- Template().call method
ADDITIONAL INFORMATION
I work with the cisco_ios network module a lot. When trying to gather bgp_global facts the 'as_number' is truncated. Traced the bug back to the above-mentioned module. The value loses its trailing zeroes after being processed by ast.literal_eval() before being returned.
BEFORE CHANGE
PLAY [CISCO FACTS] *****************************************************************************************************************************************************************************************************************
TASK [cisco_facts : CISCO IOS - GATHER FACTS] **************************************************************************************************************************************************************************************
Thursday 08 May 2025 23:23:15 -0700 (0:00:00.008) 0:00:00.008 **********
Thursday 08 May 2025 23:23:15 -0700 (0:00:00.007) 0:00:00.007 **********
ok: [edge1-rt]
TASK [cisco_facts : CISCO IOS - PRINT FACTS] ***************************************************************************************************************************************************************************************
Thursday 08 May 2025 23:23:17 -0700 (0:00:02.043) 0:00:02.051 **********
Thursday 08 May 2025 23:23:17 -0700 (0:00:02.043) 0:00:02.051 **********
ok: [edge1-rt] =>
ios_facts:
ansible_facts:
ansible_net_api: cliconf
ansible_net_gather_network_resources:
- bgp_global
ansible_net_gather_subset:
- default
ansible_net_hostname: edge1-rt
ansible_net_image: bootflash:packages.conf
ansible_net_iostype: IOS-XE
ansible_net_model: C8000V
ansible_net_operatingmode: autonomous
ansible_net_python_version: 3.12.3
ansible_net_system: ios
ansible_net_version: 17.12.04a
ansible_network_resources:
bgp_global:
aggregate_addresses:
- address: 205.85.0.0
netmask: 255.255.248.0
as_number: '65000.1'
TRUNCATED OUTPUT ---
PLAY RECAP *************************************************************************************************************************************************************************************************************************
edge1-rt : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Playbook run took 0 days, 0 hours, 0 minutes, 2 seconds
Thursday 08 May 2025 23:23:17 -0700 (0:00:00.038) 0:00:02.089 **********
===============================================================================
cisco_facts : CISCO IOS - GATHER FACTS -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2.04s
cisco_facts : CISCO IOS - PRINT FACTS --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.04s
Thursday 08 May 2025 23:23:17 -0700 (0:00:00.038) 0:00:02.089 **********
===============================================================================
cisco_facts ------------------------------------------------------------- 2.08s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
total ------------------------------------------------------------------- 2.08s
AFTER CHANGE
PLAY [CISCO FACTS] *****************************************************************************************************************************************************************************************************************
TASK [cisco_facts : CISCO IOS - GATHER FACTS] **************************************************************************************************************************************************************************************
Thursday 08 May 2025 23:28:40 -0700 (0:00:00.008) 0:00:00.008 **********
Thursday 08 May 2025 23:28:40 -0700 (0:00:00.008) 0:00:00.008 **********
ok: [edge1-rt]
TASK [cisco_facts : CISCO IOS - PRINT FACTS] ***************************************************************************************************************************************************************************************
Thursday 08 May 2025 23:28:42 -0700 (0:00:02.022) 0:00:02.030 **********
Thursday 08 May 2025 23:28:42 -0700 (0:00:02.022) 0:00:02.030 **********
ok: [edge1-rt] =>
ios_facts:
ansible_facts:
ansible_net_api: cliconf
ansible_net_gather_network_resources:
- bgp_global
ansible_net_gather_subset:
- default
ansible_net_hostname: edge1-rt
ansible_net_image: bootflash:packages.conf
ansible_net_iostype: IOS-XE
ansible_net_model: C8000V
ansible_net_operatingmode: autonomous
ansible_net_python_version: 3.12.3
ansible_net_system: ios
ansible_net_version: 17.12.04a
ansible_network_resources:
bgp_global:
aggregate_addresses:
- address: 205.85.0.0
netmask: 255.255.248.0
as_number: '65000.1000'
TRUNCATED OUTPUT ---
PLAY RECAP *************************************************************************************************************************************************************************************************************************
edge1-rt : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Playbook run took 0 days, 0 hours, 0 minutes, 2 seconds
Thursday 08 May 2025 23:28:42 -0700 (0:00:00.037) 0:00:02.068 **********
===============================================================================
cisco_facts : CISCO IOS - GATHER FACTS -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2.02s
cisco_facts : CISCO IOS - PRINT FACTS --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.04s
Thursday 08 May 2025 23:28:42 -0700 (0:00:00.037) 0:00:02.067 **********
===============================================================================
cisco_facts ------------------------------------------------------------- 2.06s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
total ------------------------------------------------------------------- 2.06s