Fix ios_config diff trailing whitespaces #1118
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andafter
keys in theresult.dict
. This will eliminate false positives in diffs and help users focus on meaningful configuration changes.Rationale:
ISSUE TYPE
COMPONENT NAME
cisco.ios.ios_config
ADDITIONAL INFORMATION
This behavior was observed on the following platform:
CAT9K_IOSXE
17.09.03
Example of the incorrect diff output observed with and without this fix:
Trailing whitespaces ignored:
Trailing whitespaces not ignored: