Skip to content

Commit

Permalink
ec2_metadata_facts - Fix read failure in ansible 2.13+ (ansible-colle…
Browse files Browse the repository at this point in the history
…ctions#943)

ec2_metadata_facts - Fix read failure in ansible 2.13+

SUMMARY
Ansible 2.13+ changes the return conventions of fetch_url when an error occurs. Add a guard to prevent calling read which will be None.
Fixes ansible-collections#942
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ec2_metadata_facts
ADDITIONAL INFORMATION

Reviewed-by: Vinay Dandekar <None>
Reviewed-by: Mark Chappell <None>
  • Loading branch information
cmbrad authored Jul 27, 2022
1 parent 9e182cf commit 8f83de5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 1 addition & 1 deletion plugins/modules/ec2_metadata_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f83de5

Please sign in to comment.