From 151f981ce5b16b5e1723eb5c6a80dfe062c861d2 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 4 Feb 2016 01:29:56 -0800 Subject: [PATCH] Make modify_user honor check mode on OS X. --- system/user.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/system/user.py b/system/user.py index 29d84bf7c13..570cc0583ca 100755 --- a/system/user.py +++ b/system/user.py @@ -1551,6 +1551,8 @@ class DarwinUser(User): target = set([]) for remove in current - target: + if self.module.check_mode: + return (0, '', '', True) (_rc, _err, _out) = self.__modify_group(remove, 'delete') rc += rc out += _out @@ -1558,6 +1560,8 @@ class DarwinUser(User): changed = True for add in target - current: + if self.module.check_mode: + return (0, '', '', True) (_rc, _err, _out) = self.__modify_group(add, 'add') rc += _rc out += _out @@ -1594,6 +1598,8 @@ class DarwinUser(User): if not self.name in hidden_users: cmd = [ 'defaults', 'write', plist_file, 'HiddenUsersList', '-array-add', self.name ] + if self.module.check_mode: + return 0 (rc, out, err) = self.execute_command(cmd) if rc != 0: self.module.fail_json( @@ -1606,6 +1612,8 @@ class DarwinUser(User): cmd = [ 'defaults', 'write', plist_file, 'HiddenUsersList', '-array' ] + hidden_users + if self.module.check_mode: + return 0 (rc, out, err) = self.execute_command(cmd) if rc != 0: self.module.fail_json( @@ -1708,6 +1716,8 @@ class DarwinUser(User): cmd = self._get_dscl() cmd += [ '-create', '/Users/%s' % self.name, field[1], self.__dict__[field[0]]] + if self.module.check_mode: + return (0, '', '') (rc, _err, _out) = self.execute_command(cmd) if rc != 0: self.module.fail_json( @@ -1717,6 +1727,8 @@ class DarwinUser(User): out += _out err += _err if self.update_password == 'always' and self.password is not None: + if self.module.check_mode: + return (0, '', '') (rc, _err, _out) = self._change_user_password() out += _out err += _err