Skip to content

Commit

Permalink
Add support for copy_from_network_id (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbreit authored Jul 6, 2022
1 parent dde1aa3 commit fde6302
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/335-net_copy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- meraki_network - Add support for `copy_from_network_id`.
19 changes: 19 additions & 0 deletions plugins/modules/meraki_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
- Can only be set if C(local_status_page_enabled:) is set to C(yes).
- Only can be specified on its own or with C(local_status_page_enabled).
type: bool
copy_from_network_id:
description:
- New network inherits properties from this network ID.
- Other provided parameters will override the copied configuration.
- Type which must match this network's type exactly.
type: str
author:
- Kevin Breit (@kbreit)
Expand Down Expand Up @@ -115,6 +121,16 @@
- appliance
timezone: America/Chicago
tags: production, chicago
- name: Create new network based on an existing network
meraki_network:
auth_key: abc12345
state: present
org_name: YourOrg
net_name: MyNet
type:
- switch
- appliance
copy_from_network_id: N_1234
- name: Enable VLANs on a network
meraki_network:
auth_key: abc12345
Expand Down Expand Up @@ -236,6 +252,7 @@ def main():
enable_vlans=dict(type="bool"),
local_status_page_enabled=dict(type="bool"),
remote_status_page_enabled=dict(type="bool"),
copy_from_network_id=dict(type="str"),
)

# the AnsibleModule object will be our abstraction working with Ansible
Expand Down Expand Up @@ -307,6 +324,8 @@ def main():
payload["remoteStatusPageEnabled"] = meraki.params[
"remote_status_page_enabled"
]
if meraki.params["copy_from_network_id"] is not None:
payload["copyFromNetworkId"] = meraki.params["copy_from_network_id"]

# manipulate or modify the state as needed (this is going to be the
# part where your module will do what it needs to do)
Expand Down
23 changes: 22 additions & 1 deletion tests/integration/targets/meraki_network/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,27 @@
timezone: America/Chicago
delegate_to: localhost
register: create_net_switch


- set_fact:
switch_net_id: '{{ create_net_switch.data.id }}'

- name: Copy network
meraki_network:
auth_key: '{{ auth_key }}'
state: present
org_name: '{{test_org_name}}'
net_name: IntTestNetworkSwitchCopied
type: switch
copy_from_network_id: '{{ switch_net_id }}'
delegate_to: localhost
register: copy_from_net_id

- assert:
that:
- copy_from_net_id is defined
- copy_from_net_id is changed
- copy_from_net_id.data.id != create_net_switch.data.id

- name: Create network with type switch by org ID
meraki_network:
auth_key: '{{ auth_key }}'
Expand Down Expand Up @@ -442,6 +462,7 @@
ignore_errors: yes
loop:
- IntTestNetworkSwitch
- IntTestNetworkSwitchCopied
- IntTestNetworkWireless
- IntTestNetworkAppliance
- IntTestNetworkCombined
Expand Down

0 comments on commit fde6302

Please sign in to comment.