mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Minor fix to user module to further streamline setting 'changed' flag
This commit is contained in:
parent
3235da074e
commit
ac3341cc12
1 changed files with 7 additions and 11 deletions
18
library/user
18
library/user
|
@ -310,20 +310,16 @@ if append not in [ 'yes', 'no' ]:
|
||||||
if name is None:
|
if name is None:
|
||||||
fail_json(msg='name is required')
|
fail_json(msg='name is required')
|
||||||
|
|
||||||
result = {}
|
rc = None
|
||||||
rc = 0
|
|
||||||
out = ''
|
out = ''
|
||||||
err = ''
|
err = ''
|
||||||
|
result = {}
|
||||||
result['name'] = name
|
result['name'] = name
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
if not user_exists(name):
|
if user_exists(name):
|
||||||
result['changed'] = False
|
|
||||||
else:
|
|
||||||
(rc, out, err) = user_del(name, force=force, remove=remove)
|
(rc, out, err) = user_del(name, force=force, remove=remove)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
fail_json(name=name, msg=err)
|
fail_json(name=name, msg=err)
|
||||||
else:
|
|
||||||
result['changed'] = True
|
|
||||||
result['force'] = force
|
result['force'] = force
|
||||||
result['remove'] = remove
|
result['remove'] = remove
|
||||||
elif state == 'present':
|
elif state == 'present':
|
||||||
|
@ -338,13 +334,13 @@ elif state == 'present':
|
||||||
password=password, append=append)
|
password=password, append=append)
|
||||||
if rc is not None and rc != 0:
|
if rc is not None and rc != 0:
|
||||||
fail_json(name=name, msg=err)
|
fail_json(name=name, msg=err)
|
||||||
if rc is None:
|
|
||||||
result['changed'] = False
|
|
||||||
else:
|
|
||||||
result['changed'] = True
|
|
||||||
if password is not None:
|
if password is not None:
|
||||||
result['password'] = 'NOTLOGGINGPASSWORD'
|
result['password'] = 'NOTLOGGINGPASSWORD'
|
||||||
|
|
||||||
|
if rc is None:
|
||||||
|
result['changed'] = False
|
||||||
|
else:
|
||||||
|
result['changed'] = True
|
||||||
if out:
|
if out:
|
||||||
result['stdout'] = out
|
result['stdout'] = out
|
||||||
if err:
|
if err:
|
||||||
|
|
Loading…
Reference in a new issue