mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add group support to check mode.
This commit is contained in:
parent
fdbbb171ba
commit
ad89ab7c5d
1 changed files with 14 additions and 1 deletions
|
@ -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…
Reference in a new issue