From a824cd633f14c108bfc015ef7b80681e147af826 Mon Sep 17 00:00:00 2001 From: Nick Aslanidis Date: Sat, 7 May 2016 21:00:23 +1000 Subject: [PATCH] corrected version to 2.2. Ensure no vpc-id is returned if detached --- lib/ansible/modules/extras/cloud/amazon/ec2_vpc_vgw.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_vgw.py b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_vgw.py index 466b81c8762..9861e7d0b7e 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_vgw.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_vpc_vgw.py @@ -22,7 +22,7 @@ description: - Deletes AWS VPN Virtual Gateways - Attaches Virtual Gateways to VPCs - Detaches Virtual Gateways from VPCs -version_added: "2.1" +version_added: "2.2" requirements: [ boto3 ] options: state: @@ -139,7 +139,7 @@ def get_vgw_info(vgws): for tag in vgw['Tags']: vgw_info['tags'][tag['Key']] = tag['Value'] - if len(vgw['VpcAttachments']) != 0: + if len(vgw['VpcAttachments']) != 0 and vgw['VpcAttachments'][0]['State'] == 'attached': vgw_info['vpc_id'] = vgw['VpcAttachments'][0]['VpcId'] return vgw_info @@ -537,7 +537,7 @@ def ensure_vgw_absent(client, module): changed = False deleted_vgw = None - result = get_vgw_info(deleted_vgw) + result = deleted_vgw return changed, result