Skip to content

Add hier config nested compliance rule feature - #979

Draft
Dav-C wants to merge 51 commits into
nautobot:developfrom
Dav-C:dcates-nested-compliance
Draft

Add hier config nested compliance rule feature#979
Dav-C wants to merge 51 commits into
nautobot:developfrom
Dav-C:dcates-nested-compliance

Conversation

@Dav-C

@Dav-C Dav-C commented Aug 8, 2025

Copy link
Copy Markdown

Closes: #978

What's Changed

  • Added feature utilizing hier config for compliance rule matching nested configuration lines.
  • Updated Tests
  • Updated Docs

To Do

  • Explanation of Change(s)
  • Added change log fragment(s) (for more information see the documentation)
  • Attached Screenshots, Payload Example
  • Unit, Integration Tests
  • Documentation Updates (when adding/changing features)
  • Outline Remaining Work, Constraints from Design

@@ -0,0 +1,298 @@
# Hierarchical Configuration Compliance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should come up with a word that will resonate with the network engineer vs the technical implementation, such as partial match or filter configs.

@Dav-C Dav-C Aug 14, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've renamed it to Filtered Configuration Compliance. If that doesn't fit, let me know and I'll change it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If filtered doesn’t work for you, then how about “Advanced configuration compliance”

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My vote is Limited Configuration Compliance

Comment thread docs/user/app_feature_compliance_hierarchical.md Outdated
Comment thread nautobot_golden_config/nornir_plays/config_compliance.py
Comment thread nautobot_golden_config/nornir_plays/config_compliance.py Outdated
Comment thread docs/user/app_feature_compliance_hierarchical.md Outdated

Filtered configuration compliance requires:

1. **CLI Configuration Type**: Only `CLI` configuration types are supported for hierarchical compliance

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we link to appropriate docs/repo here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a link to the cli compliance feature within these docs (app_feature_compliancecli.md). Is that sufficient?

Comment thread docs/user/app_feature_compliancefiltered.md Outdated
Comment on lines +142 to +161
## Fallback Behavior for Empty Intended Configuration

In some cases, the intended configuration may not contain any elements that match the compliance rules, resulting in an empty intended configuration text. To handle this scenario, the system includes a fallback mechanism:

**Interface Fallback**: When the intended configuration text is empty, the system automatically looks for top-level interface configurations in the running configuration and uses them as the intended configuration baseline.

This fallback behavior:

1. **Triggers** when `intended_text` is empty after tag-based filtering
3. **Filters** for lines that start with "interface"
4. **Uses** these interface declarations as the intended configuration for comparison

**Example Scenario**:
- Your hierarchical rule targets specific VLAN configurations
- The intended configuration template doesn't include those VLANs
- The running configuration has interface declarations
- The system uses the interface lines from running config as the baseline

This ensures that remediation will not remove interfaces when intended configuration is empty for an interface.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's talk about this before pursuing further. My initial thought is this complicates things too much and going to be hard to meet everyone's POLA.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still feel similar, I don't fully follow the solution (examples would help), and it seems like more complication then required in a day 1 solution.

@jeffkala

jeffkala commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

Think my biggest concern is the actual and intended views are filtered too. I fully agree a filtered compliance has tons of value, but that doesn't mean the intended/actual should be filtered as well. (IMHO). I think the below should happen.

  1. Actual should show as if the old "search" is being used. "interface" is the root/parent and it shows the entire interface section with all config.
  2. Intended ^^ same as above
  3. The actual compliance result should be filtered down to the hier_config rule definition.

@steve-hodgkiss

Copy link
Copy Markdown

I think filtered is the whole point TBH. Compliance rules as they stand today are currently filtered if you think about it from a certain point of view - you’re matching on the parent command rather than displaying the whole intended in one screen. For example my intended config can have loads of lines which don’t have a compliance rule set and the app is happy with all the rules green.

@jeffkala

jeffkala commented Sep 4, 2025

Copy link
Copy Markdown
Contributor

I think filtered is the whole point TBH. Compliance rules as they stand today are currently filtered if you think about it from a certain point of view - you’re matching on the parent command rather than displaying the whole intended in one screen. For example my intended config can have loads of lines which don’t have a compliance rule set and the app is happy with all the rules green.

I understand your viewpoint; however, it shifts many other users use cases. Many people use the other config plan types for example (intended) which pulls from the compliance result. This now means its a filtered intended config-set which isn't what most users want. I think the key components are to make this work alongside all the apps features/functionalities. Where the intended and actual are still showing "everything" that matches the root/main parent, and then the missing/extra/compliance result filtered down.

jeffkala and others added 18 commits December 16, 2025 11:48
* Added fixes

* Added changelog

* Added command to generate more data

* Ruff fix
* Updated django-debug-toolbar version

* Changelog

* Apply suggestion from @smk4664

* Update poetry.lock

---------

Co-authored-by: Stephen Kiely <stephenkiely87@gmail.com>
…tion-options-ltm

[LTM 2.4 Backport] Fixed Hier Config Remediation Options
…g-leading-spaces-ltm

[LTM 2.4 Backport] Changed compliance rule match_config to preserve leading spaces
@Dav-C
Dav-C changed the base branch from develop to ltm-2.4 May 29, 2026 04:21
@Dav-C
Dav-C changed the base branch from ltm-2.4 to develop May 29, 2026 21:23
@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  nautobot_golden_config/nornir_plays
  config_compliance.py 181-186
Project Total  

This report was generated by python-coverage-comment-action

Comment on lines +268 to +274
for tag_rule in v3_tags:
for child in running_config.get_children_deep(tag_rule.match_rules):
child.tags_add(tag_rule.apply_tags)

for tag_rule in v3_tags:
for child in generated_config.get_children_deep(tag_rule.match_rules):
child.tags_add(tag_rule.apply_tags)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be applied the same on running and generated? When does get_children_deep get applied to a running but not generated config?

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.

Nested compliance rules