From 6410e139037db14189a47173b90fe110566f69d9 Mon Sep 17 00:00:00 2001 From: Jonathan Davila Date: Sun, 14 May 2017 17:29:44 -0400 Subject: [PATCH] Fix bug in iam_role (#22618) --- lib/ansible/modules/cloud/amazon/iam_role.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/iam_role.py b/lib/ansible/modules/cloud/amazon/iam_role.py index a1b8ea0739..cf837b4f50 100644 --- a/lib/ansible/modules/cloud/amazon/iam_role.py +++ b/lib/ansible/modules/cloud/amazon/iam_role.py @@ -190,7 +190,7 @@ def create_or_update_role(connection, module): changed = False # Get role - role = get_role(connection, params['RoleName']) + role = get_role(connection, params['RoleName'], module) # If role is None, create it if role is None: @@ -258,7 +258,7 @@ def create_or_update_role(connection, module): connection.add_role_to_instance_profile(InstanceProfileName=params['RoleName'], RoleName=params['RoleName']) # Get the role again - role = get_role(connection, params['RoleName']) + role = get_role(connection, params['RoleName'], module) role['attached_policies'] = get_attached_policy_list(connection, params['RoleName']) module.exit_json(changed=changed, iam_role=camel_dict_to_snake_dict(role)) @@ -269,7 +269,7 @@ def destroy_role(connection, module): params = dict() params['RoleName'] = module.params.get('name') - if get_role(connection, params['RoleName']): + if get_role(connection, params['RoleName'], module): # We need to remove any instance profiles from the role before we delete it try: @@ -301,7 +301,7 @@ def destroy_role(connection, module): module.exit_json(changed=True) -def get_role(connection, name): +def get_role(connection, name, module): params = dict() params['RoleName'] = name