From a419b26d320b63a433f03228c3482d21e86d18a2 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 7 Oct 2022 16:58:40 +0200 Subject: [PATCH] Fix AttributeError when running ec2_metadata_facts fixes: #1134 --- changelogs/fragments/1134-ec2_metadata_facts-AttributeError.yml | 2 ++ plugins/modules/ec2_metadata_facts.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/1134-ec2_metadata_facts-AttributeError.yml diff --git a/changelogs/fragments/1134-ec2_metadata_facts-AttributeError.yml b/changelogs/fragments/1134-ec2_metadata_facts-AttributeError.yml new file mode 100644 index 00000000000..5a836fa7407 --- /dev/null +++ b/changelogs/fragments/1134-ec2_metadata_facts-AttributeError.yml @@ -0,0 +1,2 @@ +bugfixes: +- ec2_metadata_facts - fixed ``AttributeError`` (https://github.com/ansible-collections/amazon.aws/issues/1134). diff --git a/plugins/modules/ec2_metadata_facts.py b/plugins/modules/ec2_metadata_facts.py index 5a7875e634a..754fc34a294 100644 --- a/plugins/modules/ec2_metadata_facts.py +++ b/plugins/modules/ec2_metadata_facts.py @@ -528,7 +528,7 @@ def fetch(self, uri, recurse=True): self._data['%s' % (new_uri)] = content for (key, value) in json_dict.items(): self._data['%s:%s' % (new_uri, key.lower())] = value - except json.JSONDecodeError: + except (json.JSONDecodeError, AttributeError): self._data['%s' % (new_uri)] = content # not a stringified JSON string def fix_invalid_varnames(self, data):