|
|
@ -153,6 +153,7 @@ import os
|
|
|
|
from ansible.module_utils.basic import AnsibleModule, json, env_fallback
|
|
|
|
from ansible.module_utils.basic import AnsibleModule, json, env_fallback
|
|
|
|
from ansible.module_utils.urls import fetch_url
|
|
|
|
from ansible.module_utils.urls import fetch_url
|
|
|
|
from ansible.module_utils._text import to_native
|
|
|
|
from ansible.module_utils._text import to_native
|
|
|
|
|
|
|
|
from ansible.module_utils.common.dict_transformations import recursive_diff
|
|
|
|
from ansible.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec
|
|
|
|
from ansible.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -203,10 +204,20 @@ def set_snmp(meraki, org_id):
|
|
|
|
snmp = get_snmp(meraki, org_id)
|
|
|
|
snmp = get_snmp(meraki, org_id)
|
|
|
|
ignored_parameters = ['v3AuthPass', 'v3PrivPass', 'hostname', 'port', 'v2CommunityString', 'v3User']
|
|
|
|
ignored_parameters = ['v3AuthPass', 'v3PrivPass', 'hostname', 'port', 'v2CommunityString', 'v3User']
|
|
|
|
if meraki.is_update_required(snmp, full_compare, optional_ignore=ignored_parameters):
|
|
|
|
if meraki.is_update_required(snmp, full_compare, optional_ignore=ignored_parameters):
|
|
|
|
|
|
|
|
if meraki.module.check_mode is True:
|
|
|
|
|
|
|
|
diff = recursive_diff(snmp, full_compare)
|
|
|
|
|
|
|
|
snmp.update(payload)
|
|
|
|
|
|
|
|
meraki.result['data'] = snmp
|
|
|
|
|
|
|
|
meraki.result['diff'] = {'before': diff[0],
|
|
|
|
|
|
|
|
'after': diff[1]}
|
|
|
|
|
|
|
|
meraki.exit_json(**meraki.result)
|
|
|
|
r = meraki.request(path,
|
|
|
|
r = meraki.request(path,
|
|
|
|
method='PUT',
|
|
|
|
method='PUT',
|
|
|
|
payload=json.dumps(payload))
|
|
|
|
payload=json.dumps(payload))
|
|
|
|
if meraki.status == 200:
|
|
|
|
if meraki.status == 200:
|
|
|
|
|
|
|
|
diff = recursive_diff(snmp, r)
|
|
|
|
|
|
|
|
meraki.result['diff'] = {'before': diff[0],
|
|
|
|
|
|
|
|
'after': diff[1]}
|
|
|
|
meraki.result['changed'] = True
|
|
|
|
meraki.result['changed'] = True
|
|
|
|
return r
|
|
|
|
return r
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -260,9 +271,6 @@ def main():
|
|
|
|
# if the user is working with this module in only check mode we do not
|
|
|
|
# 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
|
|
|
|
# want to make any changes to the environment, just return the current
|
|
|
|
# state with no modifications
|
|
|
|
# state with no modifications
|
|
|
|
# FIXME: Work with Meraki so they can implement a check mode
|
|
|
|
|
|
|
|
if module.check_mode:
|
|
|
|
|
|
|
|
meraki.exit_json(**meraki.result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# execute checks for argument completeness
|
|
|
|
# execute checks for argument completeness
|
|
|
|
|
|
|
|
|
|
|
@ -275,7 +283,6 @@ def main():
|
|
|
|
org_id = meraki.params['org_id']
|
|
|
|
org_id = meraki.params['org_id']
|
|
|
|
if org_id is None:
|
|
|
|
if org_id is None:
|
|
|
|
org_id = meraki.get_org_id(meraki.params['org_name'])
|
|
|
|
org_id = meraki.get_org_id(meraki.params['org_name'])
|
|
|
|
|
|
|
|
|
|
|
|
if meraki.params['state'] == 'query':
|
|
|
|
if meraki.params['state'] == 'query':
|
|
|
|
meraki.result['data'] = get_snmp(meraki, org_id)
|
|
|
|
meraki.result['data'] = get_snmp(meraki, org_id)
|
|
|
|
elif meraki.params['state'] == 'present':
|
|
|
|
elif meraki.params['state'] == 'present':
|
|
|
|