diff --git a/plugins/modules/nd_interface_loopback.py b/plugins/modules/nd_interface_loopback.py index c79a9edce..4c9229714 100644 --- a/plugins/modules/nd_interface_loopback.py +++ b/plugins/modules/nd_interface_loopback.py @@ -11,7 +11,7 @@ DOCUMENTATION = r""" --- module: nd_interface_loopback -version_added: "1.4.0" +version_added: "2.0.0" short_description: Manage loopback interfaces on Cisco Nexus Dashboard description: - Manage loopback interfaces on Cisco Nexus Dashboard. @@ -91,15 +91,20 @@ description: - Additional CLI configuration commands to apply to the interface. type: str - deploy: + config_actions: description: - - Whether to deploy interface changes after mutations are complete. - - When V(true), all queued interface changes are deployed in a single bulk API call at the end of module execution - via the C(interfaceActions/deploy) API. Only the interfaces modified by this task are deployed. - - When V(false), changes are staged but not deployed. Use a separate deploy module or task to deploy later. - - Setting O(deploy=false) is useful when batching changes across multiple interface tasks before a single deploy. - type: bool - default: true + - Controls deploy behavior after interface mutations are complete. + type: dict + suboptions: + deploy: + description: + - Whether to deploy interface changes after mutations are complete. + - When V(true), all queued interface changes are deployed in a single bulk API call at the end of module + execution via the C(interfaceActions/deploy) API. Only the interfaces modified by this task are deployed. + - When V(false), changes are staged but not deployed. Use a separate deploy module or task to deploy later. + - Setting O(config_actions.deploy=false) is useful when batching changes across multiple interface tasks before a single deploy. + type: bool + default: true state: description: - The desired state of the network resources on the Cisco Nexus Dashboard. @@ -221,7 +226,8 @@ network_os: policy: ip: 10.1.1.1 - deploy: false + config_actions: + deploy: false state: merged - name: Create a loopback interface with extra CLI configuration @@ -256,7 +262,7 @@ from ansible_collections.cisco.nd.plugins.module_utils.common.log import setup_logging from ansible_collections.cisco.nd.plugins.module_utils.common.pydantic_compat import require_pydantic from ansible_collections.cisco.nd.plugins.module_utils.models.interfaces.loopback_interface import LoopbackInterfaceModel -from ansible_collections.cisco.nd.plugins.module_utils.nd import nd_argument_spec +from ansible_collections.cisco.nd.plugins.module_utils.nd_argument_specs import config_actions_spec, nd_argument_spec from ansible_collections.cisco.nd.plugins.module_utils.nd_state_machine import NDStateMachine from ansible_collections.cisco.nd.plugins.module_utils.orchestrators.base_interface import NDBaseInterfaceOrchestrator from ansible_collections.cisco.nd.plugins.module_utils.orchestrators.loopback_interface import LoopbackInterfaceOrchestrator @@ -275,9 +281,7 @@ def main(): """ argument_spec = nd_argument_spec() argument_spec.update(LoopbackInterfaceModel.get_argument_spec()) - argument_spec.update( - deploy=dict(type="bool", default=True), - ) + argument_spec.update(config_actions_spec(include=("deploy",))) module = AnsibleModule( argument_spec=argument_spec, @@ -300,13 +304,15 @@ def main(): # visible to Pylance and validated at runtime. if not isinstance(nd_state_machine.model_orchestrator, NDBaseInterfaceOrchestrator): raise AssertionError(f"Expected NDBaseInterfaceOrchestrator, got {type(nd_state_machine.model_orchestrator)}") - nd_state_machine.model_orchestrator.deploy = module.params["deploy"] + config_actions = module.params.get("config_actions") or {} + deploy = config_actions.get("deploy", True) + nd_state_machine.model_orchestrator.deploy = deploy module_log.debug( "manage_state begin state=%s check_mode=%s deploy=%s", module.params.get("state"), module.check_mode, - module.params["deploy"], + deploy, ) nd_state_machine.manage_state() module_log.debug("manage_state end") diff --git a/tests/integration/targets/nd_interface_loopback/tasks/merged.yaml b/tests/integration/targets/nd_interface_loopback/tasks/merged.yaml index 9793fc36d..9f7e0da56 100644 --- a/tests/integration/targets/nd_interface_loopback/tasks/merged.yaml +++ b/tests/integration/targets/nd_interface_loopback/tasks/merged.yaml @@ -123,7 +123,8 @@ admin_state: true ip: "10.100.103.1" description: "No-deploy test loopback103" - deploy: false + config_actions: + deploy: false state: merged register: nm_merged_no_deploy