Skip to content

Commit

Permalink
ipauser: Do not try to modify user when not changing password
Browse files Browse the repository at this point in the history
If a playbook to ensure the existence of a user contains 'random:false'
and 'update_password: always' is executed twice, the second execution
will raise an exception due to "No modifications to perform", as there
is actually nothing to modify.

The fix for the issue is to remove 'random' if it is not set to true, as
setting it to 'false' would have no effect on the user object.

Related: https://issues.redhat.com/browse/RHEL-4934
  • Loading branch information
rjeffman committed Nov 28, 2023
1 parent 48c0fd0 commit ca54969
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/modules/ipauser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,10 @@ def main():
del args["userpassword"]
if "random" in args:
del args["random"]
# if using "random:false" password should not be
# generated.
if not args.get("random", True):
del args["random"]
if "noprivate" in args:
del args["noprivate"]

Expand Down
11 changes: 11 additions & 0 deletions tests/user/test_user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@
register: result
failed_when: not result.changed or result.failed

- name: Ensure user presence with 'random:false'
ipauser:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: pinky
first: pinky
last: Acme
random: false
register: result
failed_when: result.changed or result.failed

- name: Set street, again
ipauser:
ipaadmin_password: SomeADMINpassword
Expand Down

0 comments on commit ca54969

Please sign in to comment.