From 369076a1a40c58c591fcea2cd8a5998a6e44ccbd Mon Sep 17 00:00:00 2001 From: bverschueren Date: Tue, 29 Jan 2019 21:52:31 +0100 Subject: [PATCH] Fix gcp utils dict replace (#51426) * fix reference before assignment of new_item if item is plain string * fix KeyError if managed_zone is plain string --- lib/ansible/module_utils/gcp_utils.py | 2 +- lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/gcp_utils.py b/lib/ansible/module_utils/gcp_utils.py index 46bb2b88637..65cd877781d 100644 --- a/lib/ansible/module_utils/gcp_utils.py +++ b/lib/ansible/module_utils/gcp_utils.py @@ -69,7 +69,7 @@ def replace_resource_dict(item, value): new_item = ast.literal_eval(item) return replace_resource_dict(new_item, value) except ValueError: - return new_item + return item # Handles all authentication and HTTP sessions for GCP API calls. diff --git a/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py b/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py index 50b5f211887..d87bd82de3b 100644 --- a/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py +++ b/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py @@ -376,7 +376,7 @@ def prefetch_soa_resource(module): result = fetch_wrapped_resource(resource, 'dns#resourceRecordSet', 'dns#resourceRecordSetsListResponse', 'rrsets') if not result: - raise ValueError("Google DNS Managed Zone %s not found" % module.params['managed_zone']['name']) + raise ValueError("Google DNS Managed Zone %s not found" % replace_resource_dict(module.params['managed_zone'], 'name')) return result