Ansible ND 4.X | ND Manage Switches Module + Pydantic Models + Smart Endpoints#198
Ansible ND 4.X | ND Manage Switches Module + Pydantic Models + Smart Endpoints#198AKDRG wants to merge 49 commits intoCiscoDevNet:nd42_integrationfrom
Conversation
…ible-nd into switch_int_pr
plugins/module_utils/endpoints/v1/manage/nd_manage_switches/credentials.py
Outdated
Show resolved
Hide resolved
plugins/module_utils/endpoints/v1/manage/nd_manage_switches/credentials.py
Outdated
Show resolved
Hide resolved
plugins/module_utils/endpoints/v1/manage/nd_manage_switches/credentials.py
Outdated
Show resolved
Hide resolved
plugins/module_utils/endpoints/v1/manage/nd_manage_switches/credentials.py
Outdated
Show resolved
Hide resolved
plugins/module_utils/endpoints/v1/manage/nd_manage_switches/credentials.py
Outdated
Show resolved
Hide resolved
plugins/module_utils/endpoints/v1/manage/nd_manage_switches/fabric_bootstrap.py
Outdated
Show resolved
Hide resolved
plugins/module_utils/endpoints/v1/manage/nd_manage_switches/fabric_bootstrap.py
Outdated
Show resolved
Hide resolved
…ible-nd into switch_int_pr
|
|
||
| # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
| """ | ||
| ND Manage Fabric Config endpoint models. |
There was a problem hiding this comment.
There is some overlap here with the fabric module endpoints so we should discuss consolidation and moving things like config-save and config-deploy to a more common location instead of under nd_manage_switches
plugins/module_utils/models/nd_manage_switches/bootstrap_models.py
Outdated
Show resolved
Hide resolved
|
@AKDRG Couple of testing notes:
- name: Manage Fabric Switches
cisco.nd.nd_manage_switches:
fabric: mike_test
state: overridden
deploy: false
config: []Currently I see the following: "msg": "'config' is required for 'overridden' state."
"msg": "Configuration validation failed for config index 13: [{'type': 'value_error', 'loc': (), 'msg': \"Value error, POAP/Pre-provision operations require 'merged' state, got 'overridden' (switch: 192.168.10.1)\", 'input': {'seed_ip': '192.168.10.1', 'username': 'admin', 'password': '********', 'preprovision': {'serial_number': 'SAL1234ABCD', 'model': 'N9K-C93180YC-EX', 'version': '10.3(1)', 'hostname': 'leaf-preprov', 'config_data': {'models': ['N9K-C93180YC-EX'], 'gateway': '192.168.10.1/24'}, 'discovery_username': None, 'discovery_password': None, 'image_policy': None}, 'auth_proto': 'MD5', 'role': 'leaf', 'preserve_config': False, 'poap': None, 'rma': None}, 'ctx': {'error': ValueError(\"POAP/Pre-provision operations require 'merged' state, got 'overridden' (switch: 192.168.10.1)\")}, 'url': 'https://errors.pydantic.dev/2.12/v/value_error'}]"
}
|
|
I was not able to add more then one switch to the fabric until I added the following line diff --git a/plugins/module_utils/nd_config_collection.py b/plugins/module_utils/nd_config_collection.py
index 832cc13..7610d05 100644
--- a/plugins/module_utils/nd_config_collection.py
+++ b/plugins/module_utils/nd_config_collection.py
@@ -56,7 +56,7 @@ class NDConfigCollection:
key = self._extract_key(item)
- if key in self._index:
+ if key is not None and key in self._index:
raise ValueError(f"Item with identifier {key} already exists. Use replace() to update")
position = len(self._items)This is just a workaround but I am wondering if |
This PR introduces the initial implementation of ND Manage switch lifecycle support in the cisco.nd collection.
It adds a new switch management resource layer, endpoint wrappers, Pydantic model hierarchy, utility helpers.
What’s Included
Added a full resource engine in plugins/module_utils/manage_switches/nd_switch_resources.py
Implements state handling for:
Adds structured operation sequencing:
Added endpoint models under plugins/module_utils/endpoints/v1/:
Added helpers in plugins/module_utils/manage_switches:
These utilities centralize grouping, payload shaping, wait/retry logic, and fabric operations.