Add group support to check mode.

reviewable/pr18780/r1
Michael DeHaan 12 years ago
parent 69784f0215
commit ad1d038041

15
group

@ -118,6 +118,8 @@ class Group(object):
cmd.append(kwargs[key]) cmd.append(kwargs[key])
if len(cmd) == 1: if len(cmd) == 1:
return (None, '', '') return (None, '', '')
if self.module.check_mode:
return (True, '', '')
cmd.append(self.name) cmd.append(self.name)
return self.execute_command(cmd) return self.execute_command(cmd)
@ -201,6 +203,8 @@ class AIX(Group):
cmd.append('id='+kwargs[key]) cmd.append('id='+kwargs[key])
if len(cmd) == 1: if len(cmd) == 1:
return (None, '', '') return (None, '', '')
if self.module.check_mode:
return (True, '', '')
cmd.append(self.name) cmd.append(self.name)
return self.execute_command(cmd) return self.execute_command(cmd)
@ -213,7 +217,8 @@ def main():
name=dict(required=True), name=dict(required=True),
gid=dict(default=None), gid=dict(default=None),
system=dict(default='no', choices=['yes', 'no']), system=dict(default='no', choices=['yes', 'no']),
) ),
supports_check_mode=True
) )
group = Group(module) group = Group(module)
@ -230,13 +235,21 @@ def main():
result = {} result = {}
result['name'] = group.name result['name'] = group.name
result['state'] = group.state result['state'] = group.state
if group.state == 'absent': if group.state == 'absent':
if group.group_exists(): if group.group_exists():
if module.check_mode:
module.exit_json(changed=True)
(rc, out, err) = group.group_del() (rc, out, err) = group.group_del()
if rc != 0: if rc != 0:
module.fail_json(name=group.name, msg=err) module.fail_json(name=group.name, msg=err)
elif group.state == 'present': elif group.state == 'present':
if not group.group_exists(): if not group.group_exists():
if module.check_mode:
module.exit_json(changed=True)
(rc, out, err) = group.group_add(gid=group.gid, system=group.system) (rc, out, err) = group.group_add(gid=group.gid, system=group.system)
else: else:
(rc, out, err) = group.group_mod(gid=group.gid) (rc, out, err) = group.group_mod(gid=group.gid)

Loading…
Cancel
Save