|
|
|
|
@ -244,13 +244,13 @@ def main():
|
|
|
|
|
if not value:
|
|
|
|
|
module.fail_json(msg="Missing the record value")
|
|
|
|
|
|
|
|
|
|
rr = next((r for r in records if r['name'] == record and r['record_type'] == record_type and r['content'] == value), None)
|
|
|
|
|
rr = next((r for r in records if r['name'] == record and r['type'] == record_type and r['content'] == value), None)
|
|
|
|
|
|
|
|
|
|
if state == 'present':
|
|
|
|
|
changed = False
|
|
|
|
|
if is_solo:
|
|
|
|
|
# delete any records that have the same name and record type
|
|
|
|
|
same_type = [r['id'] for r in records if r['name'] == record and r['record_type'] == record_type]
|
|
|
|
|
same_type = [r['id'] for r in records if r['name'] == record and r['type'] == record_type]
|
|
|
|
|
if rr:
|
|
|
|
|
same_type = [rid for rid in same_type if rid != rr['id']]
|
|
|
|
|
if same_type:
|
|
|
|
|
@ -260,12 +260,12 @@ def main():
|
|
|
|
|
changed = True
|
|
|
|
|
if rr:
|
|
|
|
|
# check if we need to update
|
|
|
|
|
if rr['ttl'] != ttl or rr['prio'] != priority:
|
|
|
|
|
if rr['ttl'] != ttl or rr['priority'] != priority:
|
|
|
|
|
data = {}
|
|
|
|
|
if ttl:
|
|
|
|
|
data['ttl'] = ttl
|
|
|
|
|
if priority:
|
|
|
|
|
data['prio'] = priority
|
|
|
|
|
data['priority'] = priority
|
|
|
|
|
if module.check_mode:
|
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
|
else:
|
|
|
|
|
@ -276,13 +276,13 @@ def main():
|
|
|
|
|
# create it
|
|
|
|
|
data = {
|
|
|
|
|
'name': record,
|
|
|
|
|
'record_type': record_type,
|
|
|
|
|
'type': record_type,
|
|
|
|
|
'content': value,
|
|
|
|
|
}
|
|
|
|
|
if ttl:
|
|
|
|
|
data['ttl'] = ttl
|
|
|
|
|
if priority:
|
|
|
|
|
data['prio'] = priority
|
|
|
|
|
data['priority'] = priority
|
|
|
|
|
if module.check_mode:
|
|
|
|
|
module.exit_json(changed=True)
|
|
|
|
|
else:
|
|
|
|
|
|