meraki_network - Add support for disableRemoteStatusPage (#48971)
* Add support for disableRemoteStatusPage - New feature in the Meraki API - Yes, it's a double negative, I may fix at some point * Remove double negative - All disables became enable and logic is reversed - This isn't yet tested * Switching computers!!! * Apply changes to make the logic work, even reversed * Attempt to fix some formatting errors * Add documentation fragment * Fix whitespace * Add disable_my_meraki back, with deprecation notice * Edit changelog notice * Update deprecation version * Update example to be a block and change deprecation message. * Remove duplicate delegate_to * Change deprecation notice.
This commit is contained in:
parent
79bb7bde5f
commit
4df53f869e
3 changed files with 149 additions and 50 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- meraki_network - Add support for disabling remote status page on a network.
|
|
@ -71,9 +71,24 @@ options:
|
|||
disable_my_meraki:
|
||||
description: >
|
||||
- Disables the local device status pages (U[my.meraki.com](my.meraki.com), U[ap.meraki.com](ap.meraki.com), U[switch.meraki.com](switch.meraki.com),
|
||||
U[wired.meraki.com](wired.meraki.com))
|
||||
U[wired.meraki.com](wired.meraki.com)).
|
||||
- Mutually exclusive of C(enable_my_meraki).
|
||||
- Will be deprecated in Ansible 2.13 in favor of C(enable_my_meraki).
|
||||
type: bool
|
||||
version_added: '2.7'
|
||||
enable_my_meraki:
|
||||
description: >
|
||||
- Enables the local device status pages (U[my.meraki.com](my.meraki.com), U[ap.meraki.com](ap.meraki.com), U[switch.meraki.com](switch.meraki.com),
|
||||
U[wired.meraki.com](wired.meraki.com)).
|
||||
- Ansible 2.7 had this parameter as C(disable_my_meraki).
|
||||
type: bool
|
||||
version_added: '2.9'
|
||||
enable_remote_status_page:
|
||||
description:
|
||||
- Enables access to the device status page (U(http://device LAN IP)).
|
||||
- Can only be set if C(enable_my_meraki:) is set to C(yes).
|
||||
type: bool
|
||||
version_added: '2.9'
|
||||
|
||||
author:
|
||||
- Kevin Breit (@kbreit)
|
||||
|
@ -81,48 +96,46 @@ extends_documentation_fragment: meraki
|
|||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: List all networks associated to the YourOrg organization
|
||||
meraki_network:
|
||||
auth_key: abc12345
|
||||
state: query
|
||||
org_name: YourOrg
|
||||
delegate_to: localhost
|
||||
- name: Query network named MyNet in the YourOrg organization
|
||||
meraki_network:
|
||||
auth_key: abc12345
|
||||
state: query
|
||||
org_name: YourOrg
|
||||
net_name: MyNet
|
||||
delegate_to: localhost
|
||||
- name: Create network named MyNet in the YourOrg organization
|
||||
meraki_network:
|
||||
auth_key: abc12345
|
||||
state: present
|
||||
org_name: YourOrg
|
||||
net_name: MyNet
|
||||
type: switch
|
||||
timezone: America/Chicago
|
||||
tags: production, chicago
|
||||
delegate_to: localhost
|
||||
- name: Create combined network named MyNet in the YourOrg organization
|
||||
meraki_network:
|
||||
auth_key: abc12345
|
||||
state: present
|
||||
org_name: YourOrg
|
||||
net_name: MyNet
|
||||
type:
|
||||
- switch
|
||||
- appliance
|
||||
timezone: America/Chicago
|
||||
tags: production, chicago
|
||||
- name: Enable VLANs on a network
|
||||
meraki_network:
|
||||
auth_key: abc12345
|
||||
state: query
|
||||
org_name: YourOrg
|
||||
net_name: MyNet
|
||||
enable_vlans: yes
|
||||
delegate_to: localhost
|
||||
- delegate_to: localhost
|
||||
block:
|
||||
- name: List all networks associated to the YourOrg organization
|
||||
meraki_network:
|
||||
auth_key: abc12345
|
||||
state: query
|
||||
org_name: YourOrg
|
||||
- name: Query network named MyNet in the YourOrg organization
|
||||
meraki_network:
|
||||
auth_key: abc12345
|
||||
state: query
|
||||
org_name: YourOrg
|
||||
net_name: MyNet
|
||||
- name: Create network named MyNet in the YourOrg organization
|
||||
meraki_network:
|
||||
auth_key: abc12345
|
||||
state: present
|
||||
org_name: YourOrg
|
||||
net_name: MyNet
|
||||
type: switch
|
||||
timezone: America/Chicago
|
||||
tags: production, chicago
|
||||
- name: Create combined network named MyNet in the YourOrg organization
|
||||
meraki_network:
|
||||
auth_key: abc12345
|
||||
state: present
|
||||
org_name: YourOrg
|
||||
net_name: MyNet
|
||||
type:
|
||||
- switch
|
||||
- appliance
|
||||
timezone: America/Chicago
|
||||
tags: production, chicago
|
||||
- name: Enable VLANs on a network
|
||||
meraki_network:
|
||||
auth_key: abc12345
|
||||
state: query
|
||||
org_name: YourOrg
|
||||
net_name: MyNet
|
||||
enable_vlans: yes
|
||||
'''
|
||||
|
||||
RETURN = r'''
|
||||
|
@ -166,6 +179,11 @@ data:
|
|||
returned: success
|
||||
type: bool
|
||||
sample: true
|
||||
disableRemoteStatusPage:
|
||||
description: Disables access to the device status page.
|
||||
returned: success
|
||||
type: bool
|
||||
sample: true
|
||||
'''
|
||||
|
||||
import os
|
||||
|
@ -210,8 +228,10 @@ def main():
|
|||
timezone=dict(type='str'),
|
||||
net_name=dict(type='str', aliases=['name', 'network']),
|
||||
state=dict(type='str', choices=['present', 'query', 'absent'], default='present'),
|
||||
disable_my_meraki=dict(type='bool'),
|
||||
enable_vlans=dict(type='bool'),
|
||||
disable_my_meraki=dict(type='bool', removed_in_version=2.13),
|
||||
enable_my_meraki=dict(type='bool'),
|
||||
enable_remote_status_page=dict(type='bool'),
|
||||
)
|
||||
|
||||
# the AnsibleModule object will be our abstraction working with Ansible
|
||||
|
@ -220,6 +240,8 @@ def main():
|
|||
# supports check mode
|
||||
module = AnsibleModule(argument_spec=argument_spec,
|
||||
supports_check_mode=False,
|
||||
mutually_exclusive=[('disable_my_meraki', 'enable_my_meraki'),
|
||||
]
|
||||
)
|
||||
|
||||
meraki = MerakiModule(module, function='network')
|
||||
|
@ -247,6 +269,8 @@ def main():
|
|||
if not meraki.params['net_name'] and not meraki.params['net_id']:
|
||||
if meraki.params['enable_vlans']:
|
||||
meraki.fail_json(msg="The parameter 'enable_vlans' requires 'net_name' or 'net_id' to be specified")
|
||||
if meraki.params['enable_my_meraki'] is True and meraki.params['enable_remote_status_page'] is False:
|
||||
meraki.fail_json(msg='enable_my_meraki must be true when setting enable_remote_status_page')
|
||||
|
||||
# if the user is working with this module in only check mode we do not
|
||||
# want to make any changes to the environment, just return the current
|
||||
|
@ -265,8 +289,19 @@ def main():
|
|||
payload['tags'] = construct_tags(meraki.params['tags'])
|
||||
if meraki.params['timezone']:
|
||||
payload['timeZone'] = meraki.params['timezone']
|
||||
if meraki.params['disable_my_meraki'] is not None:
|
||||
if meraki.params['enable_my_meraki'] is not None:
|
||||
if meraki.params['enable_my_meraki'] is True:
|
||||
payload['disableMyMerakiCom'] = False
|
||||
else:
|
||||
payload['disableMyMerakiCom'] = True
|
||||
elif meraki.params['disable_my_meraki'] is not None:
|
||||
payload['disableMyMerakiCom'] = meraki.params['disable_my_meraki']
|
||||
if meraki.params['enable_remote_status_page'] is not None:
|
||||
if meraki.params['enable_remote_status_page'] is True:
|
||||
payload['disableRemoteStatusPage'] = False
|
||||
# meraki.fail_json(msg="Debug", payload=payload)
|
||||
else:
|
||||
payload['disableRemoteStatusPage'] = True
|
||||
|
||||
# manipulate or modify the state as needed (this is going to be the
|
||||
# part where your module will do what it needs to do)
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
- disable_vlan_idempotent is not changed
|
||||
- disable_vlan_idempotent.data is defined
|
||||
|
||||
- name: Create network with type wireless
|
||||
- name: Create network with type wireless and disable my.meraki.com
|
||||
meraki_network:
|
||||
auth_key: '{{ auth_key }}'
|
||||
state: present
|
||||
|
@ -126,10 +126,11 @@
|
|||
net_name: IntTestNetworkWireless
|
||||
type: wireless
|
||||
timezone: America/Chicago
|
||||
disable_my_meraki: yes
|
||||
delegate_to: localhost
|
||||
register: create_net_wireless
|
||||
|
||||
- name: Create network with type wireless and check for idempotency
|
||||
- name: Create network with type wireless, disable my.meraki.com, and check for idempotency
|
||||
meraki_network:
|
||||
auth_key: '{{ auth_key }}'
|
||||
state: present
|
||||
|
@ -137,6 +138,7 @@
|
|||
net_name: IntTestNetworkWireless
|
||||
type: wireless
|
||||
timezone: America/Chicago
|
||||
disable_my_meraki: yes
|
||||
delegate_to: localhost
|
||||
register: create_net_wireless_idempotent
|
||||
|
||||
|
@ -154,7 +156,7 @@
|
|||
- appliance
|
||||
- switch
|
||||
timezone: America/Chicago
|
||||
disable_my_meraki: yes
|
||||
enable_my_meraki: no
|
||||
delegate_to: localhost
|
||||
register: create_net_combined
|
||||
|
||||
|
@ -164,10 +166,69 @@
|
|||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: IntTestNetworkCombined
|
||||
disable_my_meraki: no
|
||||
enable_my_meraki: yes
|
||||
delegate_to: localhost
|
||||
register: enable_meraki_com
|
||||
|
||||
- name: Disable my.meraki.com for next test
|
||||
meraki_network:
|
||||
auth_key: '{{ auth_key }}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: IntTestNetworkCombined
|
||||
enable_my_meraki: no
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Enable remote status page
|
||||
meraki_network:
|
||||
auth_key: '{{ auth_key }}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: IntTestNetworkCombined
|
||||
enable_remote_status_page: yes
|
||||
delegate_to: localhost
|
||||
register: disable_remote_status
|
||||
|
||||
- debug:
|
||||
msg: '{{disable_remote_status}}'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- disable_remote_status.data.disableRemoteStatusPage == False
|
||||
|
||||
- name: Disable remote status page
|
||||
meraki_network:
|
||||
auth_key: '{{ auth_key }}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: IntTestNetworkCombined
|
||||
enable_remote_status_page: no
|
||||
delegate_to: localhost
|
||||
register: enable_remote_status
|
||||
|
||||
- debug:
|
||||
msg: '{{enable_remote_status}}'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- enable_remote_status.data.disableRemoteStatusPage == True
|
||||
|
||||
- name: Test status pages are mutually exclusive when on
|
||||
meraki_network:
|
||||
auth_key: '{{ auth_key }}'
|
||||
state: present
|
||||
org_name: '{{test_org_name}}'
|
||||
net_name: IntTestNetworkCombined
|
||||
enable_my_meraki: yes
|
||||
enable_remote_status_page: no
|
||||
delegate_to: localhost
|
||||
register: status_exclusivity
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- '"must be true when setting" in status_exclusivity.msg'
|
||||
|
||||
- name: Create network with one tag
|
||||
meraki_network:
|
||||
auth_key: '{{ auth_key }}'
|
||||
|
@ -241,6 +302,7 @@
|
|||
- '"IntTestNetworkSwitch" in create_net_switch.data.name'
|
||||
- '"IntTestNetworkSwitchOrgID" in create_net_switch_org_id.data.name'
|
||||
- '"IntTestNetworkWireless" in create_net_wireless.data.name'
|
||||
- create_net_wireless.data.disableMyMerakiCom == True
|
||||
- create_net_wireless_idempotent.changed == False
|
||||
- create_net_wireless_idempotent.data is defined
|
||||
- '"first_tag" in create_net_tag.data.tags'
|
||||
|
|
Loading…
Reference in a new issue