From 6c59811bf958b0d8a0d5f6c9c948e28f32c48391 Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 15 Jun 2020 20:53:04 +0200 Subject: [PATCH] Be more verbose on unexpected failure. (#511) I spent some time debugging an error, where the unexpected HTTP return code was reported to be -1. Digging deeper, I found the cause using this patch: "An unknown error occurred: ~/.netrc access too permissive: access permissions must restrict access to only the owner" --- changelogs/fragments/511-cloudflare_dns-verbose-failure.yml | 2 ++ plugins/modules/net_tools/cloudflare_dns.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/511-cloudflare_dns-verbose-failure.yml diff --git a/changelogs/fragments/511-cloudflare_dns-verbose-failure.yml b/changelogs/fragments/511-cloudflare_dns-verbose-failure.yml new file mode 100644 index 0000000000..5c7908a78f --- /dev/null +++ b/changelogs/fragments/511-cloudflare_dns-verbose-failure.yml @@ -0,0 +1,2 @@ +minor_changes: + - cloudflare_dns - Report unexpected failure with more detail (https://github.com/ansible-collections/community.general/pull/511). diff --git a/plugins/modules/net_tools/cloudflare_dns.py b/plugins/modules/net_tools/cloudflare_dns.py index 48901cab83..7634557129 100644 --- a/plugins/modules/net_tools/cloudflare_dns.py +++ b/plugins/modules/net_tools/cloudflare_dns.py @@ -452,7 +452,7 @@ class CloudflareAPI(object): timeout=self.timeout) if info['status'] not in [200, 304, 400, 401, 403, 429, 405, 415]: - self.module.fail_json(msg="Failed API call {0}; got unexpected HTTP code {1}".format(api_call, info['status'])) + self.module.fail_json(msg="Failed API call {0}; got unexpected HTTP code {1}: {2}".format(api_call, info['status'], info.get('msg'))) error_msg = '' if info['status'] == 401: