From 02dfc76e3a374b065aa930fdac88750cf7c82360 Mon Sep 17 00:00:00 2001 From: Stefan Horning Date: Wed, 24 Mar 2021 20:28:01 +0100 Subject: [PATCH] =?UTF-8?q?Make=20iam=20module=20more=20predictable=20and?= =?UTF-8?q?=20idempotent=20=E2=80=A6=20(#369)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make iam module more predictable and idempotent on returning the user_name it creates/deletes * Add changelog fragment for iam module change --- iam.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iam.py b/iam.py index 4c774285f6f..e65824a4862 100644 --- a/iam.py +++ b/iam.py @@ -742,7 +742,7 @@ def main(): (user_groups, changed) = set_users_groups( module, iam, name, groups, been_updated, new_name) module.exit_json( - user_meta=meta, groups=user_groups, keys=keys, changed=changed) + user_meta=meta, groups=user_groups, user_name=meta['created_user']['user_name'], keys=keys, changed=changed) elif state in ['present', 'update'] and user_exists: if update_pw == 'on_create': @@ -778,7 +778,7 @@ def main(): created_keys=new_key, user_meta=user_meta) elif new_name and not new_path and not been_updated: module.exit_json( - changed=changed, groups=user_groups, old_user_name=orig_name, new_user_name=new_name, keys=key_list, + changed=changed, groups=user_groups, old_user_name=orig_name, user_name=new_name, new_user_name=new_name, keys=key_list, created_keys=new_key, user_meta=user_meta) elif new_name and not new_path and been_updated: module.exit_json( @@ -802,7 +802,7 @@ def main(): try: set_users_groups(module, iam, name, '') name, changed = delete_user(module, iam, name) - module.exit_json(deleted_user=name, changed=changed) + module.exit_json(deleted_user=name, user_name=name, changed=changed) except Exception as ex: module.fail_json(changed=changed, msg=str(ex))