mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
meraki - Unchanged requests now return the original data (#53576)
* Unchanged requests now return the original data * Add changelog fragment * Add integration tests for returned data for meraki_network * Add integration tests for returned data * Improve idempoetent output - Make MX l3 rules always show default rule - Add integration tests * Add integration tests for returned data on meraki_network * Improved idempotency in a few modules and improved tests
This commit is contained in:
parent
a3c3fd91f8
commit
2a187f362a
29 changed files with 167 additions and 96 deletions
2
changelogs/fragments/53576-meraki-unchanged-returns.yml
Normal file
2
changelogs/fragments/53576-meraki-unchanged-returns.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- "meraki_* - Meraki modules now return data when no changes are made."
|
|
@ -354,7 +354,6 @@ def create_admin(meraki, org_id, name, email):
|
||||||
if not meraki.params['networks']:
|
if not meraki.params['networks']:
|
||||||
payload['networks'] = []
|
payload['networks'] = []
|
||||||
if meraki.is_update_required(is_admin_existing, payload) is True:
|
if meraki.is_update_required(is_admin_existing, payload) is True:
|
||||||
# meraki.fail_json(msg='Update is required!!!', original=is_admin_existing, proposed=payload)
|
|
||||||
path = meraki.construct_path('update', function='admin', org_id=org_id) + is_admin_existing['id']
|
path = meraki.construct_path('update', function='admin', org_id=org_id) + is_admin_existing['id']
|
||||||
r = meraki.request(path,
|
r = meraki.request(path,
|
||||||
method='PUT',
|
method='PUT',
|
||||||
|
@ -364,7 +363,7 @@ def create_admin(meraki, org_id, name, email):
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
return r
|
return r
|
||||||
else:
|
else:
|
||||||
# meraki.fail_json(msg='No update is required!!!')
|
meraki.result['data'] = is_admin_existing
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,8 @@ def main():
|
||||||
meraki.fail_json(msg='Unable to bind configuration template to network')
|
meraki.fail_json(msg='Unable to bind configuration template to network')
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
meraki.result['data'] = template_bind
|
meraki.result['data'] = template_bind
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = {}
|
||||||
elif meraki.params['state'] == 'absent':
|
elif meraki.params['state'] == 'absent':
|
||||||
if not meraki.params['net_name'] and not meraki.params['net_id']:
|
if not meraki.params['net_name'] and not meraki.params['net_id']:
|
||||||
meraki.result['data'] = delete_template(meraki,
|
meraki.result['data'] = delete_template(meraki,
|
||||||
|
@ -266,6 +268,8 @@ def main():
|
||||||
meraki.fail_json(msg='Unable to unbind configuration template from network')
|
meraki.fail_json(msg='Unable to unbind configuration template from network')
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
meraki.result['data'] = config_unbind
|
meraki.result['data'] = config_unbind
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = {}
|
||||||
|
|
||||||
# in the event of a successful module execution, you will want to
|
# in the event of a successful module execution, you will want to
|
||||||
# simple AnsibleModule.exit_json(), passing the key/value results
|
# simple AnsibleModule.exit_json(), passing the key/value results
|
||||||
|
|
|
@ -210,6 +210,8 @@ def main():
|
||||||
response = meraki.request(path, method='PUT', payload=json.dumps(payload))
|
response = meraki.request(path, method='PUT', payload=json.dumps(payload))
|
||||||
meraki.result['data'] = response
|
meraki.result['data'] = response
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = current
|
||||||
|
|
||||||
# in the event of a successful module execution, you will want to
|
# in the event of a successful module execution, you will want to
|
||||||
# simple AnsibleModule.exit_json(), passing the key/value results
|
# simple AnsibleModule.exit_json(), passing the key/value results
|
||||||
|
|
|
@ -378,6 +378,8 @@ def main():
|
||||||
updated_device.append(meraki.request(path, method='PUT', payload=json.dumps(payload)))
|
updated_device.append(meraki.request(path, method='PUT', payload=json.dumps(payload)))
|
||||||
meraki.result['data'] = updated_device
|
meraki.result['data'] = updated_device
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = device_data
|
||||||
else:
|
else:
|
||||||
if net_id is None:
|
if net_id is None:
|
||||||
device_list = get_org_devices(meraki, org_id)
|
device_list = get_org_devices(meraki, org_id)
|
||||||
|
|
|
@ -20,6 +20,7 @@ short_description: Manage MR access point layer 3 firewalls in the Meraki cloud
|
||||||
version_added: "2.7"
|
version_added: "2.7"
|
||||||
description:
|
description:
|
||||||
- Allows for creation, management, and visibility into layer 3 firewalls implemented on Meraki MR access points.
|
- Allows for creation, management, and visibility into layer 3 firewalls implemented on Meraki MR access points.
|
||||||
|
- Module is not idempotent as of current release.
|
||||||
options:
|
options:
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
|
@ -278,6 +279,8 @@ def main():
|
||||||
if meraki.status == 200:
|
if meraki.status == 200:
|
||||||
meraki.result['data'] = response
|
meraki.result['data'] = response
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = rules
|
||||||
|
|
||||||
# in the event of a successful module execution, you will want to
|
# in the event of a successful module execution, you will want to
|
||||||
# simple AnsibleModule.exit_json(), passing the key/value results
|
# simple AnsibleModule.exit_json(), passing the key/value results
|
||||||
|
|
|
@ -303,7 +303,6 @@ def main():
|
||||||
update = False
|
update = False
|
||||||
if meraki.params['syslog_default_rule'] is not None:
|
if meraki.params['syslog_default_rule'] is not None:
|
||||||
payload['syslogDefaultRule'] = meraki.params['syslog_default_rule']
|
payload['syslogDefaultRule'] = meraki.params['syslog_default_rule']
|
||||||
# meraki.fail_json(msg='Payload', payload=payload)
|
|
||||||
try:
|
try:
|
||||||
if len(rules) - 1 != len(payload['rules']): # Quick and simple check to avoid more processing
|
if len(rules) - 1 != len(payload['rules']): # Quick and simple check to avoid more processing
|
||||||
update = True
|
update = True
|
||||||
|
@ -311,19 +310,21 @@ def main():
|
||||||
if rules[len(rules) - 1]['syslogEnabled'] != meraki.params['syslog_default_rule']:
|
if rules[len(rules) - 1]['syslogEnabled'] != meraki.params['syslog_default_rule']:
|
||||||
update = True
|
update = True
|
||||||
if update is False:
|
if update is False:
|
||||||
|
default_rule = rules[len(rules) - 1].copy()
|
||||||
del rules[len(rules) - 1] # Remove default rule for comparison
|
del rules[len(rules) - 1] # Remove default rule for comparison
|
||||||
for r in range(len(rules) - 1):
|
for r in range(len(rules) - 1):
|
||||||
if meraki.is_update_required(rules[r], payload['rules'][r]) is True:
|
if meraki.is_update_required(rules[r], payload['rules'][r]) is True:
|
||||||
update = True
|
update = True
|
||||||
|
rules.append(default_rule)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# if meraki.params['syslog_default_rule']:
|
|
||||||
# meraki.fail_json(msg='Compare', original=rules, proposed=payload)
|
|
||||||
if update is True:
|
if update is True:
|
||||||
response = meraki.request(path, method='PUT', payload=json.dumps(payload))
|
response = meraki.request(path, method='PUT', payload=json.dumps(payload))
|
||||||
if meraki.status == 200:
|
if meraki.status == 200:
|
||||||
meraki.result['data'] = response
|
meraki.result['data'] = response
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = rules
|
||||||
|
|
||||||
# in the event of a successful module execution, you will want to
|
# in the event of a successful module execution, you will want to
|
||||||
# simple AnsibleModule.exit_json(), passing the key/value results
|
# simple AnsibleModule.exit_json(), passing the key/value results
|
||||||
|
|
|
@ -316,7 +316,6 @@ def main():
|
||||||
if meraki.status == 200:
|
if meraki.status == 200:
|
||||||
meraki.result['data'] = r
|
meraki.result['data'] = r
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
|
||||||
else: # Update existing network
|
else: # Update existing network
|
||||||
net = meraki.get_net(meraki.params['org_name'], meraki.params['net_name'], data=nets)
|
net = meraki.get_net(meraki.params['org_name'], meraki.params['net_name'], data=nets)
|
||||||
if meraki.params['enable_vlans'] is not None:
|
if meraki.params['enable_vlans'] is not None:
|
||||||
|
@ -344,6 +343,8 @@ def main():
|
||||||
if meraki.status == 200:
|
if meraki.status == 200:
|
||||||
meraki.result['data'] = r
|
meraki.result['data'] = r
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = net
|
||||||
elif meraki.params['state'] == 'absent':
|
elif meraki.params['state'] == 'absent':
|
||||||
if is_net_valid(meraki, meraki.params['net_name'], nets) is True:
|
if is_net_valid(meraki, meraki.params['net_name'], nets) is True:
|
||||||
net_id = meraki.get_net_id(net_name=meraki.params['net_name'],
|
net_id = meraki.get_net_id(net_name=meraki.params['net_name'],
|
||||||
|
|
|
@ -207,12 +207,8 @@ def main():
|
||||||
payload = {'name': meraki.params['org_name'],
|
payload = {'name': meraki.params['org_name'],
|
||||||
'id': meraki.params['org_id'],
|
'id': meraki.params['org_id'],
|
||||||
}
|
}
|
||||||
if meraki.is_update_required(
|
original = get_org(meraki, meraki.params['org_id'], orgs)
|
||||||
get_org(
|
if meraki.is_update_required(original, payload):
|
||||||
meraki,
|
|
||||||
meraki.params['org_id'],
|
|
||||||
orgs),
|
|
||||||
payload):
|
|
||||||
response = meraki.request(meraki.construct_path('update',
|
response = meraki.request(meraki.construct_path('update',
|
||||||
org_id=meraki.params['org_id']
|
org_id=meraki.params['org_id']
|
||||||
),
|
),
|
||||||
|
@ -222,6 +218,9 @@ def main():
|
||||||
meraki.fail_json(msg='Organization update failed')
|
meraki.fail_json(msg='Organization update failed')
|
||||||
meraki.result['data'] = response
|
meraki.result['data'] = response
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = original
|
||||||
|
|
||||||
# in the event of a successful module execution, you will want to
|
# in the event of a successful module execution, you will want to
|
||||||
# simple AnsibleModule.exit_json(), passing the key/value results
|
# simple AnsibleModule.exit_json(), passing the key/value results
|
||||||
meraki.exit_json(**meraki.result)
|
meraki.exit_json(**meraki.result)
|
||||||
|
|
|
@ -209,7 +209,8 @@ def set_snmp(meraki, org_id):
|
||||||
if meraki.status == 200:
|
if meraki.status == 200:
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
return r
|
return r
|
||||||
return -1
|
else:
|
||||||
|
return snmp
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -519,6 +519,8 @@ def main():
|
||||||
result = meraki.request(path, 'PUT', payload=json.dumps(payload))
|
result = meraki.request(path, 'PUT', payload=json.dumps(payload))
|
||||||
meraki.result['data'] = result
|
meraki.result['data'] = result
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = original
|
||||||
elif meraki.params['state'] == 'absent':
|
elif meraki.params['state'] == 'absent':
|
||||||
ssids = get_ssids(meraki, net_id)
|
ssids = get_ssids(meraki, net_id)
|
||||||
ssid_id = meraki.params['number']
|
ssid_id = meraki.params['number']
|
||||||
|
|
|
@ -363,6 +363,8 @@ def main():
|
||||||
path = meraki.construct_path('update', net_id=net_id, custom={'route_id': meraki.params['route_id']})
|
path = meraki.construct_path('update', net_id=net_id, custom={'route_id': meraki.params['route_id']})
|
||||||
meraki.result['data'] = meraki.request(path, method="PUT", payload=json.dumps(payload))
|
meraki.result['data'] = meraki.request(path, method="PUT", payload=json.dumps(payload))
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = existing_route
|
||||||
else:
|
else:
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
meraki.result['data'] = payload
|
meraki.result['data'] = payload
|
||||||
|
|
|
@ -384,6 +384,8 @@ def main():
|
||||||
response = meraki.request(path, method='PUT', payload=json.dumps(payload))
|
response = meraki.request(path, method='PUT', payload=json.dumps(payload))
|
||||||
meraki.result['data'] = response
|
meraki.result['data'] = response
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = original
|
||||||
|
|
||||||
# in the event of a successful module execution, you will want to
|
# in the event of a successful module execution, you will want to
|
||||||
# simple AnsibleModule.exit_json(), passing the key/value results
|
# simple AnsibleModule.exit_json(), passing the key/value results
|
||||||
|
|
|
@ -278,6 +278,8 @@ def main():
|
||||||
if meraki.status == 200:
|
if meraki.status == 200:
|
||||||
meraki.result['data'] = r
|
meraki.result['data'] = r
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = original
|
||||||
|
|
||||||
# in the event of a successful module execution, you will want to
|
# in the event of a successful module execution, you will want to
|
||||||
# simple AnsibleModule.exit_json(), passing the key/value results
|
# simple AnsibleModule.exit_json(), passing the key/value results
|
||||||
|
|
|
@ -397,6 +397,8 @@ def main():
|
||||||
response = meraki.request(path, method='PUT', payload=json.dumps(payload))
|
response = meraki.request(path, method='PUT', payload=json.dumps(payload))
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
meraki.result['data'] = response
|
meraki.result['data'] = response
|
||||||
|
else:
|
||||||
|
meraki.result['data'] = original
|
||||||
elif meraki.params['state'] == 'absent':
|
elif meraki.params['state'] == 'absent':
|
||||||
if is_vlan_valid(meraki, net_id, meraki.params['vlan_id']):
|
if is_vlan_valid(meraki, net_id, meraki.params['vlan_id']):
|
||||||
path = meraki.construct_path('delete', net_id=net_id) + str(meraki.params['vlan_id'])
|
path = meraki.construct_path('delete', net_id=net_id) + str(meraki.params['vlan_id'])
|
||||||
|
|
|
@ -174,6 +174,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- update_network_idempotent.changed == false
|
- update_network_idempotent.changed == false
|
||||||
|
- update_network_idempotent.data is defined
|
||||||
|
|
||||||
- name: Create administrator with invalid network
|
- name: Create administrator with invalid network
|
||||||
meraki_admin:
|
meraki_admin:
|
||||||
|
|
|
@ -4,39 +4,39 @@
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
# - name: Test an API key is provided
|
- name: Test an API key is provided
|
||||||
# fail:
|
fail:
|
||||||
# msg: Please define an API key
|
msg: Please define an API key
|
||||||
# when: auth_key is not defined
|
when: auth_key is not defined
|
||||||
|
|
||||||
# - name: Use an invalid domain
|
- name: Use an invalid domain
|
||||||
# meraki_config_template:
|
meraki_config_template:
|
||||||
# auth_key: '{{ auth_key }}'
|
auth_key: '{{ auth_key }}'
|
||||||
# host: marrrraki.com
|
host: marrrraki.com
|
||||||
# state: query
|
state: query
|
||||||
# org_name: DevTestOrg
|
org_name: DevTestOrg
|
||||||
# output_level: debug
|
output_level: debug
|
||||||
# delegate_to: localhost
|
delegate_to: localhost
|
||||||
# register: invalid_domain
|
register: invalid_domain
|
||||||
# ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
# - name: Connection assertions
|
- name: Connection assertions
|
||||||
# assert:
|
assert:
|
||||||
# that:
|
that:
|
||||||
# - '"Failed to connect to" in invalid_domain.msg'
|
- '"Failed to connect to" in invalid_domain.msg'
|
||||||
|
|
||||||
- name: Query all configuration templates
|
- name: Query all configuration templates
|
||||||
meraki_config_template:
|
meraki_config_template:
|
||||||
auth_key: '{{auth_key}}'
|
auth_key: '{{auth_key}}'
|
||||||
state: query
|
state: query
|
||||||
org_name: DevTestOrg
|
org_name: '{{test_org_name}}'
|
||||||
register: get_all
|
register: get_all
|
||||||
|
|
||||||
- name: Delete non-existant configuration template
|
- name: Delete non-existant configuration template
|
||||||
meraki_config_template:
|
meraki_config_template:
|
||||||
auth_key: '{{auth_key}}'
|
auth_key: '{{auth_key}}'
|
||||||
state: absent
|
state: absent
|
||||||
org_name: DevTestOrg
|
org_name: '{{test_org_name}}'
|
||||||
config_template: FakeConfigTemplate
|
config_template: FakeConfigTemplate
|
||||||
register: deleted
|
register: deleted
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
@ -142,7 +142,8 @@
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
bind_id_idempotent.changed == False
|
- bind_id_idempotent.changed == False
|
||||||
|
- bind_id_idempotent.data is defined
|
||||||
|
|
||||||
- name: Unbind a template to a network via id
|
- name: Unbind a template to a network via id
|
||||||
meraki_config_template:
|
meraki_config_template:
|
||||||
|
|
|
@ -4,26 +4,37 @@
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
# - name: Test an API key is provided
|
- name: Test an API key is provided
|
||||||
# fail:
|
fail:
|
||||||
# msg: Please define an API key
|
msg: Please define an API key
|
||||||
# when: auth_key is not defined
|
when: auth_key is not defined
|
||||||
|
|
||||||
# - name: Use an invalid domain
|
- name: Use an invalid domain
|
||||||
# meraki_config_template:
|
meraki_config_template:
|
||||||
# auth_key: '{{ auth_key }}'
|
auth_key: '{{ auth_key }}'
|
||||||
# host: marrrraki.com
|
host: marrrraki.com
|
||||||
# state: query
|
state: query
|
||||||
# org_name: DevTestOrg
|
org_name: DevTestOrg
|
||||||
# output_level: debug
|
output_level: debug
|
||||||
# delegate_to: localhost
|
delegate_to: localhost
|
||||||
# register: invalid_domain
|
register: invalid_domain
|
||||||
# ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
# - name: Connection assertions
|
- name: Connection assertions
|
||||||
# assert:
|
assert:
|
||||||
# that:
|
that:
|
||||||
# - '"Failed to connect to" in invalid_domain.msg'
|
- '"Failed to connect to" in invalid_domain.msg'
|
||||||
|
|
||||||
|
- name: Create network with type switch
|
||||||
|
meraki_network:
|
||||||
|
auth_key: '{{ auth_key }}'
|
||||||
|
state: present
|
||||||
|
org_name: '{{test_org_name}}'
|
||||||
|
net_name: '{{test_net_name}}'
|
||||||
|
type: appliance
|
||||||
|
timezone: America/Chicago
|
||||||
|
delegate_to: localhost
|
||||||
|
register: create_net_appliance
|
||||||
|
|
||||||
- name: Set single allowed URL pattern
|
- name: Set single allowed URL pattern
|
||||||
meraki_content_filtering:
|
meraki_content_filtering:
|
||||||
|
@ -58,6 +69,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- single_allowed_idempotent.changed == False
|
- single_allowed_idempotent.changed == False
|
||||||
|
- single_allowed_idempotent.data is defined
|
||||||
|
|
||||||
- name: Set single blocked URL pattern
|
- name: Set single blocked URL pattern
|
||||||
meraki_content_filtering:
|
meraki_content_filtering:
|
||||||
|
|
|
@ -183,6 +183,7 @@
|
||||||
tags: recently-added
|
tags: recently-added
|
||||||
state: present
|
state: present
|
||||||
move_map_marker: True
|
move_map_marker: True
|
||||||
|
note: Test device notes
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: update_device_idempotent
|
register: update_device_idempotent
|
||||||
|
|
||||||
|
@ -192,6 +193,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- update_device_idempotent.changed == False
|
- update_device_idempotent.changed == False
|
||||||
|
- update_device_idempotent.data is defined
|
||||||
|
|
||||||
always:
|
always:
|
||||||
- name: Remove a device from a network
|
- name: Remove a device from a network
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
that:
|
that:
|
||||||
- create_one.data.0.comment == 'Integration test rule'
|
- create_one.data.0.comment == 'Integration test rule'
|
||||||
- create_one.data.1.policy == 'deny'
|
- create_one.data.1.policy == 'deny'
|
||||||
|
- create_one.data is defined
|
||||||
|
|
||||||
- name: Enable local LAN access
|
- name: Enable local LAN access
|
||||||
meraki_mr_l3_firewall:
|
meraki_mr_l3_firewall:
|
||||||
|
|
|
@ -4,37 +4,37 @@
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
# - name: Test an API key is provided
|
- name: Test an API key is provided
|
||||||
# fail:
|
fail:
|
||||||
# msg: Please define an API key
|
msg: Please define an API key
|
||||||
# when: auth_key is not defined
|
when: auth_key is not defined
|
||||||
|
|
||||||
# - name: Use an invalid domain
|
- name: Use an invalid domain
|
||||||
# meraki_organization:
|
meraki_organization:
|
||||||
# auth_key: '{{ auth_key }}'
|
auth_key: '{{ auth_key }}'
|
||||||
# host: marrrraki.com
|
host: marrrraki.com
|
||||||
# state: present
|
state: present
|
||||||
# org_name: IntTestOrg
|
org_name: IntTestOrg
|
||||||
# output_level: debug
|
output_level: debug
|
||||||
# delegate_to: localhost
|
delegate_to: localhost
|
||||||
# register: invalid_domain
|
register: invalid_domain
|
||||||
# ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
# - name: Disable HTTP
|
- name: Disable HTTP
|
||||||
# meraki_organization:
|
meraki_organization:
|
||||||
# auth_key: '{{ auth_key }}'
|
auth_key: '{{ auth_key }}'
|
||||||
# use_https: false
|
use_https: false
|
||||||
# state: query
|
state: query
|
||||||
# output_level: debug
|
output_level: debug
|
||||||
# delegate_to: localhost
|
delegate_to: localhost
|
||||||
# register: http
|
register: http
|
||||||
# ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
# - name: Connection assertions
|
- name: Connection assertions
|
||||||
# assert:
|
assert:
|
||||||
# that:
|
that:
|
||||||
# - '"Failed to connect to" in invalid_domain.msg'
|
- '"Failed to connect to" in invalid_domain.msg'
|
||||||
# - '"http" in http.url'
|
- '"http" in http.url'
|
||||||
|
|
||||||
- name: Create network
|
- name: Create network
|
||||||
meraki_network:
|
meraki_network:
|
||||||
|
@ -54,9 +54,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: query
|
register: query
|
||||||
|
|
||||||
- debug:
|
|
||||||
msg: '{{query}}'
|
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- query.data|length == 1
|
- query.data|length == 1
|
||||||
|
@ -78,6 +75,9 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: create_one
|
register: create_one
|
||||||
|
|
||||||
|
- debug:
|
||||||
|
var: create_one
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- create_one.data|length == 2
|
- create_one.data|length == 2
|
||||||
|
@ -85,6 +85,7 @@
|
||||||
- create_one.data.0.protocol == 'tcp'
|
- create_one.data.0.protocol == 'tcp'
|
||||||
- create_one.data.0.policy == 'deny'
|
- create_one.data.0.policy == 'deny'
|
||||||
- create_one.changed == True
|
- create_one.changed == True
|
||||||
|
- create_one.data is defined
|
||||||
|
|
||||||
- name: Check for idempotency
|
- name: Check for idempotency
|
||||||
meraki_mx_l3_firewall:
|
meraki_mx_l3_firewall:
|
||||||
|
@ -109,6 +110,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- create_one_idempotent.changed == False
|
- create_one_idempotent.changed == False
|
||||||
|
- create_one_idempotent.data is defined
|
||||||
|
|
||||||
- name: Create syslog in network
|
- name: Create syslog in network
|
||||||
meraki_syslog:
|
meraki_syslog:
|
||||||
|
@ -145,6 +147,10 @@
|
||||||
- debug:
|
- debug:
|
||||||
msg: '{{default_syslog}}'
|
msg: '{{default_syslog}}'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- default_syslog.data is defined
|
||||||
|
|
||||||
- name: Query firewall rules
|
- name: Query firewall rules
|
||||||
meraki_mx_l3_firewall:
|
meraki_mx_l3_firewall:
|
||||||
auth_key: '{{ auth_key }}'
|
auth_key: '{{ auth_key }}'
|
||||||
|
@ -183,6 +189,10 @@
|
||||||
- debug:
|
- debug:
|
||||||
msg: '{{disable_syslog}}'
|
msg: '{{disable_syslog}}'
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- disable_syslog.data is defined
|
||||||
|
|
||||||
- name: Query firewall rules
|
- name: Query firewall rules
|
||||||
meraki_mx_l3_firewall:
|
meraki_mx_l3_firewall:
|
||||||
auth_key: '{{ auth_key }}'
|
auth_key: '{{ auth_key }}'
|
||||||
|
@ -210,3 +220,11 @@
|
||||||
rules: []
|
rules: []
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: delete_all
|
register: delete_all
|
||||||
|
|
||||||
|
- name: Delete network
|
||||||
|
meraki_network:
|
||||||
|
auth_key: '{{ auth_key }}'
|
||||||
|
org_name: '{{test_org_name}}'
|
||||||
|
net_name: TestNetAppliance
|
||||||
|
state: absent
|
||||||
|
delegate_to: localhost
|
||||||
|
|
|
@ -67,9 +67,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: enable_vlan
|
register: enable_vlan
|
||||||
|
|
||||||
- debug:
|
|
||||||
msg: '{{ enable_vlan }}'
|
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- enable_vlan.data.enabled == True
|
- enable_vlan.data.enabled == True
|
||||||
|
@ -84,9 +81,13 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: enable_vlan_idempotent
|
register: enable_vlan_idempotent
|
||||||
|
|
||||||
|
- debug:
|
||||||
|
var: enable_vlan_idempotent
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- enable_vlan_idempotent is not changed
|
- enable_vlan_idempotent is not changed
|
||||||
|
- enable_vlan_idempotent.data is defined
|
||||||
|
|
||||||
- name: Disable VLAN support on appliance network
|
- name: Disable VLAN support on appliance network
|
||||||
meraki_network:
|
meraki_network:
|
||||||
|
@ -98,9 +99,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: disable_vlan
|
register: disable_vlan
|
||||||
|
|
||||||
- debug:
|
|
||||||
msg: '{{ disable_vlan }}'
|
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- disable_vlan.data.enabled == False
|
- disable_vlan.data.enabled == False
|
||||||
|
@ -118,6 +116,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- disable_vlan_idempotent is not changed
|
- disable_vlan_idempotent is not changed
|
||||||
|
- disable_vlan_idempotent.data is defined
|
||||||
|
|
||||||
- name: Create network with type wireless
|
- name: Create network with type wireless
|
||||||
meraki_network:
|
meraki_network:
|
||||||
|
@ -141,6 +140,10 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: create_net_wireless_idempotent
|
register: create_net_wireless_idempotent
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- create_net_wireless_idempotent.data is defined
|
||||||
|
|
||||||
- name: Create network with type combined and disable my.meraki.com
|
- name: Create network with type combined and disable my.meraki.com
|
||||||
meraki_network:
|
meraki_network:
|
||||||
auth_key: '{{ auth_key }}'
|
auth_key: '{{ auth_key }}'
|
||||||
|
@ -176,9 +179,6 @@
|
||||||
tags: first_tag
|
tags: first_tag
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: create_net_tag
|
register: create_net_tag
|
||||||
|
|
||||||
- debug:
|
|
||||||
msg: '{{create_net_tag}}'
|
|
||||||
|
|
||||||
- name: Create network with two tags
|
- name: Create network with two tags
|
||||||
meraki_network:
|
meraki_network:
|
||||||
|
@ -194,9 +194,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: create_net_tags
|
register: create_net_tags
|
||||||
|
|
||||||
- debug:
|
|
||||||
msg: '{{create_net_tags}}'
|
|
||||||
|
|
||||||
- name: Modify network
|
- name: Modify network
|
||||||
meraki_network:
|
meraki_network:
|
||||||
auth_key: '{{ auth_key }}'
|
auth_key: '{{ auth_key }}'
|
||||||
|
@ -227,6 +224,10 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: create_net_modified_idempotent
|
register: create_net_modified_idempotent
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- create_net_modified_idempotent.data is defined
|
||||||
|
|
||||||
- name: Present assertions
|
- name: Present assertions
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
|
@ -241,11 +242,13 @@
|
||||||
- '"IntTestNetworkSwitchOrgID" in create_net_switch_org_id.data.name'
|
- '"IntTestNetworkSwitchOrgID" in create_net_switch_org_id.data.name'
|
||||||
- '"IntTestNetworkWireless" in create_net_wireless.data.name'
|
- '"IntTestNetworkWireless" in create_net_wireless.data.name'
|
||||||
- create_net_wireless_idempotent.changed == False
|
- create_net_wireless_idempotent.changed == False
|
||||||
|
- create_net_wireless_idempotent.data is defined
|
||||||
- '"first_tag" in create_net_tag.data.tags'
|
- '"first_tag" in create_net_tag.data.tags'
|
||||||
- '"second_tag" in create_net_tags.data.tags'
|
- '"second_tag" in create_net_tags.data.tags'
|
||||||
- '"third_tag" in create_net_modified.data.tags'
|
- '"third_tag" in create_net_modified.data.tags'
|
||||||
- create_net_modified.changed == True
|
- create_net_modified.changed == True
|
||||||
- create_net_modified_idempotent.changed == False
|
- create_net_modified_idempotent.changed == False
|
||||||
|
- create_net_modified_idempotent.data is defined
|
||||||
|
|
||||||
- name: Query all networks
|
- name: Query all networks
|
||||||
meraki_network:
|
meraki_network:
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
- modify_org.changed == True
|
- modify_org.changed == True
|
||||||
- 'modify_org.data.name == "IntTestOrgRenamed"'
|
- 'modify_org.data.name == "IntTestOrgRenamed"'
|
||||||
- modify_org_idempotent.changed == False
|
- modify_org_idempotent.changed == False
|
||||||
|
- modify_org_idempotent.data is defined
|
||||||
|
|
||||||
- name: List all organizations
|
- name: List all organizations
|
||||||
meraki_organization:
|
meraki_organization:
|
||||||
|
|
|
@ -118,6 +118,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- snmp_idempotent.changed == False
|
- snmp_idempotent.changed == False
|
||||||
|
- snmp_idempotent.data is defined
|
||||||
|
|
||||||
- name: Add peer IPs
|
- name: Add peer IPs
|
||||||
meraki_snmp:
|
meraki_snmp:
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- enable_name_ssid_idempotent.changed == False
|
- enable_name_ssid_idempotent.changed == False
|
||||||
|
- enable_name_ssid_idempotent.data is defined
|
||||||
|
|
||||||
- name: Query one SSIDs
|
- name: Query one SSIDs
|
||||||
meraki_ssid:
|
meraki_ssid:
|
||||||
|
|
|
@ -106,6 +106,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- update_idempotent.changed == False
|
- update_idempotent.changed == False
|
||||||
|
- update_idempotent.data is defined
|
||||||
|
|
||||||
- name: Update static route with fixed IP assignment and reservation
|
- name: Update static route with fixed IP assignment and reservation
|
||||||
meraki_static_route:
|
meraki_static_route:
|
||||||
|
|
|
@ -218,6 +218,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- update_port_access_idempotent.changed == False
|
- update_port_access_idempotent.changed == False
|
||||||
|
- update_port_access_idempotent.data is defined
|
||||||
|
|
||||||
- name: Configure trunk port
|
- name: Configure trunk port
|
||||||
meraki_switchport:
|
meraki_switchport:
|
||||||
|
@ -320,4 +321,5 @@
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- update_trunk_idempotent.changed == False
|
- update_trunk_idempotent.changed == False
|
||||||
|
- update_trunk_idempotent.data is defined
|
||||||
|
|
|
@ -102,6 +102,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- create_server_idempotency.changed == False
|
- create_server_idempotency.changed == False
|
||||||
|
- create_server_idempotency.data is defined
|
||||||
|
|
||||||
- name: Set multiple syslog servers # Broken
|
- name: Set multiple syslog servers # Broken
|
||||||
meraki_syslog:
|
meraki_syslog:
|
||||||
|
|
|
@ -165,6 +165,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- update_vlan_idempotent.changed == False
|
- update_vlan_idempotent.changed == False
|
||||||
|
- update_vlan_idempotent.data is defined
|
||||||
|
|
||||||
- name: Add IP assignments and reserved IP ranges
|
- name: Add IP assignments and reserved IP ranges
|
||||||
meraki_vlan:
|
meraki_vlan:
|
||||||
|
@ -262,6 +263,7 @@
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- update_vlan_idempotent.changed == False
|
- update_vlan_idempotent.changed == False
|
||||||
|
- update_vlan_idempotent.data is defined
|
||||||
|
|
||||||
- name: Update VLAN with list of DNS entries
|
- name: Update VLAN with list of DNS entries
|
||||||
meraki_vlan:
|
meraki_vlan:
|
||||||
|
|
Loading…
Reference in a new issue