[nxos_prefix_lists] Fix idempotency issues caused by IP prefix notation discrepancies #894
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
Fixed an issue where idempotency was not maintained due to discrepancies in the notation of IP prefixes. By introducing the
ipaddress
module to standardize prefixes, we ensure that the playbook and running-config prefixes are compared accurately, preventing unnecessary configuration changes.For example, previously, a playbook specifying
prefix: ::0/
and a running-config showingipv6 prefix-list plist1 seq 10 permit 0::/0
, or a playbook specifyingprefix: 10.0.0.8/24
and a running-config showingip prefix-list plist2 seq 10 permit 10.0.0.0/24
, would result in unnecessary changes. With this update, such discrepancies are handled, maintaining idempotency and ensuring existing configurations are not repeatedly deleted and re-added.Supplementary Information:
The notation you enter in configure terminal and the notation in the
show run
output may differ on Nexus devices. Therefore, a simple text comparison could break idempotency.An example is shown below.
ISSUE TYPE
COMPONENT NAME
nxos_prefix_lists
ADDITIONAL INFORMATION
Before this change, when I executed the playbook below multiple times, the result would always be changed, and plist1 would be deleted and added each time.