Make modify_user honor check mode on OS X.
This commit is contained in:
parent
9a90721720
commit
04ad3fe304
1 changed files with 12 additions and 0 deletions
|
@ -1550,6 +1550,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
|
||||
|
@ -1557,6 +1559,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
|
||||
|
@ -1593,6 +1597,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(
|
||||
|
@ -1605,6 +1611,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(
|
||||
|
@ -1707,6 +1715,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(
|
||||
|
@ -1716,6 +1726,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
|
||||
|
|
Loading…
Reference in a new issue