From aed35aba70d7c7294123b6fba860bf0a90d8084a Mon Sep 17 00:00:00 2001 From: Jack Price Date: Thu, 20 Jul 2017 13:16:37 +0100 Subject: [PATCH] Always set `result` variable in `cloudflare_dns` module (#23683) Fixes #23682 --- lib/ansible/modules/net_tools/cloudflare_dns.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/net_tools/cloudflare_dns.py b/lib/ansible/modules/net_tools/cloudflare_dns.py index d1af1e6384e..43b67d0e05c 100644 --- a/lib/ansible/modules/net_tools/cloudflare_dns.py +++ b/lib/ansible/modules/net_tools/cloudflare_dns.py @@ -596,13 +596,17 @@ class CloudflareAPI(object): if (type == 'CNAME') and (cur_record['content'] != new_record['content']): do_update = True if do_update: - if not self.module.check_mode: + if self.module.check_mode: + result = new_record + else: result, info = self._cf_api_call('/zones/{0}/dns_records/{1}'.format(zone_id,records[0]['id']),'PUT',new_record) self.changed = True return result,self.changed else: return records,self.changed - if not self.module.check_mode: + if self.module.check_mode: + result = new_record + else: result, info = self._cf_api_call('/zones/{0}/dns_records'.format(zone_id),'POST',new_record) self.changed = True return result,self.changed