From d82c5fb55f5d1077030b3856542af33d2a63f6bf Mon Sep 17 00:00:00 2001 From: Per-Henrik Lundblom Date: Wed, 17 Oct 2018 18:31:31 +0200 Subject: [PATCH] [aws] ec2_vol_facts: only access volume tags when set (#46801) (cherry picked from commit e744c838081cc2b3db308809d161f2c8393068d6) --- .../fragments/46800-ec2_vol_facts-handle-missing-tags.yml | 3 +++ lib/ansible/modules/cloud/amazon/ec2_vol_facts.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/46800-ec2_vol_facts-handle-missing-tags.yml diff --git a/changelogs/fragments/46800-ec2_vol_facts-handle-missing-tags.yml b/changelogs/fragments/46800-ec2_vol_facts-handle-missing-tags.yml new file mode 100644 index 00000000000..9465b11122a --- /dev/null +++ b/changelogs/fragments/46800-ec2_vol_facts-handle-missing-tags.yml @@ -0,0 +1,3 @@ +--- +bugfixes: +- Only access EC2 volume tags when set diff --git a/lib/ansible/modules/cloud/amazon/ec2_vol_facts.py b/lib/ansible/modules/cloud/amazon/ec2_vol_facts.py index acc59289b91..0acb456e5c1 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_vol_facts.py +++ b/lib/ansible/modules/cloud/amazon/ec2_vol_facts.py @@ -92,7 +92,7 @@ def get_volume_info(volume, region): 'status': attachment[0]["state"] if len(attachment) > 0 else None, 'delete_on_termination': attachment[0]["delete_on_termination"] if len(attachment) > 0 else None }, - 'tags': boto3_tag_list_to_ansible_dict(volume['tags']) + 'tags': boto3_tag_list_to_ansible_dict(volume['tags']) if "tags" in volume else None } return volume_info