Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix ios_config diff trailing whitespaces #1118

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rrajpuro
Copy link

@rrajpuro rrajpuro commented Sep 21, 2024

SUMMARY

The ios_config module currently generates incorrect diffs when the --diff keyword is used. This happens because some IOS commands in the running configuration add unnecessary trailing whitespace after pushing the intended config to the device. Most of these extra spaces have no functional value and are misleading in the diff output.

The proposed solution is to trim trailing whitespace in the multiline configuration strings when populating the before and after keys in the result.dict. This will eliminate false positives in diffs and help users focus on meaningful configuration changes.

Rationale:

  1. Trimming will prevent unnecessary diffs, reducing noise and making real configuration changes more visible.
  2. This fix will not introduce breaking changes.

ISSUE TYPE

  • Bugfix Pull Request

COMPONENT NAME

cisco.ios.ios_config

ADDITIONAL INFORMATION

This behavior was observed on the following platform:

  • SW Image: CAT9K_IOSXE
  • SW Version: 17.09.03

Example of the incorrect diff output observed with and without this fix:
Trailing whitespaces ignored:

--- before
+++ after
@@ -5,7 +5,6 @@
-vrf definition SRV

Trailing whitespaces not ignored:

--- before
+++ after
@@ -22,8 +21,8 @@
-ip multicast-routing 
-ip multicast-routing vrf DLM 
+ip multicast-routing
+ip multicast-routing vrf DLM
@@ -36,60 +35,60 @@
 crypto pki certificate chain SLA-TrustPoint
  certificate ca 01
-  30820321 30820209 A0030201 02020101 300D0609 2A864886 F70D0101 0B050030 
....
+  30820321 30820209 A0030201 02020101 300D0609 2A864886 F70D0101 0B050030
....
  certificate self-signed 01
-  30820330 30820218 A0030201 02020101 300D0609 2A864886 F70D0101 05050030 
.........
+  30820330 30820218 A0030201 02020101 300D0609 2A864886 F70D0101 05050030
   832110BC 5C60D883 7F5BFC85 FBD9AB97 6A9C7A5C
        quit
......
......
......
@@ -237,9 +237,9 @@
- ip router isis 
+ ip router isis
- isis network point-to-point 
+ isis network point-to-point
@@ -346,7 +346,7 @@
-route-map XXXX permit 10 
+route-map XXXX permit 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant