From ac3341cc1283f70051a547949ee8becb3d727c57 Mon Sep 17 00:00:00 2001 From: Stephen Fromm Date: Tue, 10 Jul 2012 16:37:07 -0700 Subject: [PATCH] Minor fix to user module to further streamline setting 'changed' flag --- library/user | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/library/user b/library/user index 7bd11e3a7d6..c69f4d97ccc 100755 --- a/library/user +++ b/library/user @@ -310,20 +310,16 @@ if append not in [ 'yes', 'no' ]: if name is None: fail_json(msg='name is required') -result = {} -rc = 0 +rc = None out = '' err = '' +result = {} result['name'] = name if state == 'absent': - if not user_exists(name): - result['changed'] = False - else: + if user_exists(name): (rc, out, err) = user_del(name, force=force, remove=remove) if rc != 0: fail_json(name=name, msg=err) - else: - result['changed'] = True result['force'] = force result['remove'] = remove elif state == 'present': @@ -338,13 +334,13 @@ elif state == 'present': password=password, append=append) if rc is not None and rc != 0: fail_json(name=name, msg=err) - if rc is None: - result['changed'] = False - else: - result['changed'] = True if password is not None: result['password'] = 'NOTLOGGINGPASSWORD' +if rc is None: + result['changed'] = False +else: + result['changed'] = True if out: result['stdout'] = out if err: