From 197658aff48be2e378ffaee43e0ab94d7568411e Mon Sep 17 00:00:00 2001 From: "Ryan S. Brown" Date: Wed, 14 Dec 2016 19:43:59 -0500 Subject: [PATCH] Handle when the AMI launch permissions are unset. Use an empty list to avoid a TypeError because `'NoneType' is not iterable`` --- lib/ansible/modules/cloud/amazon/ec2_ami.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_ami.py b/lib/ansible/modules/cloud/amazon/ec2_ami.py index de3a31c4a76..26426cf26d3 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_ami.py +++ b/lib/ansible/modules/cloud/amazon/ec2_ami.py @@ -88,7 +88,10 @@ options: version_added: "2.0" launch_permissions: description: - - Users and groups that should be able to launch the ami. Expects dictionary with a key of user_ids and/or group_names. user_ids should be a list of account ids. group_name should be a list of groups, "all" is the only acceptable value currently. + - Users and groups that should be able to launch the ami. Expects + dictionary with a key of user_ids and/or group_names. user_ids should + be a list of account ids. group_name should be a list of groups, "all" + is the only acceptable value currently. required: false default: null version_added: "2.0" @@ -488,7 +491,7 @@ def update_image(module, ec2): """ image_id = module.params.get('image_id') - launch_permissions = module.params.get('launch_permissions') + launch_permissions = module.params.get('launch_permissions') or [] if 'user_ids' in launch_permissions: launch_permissions['user_ids'] = [str(user_id) for user_id in launch_permissions['user_ids']]