From 9f3658d9011d5c0b8655802c54c5b8f38a7c189f Mon Sep 17 00:00:00 2001 From: toninog Date: Mon, 8 Jun 2015 13:55:24 +0100 Subject: [PATCH 1/2] Fixed bug in example where updating a user to a group Fixed bug in create_group and update_group whereby paramaters were not being set correctly. --- cloud/amazon/iam.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cloud/amazon/iam.py b/cloud/amazon/iam.py index a4111ee5477..d496a7a40c7 100644 --- a/cloud/amazon/iam.py +++ b/cloud/amazon/iam.py @@ -133,7 +133,7 @@ task: iam_type: user name: jdavila state: update - group: "{{ item.created_group.group_name }}" + groups: "{{ item.created_group.group_name }}" with_items: new_groups.results ''' @@ -376,7 +376,7 @@ new_name=None): return (groups, changed) -def create_group(module, iam, name, path): +def create_group(module=None, iam=None, name=None, path=None): changed = False try: iam.create_group( @@ -414,8 +414,7 @@ def delete_group(module, iam, name): changed = True return changed, name - -def update_group(module, iam, name, new_name, new_path): +def update_group(module=None, iam=None, name=None, new_name=None, new_path=None): changed = False try: current_group_path = iam.get_group( @@ -667,7 +666,7 @@ def main(): module.exit_json(changed=changed, group_name=new_group) elif state in ['present', 'update'] and group_exists: changed, updated_name, updated_path, cur_path = update_group( - iam, name, new_name, new_path) + iam=iam, name=name, new_name=new_name, new_path=new_path) if new_path and new_name: module.exit_json(changed=changed, old_group_name=name, From 68cfbca624c118d85ee1ee2547755cfd356b156d Mon Sep 17 00:00:00 2001 From: toninog Date: Mon, 8 Jun 2015 14:21:49 +0100 Subject: [PATCH 2/2] Fixed more issues with the delete_group and paramater mismatch --- cloud/amazon/iam.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cloud/amazon/iam.py b/cloud/amazon/iam.py index d496a7a40c7..3cfca55135c 100644 --- a/cloud/amazon/iam.py +++ b/cloud/amazon/iam.py @@ -133,7 +133,7 @@ task: iam_type: user name: jdavila state: update - groups: "{{ item.created_group.group_name }}" + group: "{{ item.created_group.group_name }}" with_items: new_groups.results ''' @@ -388,7 +388,7 @@ def create_group(module=None, iam=None, name=None, path=None): return name, changed -def delete_group(module, iam, name): +def delete_group(module=None, iam=None, name=None): changed = False try: iam.delete_group(name) @@ -662,7 +662,7 @@ def main(): group_exists = name in orig_group_list if state == 'present' and not group_exists: - new_group, changed = create_group(iam, name, path) + new_group, changed = create_group(iam=iam, name=name, path=path) module.exit_json(changed=changed, group_name=new_group) elif state in ['present', 'update'] and group_exists: changed, updated_name, updated_path, cur_path = update_group( @@ -690,7 +690,7 @@ def main(): changed=changed, msg="Update Failed. Group %s doesn't seem to exit!" % name) elif state == 'absent': if name in orig_group_list: - removed_group, changed = delete_group(iam, name) + removed_group, changed = delete_group(iam=iam, name=name) module.exit_json(changed=changed, delete_group=removed_group) else: module.exit_json(changed=changed, msg="Group already absent")