From df77d087a52cd7ab004ef1d1b9be6606f1962f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Schr=C3=B6der?= Date: Mon, 29 Jun 2015 23:28:55 +0200 Subject: [PATCH] Adds the check for 'not None' also when building host_info dict for ElastiCache clusters, nodes and replication groups --- plugins/inventory/ec2.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/inventory/ec2.py b/plugins/inventory/ec2.py index 081990cd8f..864a64f5ed 100755 --- a/plugins/inventory/ec2.py +++ b/plugins/inventory/ec2.py @@ -1117,10 +1117,14 @@ class Ec2Inventory(object): # Target: Almost everything elif key == 'ec2_security_groups': - sg_ids = [] - for sg in value: - sg_ids.append(sg['SecurityGroupId']) - host_info["ec2_security_group_ids"] = ','.join([str(i) for i in sg_ids]) + + # Skip if SecurityGroups is None + # (it is possible to have the key defined but no value in it). + if value is not None: + sg_ids = [] + for sg in value: + sg_ids.append(sg['SecurityGroupId']) + host_info["ec2_security_group_ids"] = ','.join([str(i) for i in sg_ids]) # Target: Everything # Preserve booleans and integers