miaow2 / netbox-config-diff

Find diff and push rendered device configurations from NetBox to devices and apply them.
https://miaow2.github.io/netbox-config-diff/
Apache License 2.0
78 stars 5 forks source link

Config Diff showing multiple empty lines as mismatched #84

Open Dz3015 opened 6 days ago

Dz3015 commented 6 days ago

NetBox version v4.0.6

Describe the bug On many devices I am showing large blocks of empty lines that are marked as diffed:

To Reproduce Steps to reproduce the behavior:

  1. Go to ConfigDiffScript
  2. Click on 'Run script'
  3. Then go to 'Config Compliances'
  4. See results in diff

Expected behavior Diff only for lines containing config

Screenshots image

Additional context Filters are applied on the Platform settings

chris240189 commented 5 days ago

that is expected behaviour in my book. if you want to filter them from the diff, did you try to filter them with the exclude regex in the platform settings?

Dz3015 commented 4 days ago

that is expected behaviour in my book. if you want to filter them from the diff, did you try to filter them with the exclude regex in the platform settings?

Yes that is exactly what I did. I have filtered these lines in the platform settings. I would expect at that point they are ignored by the diff, not marked.

miaow2 commented 2 days ago

Hi @Dz3015 thanks for opening the issue,

I added tweak before diff, that replaces long sequences of new lines with only one line, is his fine solution for you?

>>> a = "a\n\n\n\n\n\n\n\n\n\nb\na\n\n\n\n\n\n\n\n\n\nb"
>>> re.sub("\n{3,}", "\n", a)
'a\nb\na\nb'
>>>
Dz3015 commented 1 day ago

If this would then cause the configs to match and not show status as "Diff". My goal is that my team can review a daily report out of netbox to review configs showing a "Diff" status but it seems that these lines are not new lines but lines that were filtered out in my platform settings and are showing up that way rather than being ignored. Thank you as always for all the work on this module!