diff --git a/changelogs/fragments/943-ec2_metadata_facts-fix-NoneType-callable.yml b/changelogs/fragments/943-ec2_metadata_facts-fix-NoneType-callable.yml new file mode 100644 index 00000000000..86ce04f8166 --- /dev/null +++ b/changelogs/fragments/943-ec2_metadata_facts-fix-NoneType-callable.yml @@ -0,0 +1,2 @@ +bugfixes: +- ec2_metadata_facts - fix ``'NoneType' object is not callable`` exception when using Ansible 2.13+ (https://github.com/ansible-collections/amazon.aws/issues/942). diff --git a/plugins/modules/ec2_metadata_facts.py b/plugins/modules/ec2_metadata_facts.py index ae298ea18c1..91f7860eeaf 100644 --- a/plugins/modules/ec2_metadata_facts.py +++ b/plugins/modules/ec2_metadata_facts.py @@ -477,7 +477,7 @@ def _fetch(self, url): if info.get('status') not in (200, 404): # fail out now self.module.fail_json(msg='Failed to retrieve metadata from AWS: {0}'.format(info['msg']), response=info) - if response: + if response and info['status'] < 400: data = response.read() else: data = None