Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions plugins/modules/nd_interface_loopback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
allenrobel marked this conversation as resolved.
description:
- Manage loopback interfaces on Cisco Nexus Dashboard.
Expand Down Expand Up @@ -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
Comment thread
allenrobel marked this conversation as resolved.
state:
description:
- The desired state of the network resources on the Cisco Nexus Dashboard.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading