Skip to content

Commit

Permalink
Make iam module more predictable and idempotent … (ansible-collection…
Browse files Browse the repository at this point in the history
…s#369)

* Make iam module more predictable and idempotent on returning the user_name it creates/deletes
* Add changelog fragment for iam module change
  • Loading branch information
stefanhorning authored and abikouo committed Sep 18, 2023
1 parent 19ad24f commit 02dfc76
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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(
Expand All @@ -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))
Expand Down

0 comments on commit 02dfc76

Please sign in to comment.