mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixes idempotency check for partial configurations (#41941)
- Previous PR would overwrite new and existing values improperly
This commit is contained in:
parent
4e275a4ba8
commit
7ab3f755ce
2 changed files with 23 additions and 4 deletions
|
@ -184,14 +184,11 @@ def main():
|
||||||
if meraki.params['state'] == 'present':
|
if meraki.params['state'] == 'present':
|
||||||
payload = {'name': meraki.params['net_name'],
|
payload = {'name': meraki.params['net_name'],
|
||||||
'type': meraki.params['type'],
|
'type': meraki.params['type'],
|
||||||
'tags': meraki.params['tags'],
|
|
||||||
}
|
}
|
||||||
if meraki.params['tags']:
|
if meraki.params['tags']:
|
||||||
payload['tags'] = construct_tags(meraki.params['tags'])
|
payload['tags'] = construct_tags(meraki.params['tags'])
|
||||||
if meraki.params['timezone']:
|
if meraki.params['timezone']:
|
||||||
payload['timeZone'] = meraki.params['timezone']
|
payload['timeZone'] = meraki.params['timezone']
|
||||||
else:
|
|
||||||
payload['timeZone'] = 'America/Los_Angeles'
|
|
||||||
if meraki.params['type'] == 'combined':
|
if meraki.params['type'] == 'combined':
|
||||||
payload['type'] = 'switch wireless appliance'
|
payload['type'] = 'switch wireless appliance'
|
||||||
|
|
||||||
|
@ -225,6 +222,16 @@ def main():
|
||||||
meraki.result['changed'] = True
|
meraki.result['changed'] = True
|
||||||
else:
|
else:
|
||||||
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)
|
||||||
|
proposed = payload
|
||||||
|
if meraki.params['timezone']:
|
||||||
|
proposed['timeZone'] = meraki.params['timezone']
|
||||||
|
else:
|
||||||
|
proposed['timeZone'] = 'America/Los_Angeles'
|
||||||
|
if not meraki.params['tags']:
|
||||||
|
proposed['tags'] = None
|
||||||
|
if not proposed['type']:
|
||||||
|
proposed['type'] = net['type']
|
||||||
|
|
||||||
if meraki.is_update_required(net, payload):
|
if meraki.is_update_required(net, payload):
|
||||||
path = meraki.construct_path('update',
|
path = meraki.construct_path('update',
|
||||||
net_id=meraki.get_net_id(net_name=meraki.params['net_name'], data=nets)
|
net_id=meraki.get_net_id(net_name=meraki.params['net_name'], data=nets)
|
||||||
|
|
|
@ -66,7 +66,18 @@
|
||||||
timezone: America/Chicago
|
timezone: America/Chicago
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: create_net_wireless
|
register: create_net_wireless
|
||||||
|
|
||||||
|
- name: Create network with type wireless and check for idempotency
|
||||||
|
meraki_network:
|
||||||
|
auth_key: '{{ auth_key }}'
|
||||||
|
state: present
|
||||||
|
org_name: '{{test_org_name}}'
|
||||||
|
net_name: IntTestNetworkWireless
|
||||||
|
type: wireless
|
||||||
|
timezone: America/Chicago
|
||||||
|
delegate_to: localhost
|
||||||
|
register: create_net_wireless_idempotent
|
||||||
|
|
||||||
- name: Create network with type combined
|
- name: Create network with type combined
|
||||||
meraki_network:
|
meraki_network:
|
||||||
auth_key: '{{ auth_key }}'
|
auth_key: '{{ auth_key }}'
|
||||||
|
@ -142,6 +153,7 @@
|
||||||
- '"IntTestNetworkSwitch" in create_net_switch.data.name'
|
- '"IntTestNetworkSwitch" in create_net_switch.data.name'
|
||||||
- '"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
|
||||||
- '"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'
|
||||||
|
|
Loading…
Reference in a new issue