[Brownfield Network Settings] Granular Server Filtering for Network Management Details#442
Merged
madhansansel merged 9 commits intocisco-en-programmability:mainfrom Apr 29, 2026
Conversation
| - snmp_server | ||
| - syslog_server | ||
| - timezone | ||
| - message_of_the_day |
Collaborator
There was a problem hiding this comment.
Do we need to add ip address list?
ip_address_list:
description:
- List of server IP addresses to filter sites by.
- A site is included only if B(any) of its server
settings contains B(any) of the specified IPs.
- Uses exact match. Combined with C(site_name_list)
and C(server_types) using AND logic.
- If omitted, no IP-based filtering is applied
(default/backward-compatible behaviour).
type: list
elements: str
required: false
| "timezone", | ||
| "message_of_the_day", | ||
| ] | ||
| }, |
Collaborator
There was a problem hiding this comment.
schema missing?
"ip_address_list": {
"type": "list",
"required": False,
"elements": "str"
},
| # server IPs match any of the requested IPs (AND with other filters) | ||
| if requested_ip_addresses: | ||
| site_ips = self._collect_server_ips(filtered_settings) | ||
| matched = any( |
Collaborator
There was a problem hiding this comment.
for ip address.. do we need to match sub-string? or compare with exact string?
matched = any(
req_ip in site_ips
for req_ip in requested_ip_addresses
)
| - snmp_server | ||
| - syslog_server | ||
| - timezone | ||
| - message_of_the_day |
Collaborator
There was a problem hiding this comment.
IP address list examples?
# Network management details filtered by server IP address.
# Only sites whose server settings contain any of the listed IPs are included.
- name: Generate YAML Configuration for network management - filtered by IP
cisco.dnac.network_settings_playbook_config_generator:
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/network_mgmt_by_ip.yml"
file_mode: "overwrite"
config:
component_specific_filters:
components_list:
- "network_management_details"
network_management_details:
- ip_address_list:
- "10.1.1.10"
- "8.8.8.8"
# Combined: site + server type + IP address filters (AND logic across all three).
- name: Generate YAML Configuration - combined site, server type, and IP filter
cisco.dnac.network_settings_playbook_config_generator:
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
dnac_log: true
dnac_log_level: "{{dnac_log_level}}"
state: gathered
file_path: "/tmp/network_mgmt_combined.yml"
file_mode: "overwrite"
config:
component_specific_filters:
components_list:
- "network_management_details"
network_management_details:
- site_name_list:
- "Global/USA/California"
server_types:
- dns_server
- dhcp_server
ip_address_list:
- "10.1.1.10"
| ] | ||
| } | ||
| }, | ||
|
|
Collaborator
There was a problem hiding this comment.
unit test for IP address list??
| @@ -129,10 +129,17 @@ | |||
| required: false | |||
| network_management_details: | |||
Collaborator
There was a problem hiding this comment.
network_management_details:
description:
- Network management settings to filter by site,
server type, and/or server IP address.
- Each list entry is an independent filter dict.
Within a single entry, all specified filters
(C(site_name_list), C(server_types),
C(ip_address_list)) are combined with B(AND)
logic. Omitting a filter means no restriction
on that attribute.
- If C(network_management_details) sub-filter is
not provided under
C(component_specific_filters), the module
defaults to retrieving settings for the
B(Global) (root) site only.
- To retrieve settings for specific sites,
provide a C(site_name_list) with the desired
site names.
- To retrieve only specific server types, provide
a C(server_types) list.
- To include only sites whose server settings
match a specific server IP, provide
C(ip_address_list). A site is included only if
B(any) of its server IPs matches B(any) of the
specified addresses (OR across IPs, AND with
site and server-type filters).
- Evaluation order is site filtering first, then
C(server_types) pruning, then
C(ip_address_list) matching against the pruned
settings.
- If C(server_types) is omitted, all server types
are retrieved (backward-compatible).
- If C(ip_address_list) is omitted, no IP
filtering is applied.
| required: false | ||
| server_types: | ||
| description: | ||
| - List of server/settings types to include in the output. |
Collaborator
There was a problem hiding this comment.
server_types:
description:
- Restricts the YAML output to only the
listed server-type keys. Server types not
in this list are pruned from the generated
settings dict for each site.
- Combined with C(site_name_list) and
C(ip_address_list) using AND logic.
C(ip_address_list) matching runs after
server-type pruning, so only IPs from
the retained server types are evaluated.
- If omitted, all server types are included
in the output (backward-compatible).
- "Example: C([dns_server, ntp_server])
returns only DNS and NTP settings."
type: list
elements: str
required: false
choices:
- dhcp_server
- dns_server
- ntp_server
- network_aaa
- client_and_endpoint_aaa
- netflow_collector
- snmp_server
- syslog_server
- timezone
- message_of_the_day
madhansansel
approved these changes
Apr 29, 2026
madhansansel
approved these changes
Apr 29, 2026
c3c1df8
into
cisco-en-programmability:main
12 of 13 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Type of Change
Description
This PR enhances the network_settings_playbook_config_generator module by adding granular filtering capabilities for network_management_details. Previously, users could only filter by site_name_list, which resulted in all server types being included in the generated YAML output.
With this change, users can now selectively retrieve specific server configurations, improving flexibility and reducing unnecessary data in generated configs.
Key Enhancements
Added support for server_types filter to restrict output to specific server configurations (e.g., DNS, NTP, DHCP, AAA, etc.)
Added support for ip_address_list filter to include only sites containing specified IP addresses across server settings
Enabled combined filtering for more precise output control
Testing Done:
Test cases covered: [Mention test case IDs or brief points]
Checklist
Ansible Best Practices
ansible-vaultor environment variables)Documentation
Screenshots (if applicable)
Notes to Reviewers