Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying resolving issue with meraki_mx_content_filtering #408

Merged
merged 4 commits into from
Jan 22, 2023
Merged
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
2 changes: 2 additions & 0 deletions changelogs/fragments/issue-meraki_mx_content_filtering.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Resolved issue #407 - with restarting policy and idempotency in module mx_content_filtering
22 changes: 16 additions & 6 deletions plugins/modules/meraki_mx_content_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@


from ansible.module_utils.basic import AnsibleModule, json
from ansible_collections.cisco.meraki.plugins.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec
from ansible_collections.cisco.meraki.plugins.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec, recursive_diff
from copy import deepcopy


Expand Down Expand Up @@ -233,11 +233,17 @@ def main():
if module.params['state'] == 'present':
payload = dict()
if meraki.params['allowed_urls']:
payload['allowedUrlPatterns'] = meraki.params['allowed_urls']
if meraki.params['allowed_urls'] == ['None']: # Corner case for resetting
payload['allowedUrlPatterns'] = []
else:
payload['allowedUrlPatterns'] = meraki.params['allowed_urls']
if meraki.params['blocked_urls']:
payload['blockedUrlPatterns'] = meraki.params['blocked_urls']
if meraki.params['blocked_urls'] == ['None']: # Corner case for resetting
payload['blockedUrlPatterns'] = []
else:
payload['blockedUrlPatterns'] = meraki.params['blocked_urls']
if meraki.params['blocked_categories']:
if len(meraki.params['blocked_categories']) == 0: # Corner case for resetting
if meraki.params['blocked_categories'] == ['None']: # Corner case for resetting
payload['blockedUrlCategories'] = []
else:
category_path = meraki.construct_path('categories', net_id=net_id)
Expand Down Expand Up @@ -273,8 +279,12 @@ def main():
meraki.exit_json(**meraki.result)
response = meraki.request(path, method='PUT', payload=json.dumps(payload))
meraki.result['data'] = response
meraki.result['changed'] = True
meraki.generate_diff(current, response)
if recursive_diff(current, response) is None:
y0rune marked this conversation as resolved.
Show resolved Hide resolved
meraki.result['changed'] = False
meraki.result['data'] = str(recursive_diff(current, response))
else:
meraki.result['changed'] = True
meraki.generate_diff(current, response)
else:
meraki.result['data'] = current
if module.check_mode:
Expand Down