diff --git a/lib/ansible/modules/extras/network/cloudflare_dns.py b/lib/ansible/modules/extras/network/cloudflare_dns.py index 88207ecf8d..7ec106e9de 100644 --- a/lib/ansible/modules/extras/network/cloudflare_dns.py +++ b/lib/ansible/modules/extras/network/cloudflare_dns.py @@ -461,23 +461,19 @@ class CloudflareAPI(object): # in theory this should be impossible as cloudflare does not allow # the creation of duplicate records but lets cover it anyways if len(records) > 1: - return records,self.changed - # record already exists, check if ttl must be updated + self.module.fail_json(msg="More than one record already exists for the given attributes. That should be impossible, please open an issue!") + # record already exists, check if it must be updated if len(records) == 1: cur_record = records[0] do_update = False if (params['ttl'] is not None) and (cur_record['ttl'] != params['ttl'] ): - cur_record['ttl'] = params['ttl'] do_update = True if (params['priority'] is not None) and ('priority' in cur_record) and (cur_record['priority'] != params['priority']): - cur_record['priority'] = params['priority'] do_update = True if ('data' in new_record) and ('data' in cur_record): if (cur_record['data'] > new_record['data']) - (cur_record['data'] < new_record['data']): - cur_record['data'] = new_record['data'] do_update = True if (type == 'CNAME') and (cur_record['content'] != new_record['content']): - cur_record['content'] = new_record['content'] do_update = True if do_update: if not self.module.check_mode: