Merge pull request #2375 from sergevanginderachter/user-non-unique

Add nonunique option to user module, translating to the -o/--non-unique ...
pull/2366/merge
Michael DeHaan 12 years ago
commit 11d3bd4025

@ -41,6 +41,14 @@ options:
required: false required: false
description: description:
- Optionally sets the I(UID) of the user. - Optionally sets the I(UID) of the user.
non_unique:
required: false
default: "no"
choices: [ "yes", "no" ]
description:
- Optionally when used with the -u option, this option allows to
change the user ID to a non-unique value.
(New in 1.1)
group: group:
required: false required: false
description: description:
@ -196,6 +204,7 @@ class User(object):
self.state = module.params['state'] self.state = module.params['state']
self.name = module.params['name'] self.name = module.params['name']
self.uid = module.params['uid'] self.uid = module.params['uid']
self.non_unique = module.params['non_unique']
self.group = module.params['group'] self.group = module.params['group']
self.groups = module.params['groups'] self.groups = module.params['groups']
self.comment = module.params['comment'] self.comment = module.params['comment']
@ -244,6 +253,9 @@ class User(object):
cmd.append('-u') cmd.append('-u')
cmd.append(self.uid) cmd.append(self.uid)
if self.non_unique:
cmd.append('-o')
if self.group is not None: if self.group is not None:
if not self.group_exists(self.group): if not self.group_exists(self.group):
self.module.fail_json(msg="Group %s does not exist" % self.group) self.module.fail_json(msg="Group %s does not exist" % self.group)
@ -294,6 +306,9 @@ class User(object):
cmd.append('-u') cmd.append('-u')
cmd.append(self.uid) cmd.append(self.uid)
if self.non_unique:
cmd.append('-o')
if self.group is not None: if self.group is not None:
if not self.group_exists(self.group): if not self.group_exists(self.group):
self.module.fail_json(msg="Group %s does not exist" % self.group) self.module.fail_json(msg="Group %s does not exist" % self.group)
@ -531,6 +546,9 @@ class FreeBsdUser(User):
cmd.append('-u') cmd.append('-u')
cmd.append(self.uid) cmd.append(self.uid)
if self.non_unique:
cmd.append('-o')
if self.comment is not None: if self.comment is not None:
cmd.append('-c') cmd.append('-c')
cmd.append(self.comment) cmd.append(self.comment)
@ -591,6 +609,9 @@ class FreeBsdUser(User):
cmd.append('-u') cmd.append('-u')
cmd.append(self.uid) cmd.append(self.uid)
if self.non_unique:
cmd.append('-o')
if self.comment is not None and info[4] != self.comment: if self.comment is not None and info[4] != self.comment:
cmd.append('-c') cmd.append('-c')
cmd.append(self.comment) cmd.append(self.comment)
@ -691,6 +712,9 @@ class SunOS(User):
cmd.append('-u') cmd.append('-u')
cmd.append(self.uid) cmd.append(self.uid)
if self.non_unique:
cmd.append('-o')
if self.group is not None: if self.group is not None:
if not self.group_exists(self.group): if not self.group_exists(self.group):
self.module.fail_json(msg="Group %s does not exist" % self.group) self.module.fail_json(msg="Group %s does not exist" % self.group)
@ -752,6 +776,9 @@ class SunOS(User):
cmd.append('-u') cmd.append('-u')
cmd.append(self.uid) cmd.append(self.uid)
if self.non_unique:
cmd.append('-o')
if self.group is not None: if self.group is not None:
if not self.group_exists(self.group): if not self.group_exists(self.group):
self.module.fail_json(msg="Group %s does not exist" % self.group) self.module.fail_json(msg="Group %s does not exist" % self.group)
@ -857,6 +884,9 @@ class AIX(User):
cmd.append('-u') cmd.append('-u')
cmd.append(self.uid) cmd.append(self.uid)
if self.non_unique:
cmd.append('-o')
if self.group is not None: if self.group is not None:
if not self.group_exists(self.group): if not self.group_exists(self.group):
self.module.fail_json(msg="Group %s does not exist" % self.group) self.module.fail_json(msg="Group %s does not exist" % self.group)
@ -910,6 +940,9 @@ class AIX(User):
cmd.append('-u') cmd.append('-u')
cmd.append(self.uid) cmd.append(self.uid)
if self.non_unique:
cmd.append('-o')
if self.group is not None: if self.group is not None:
if not self.group_exists(self.group): if not self.group_exists(self.group):
self.module.fail_json(msg="Group %s does not exist" % self.group) self.module.fail_json(msg="Group %s does not exist" % self.group)
@ -995,6 +1028,7 @@ def main():
state=dict(default='present', choices=['present', 'absent'], type='str'), state=dict(default='present', choices=['present', 'absent'], type='str'),
name=dict(required=True, aliases=['user'], type='str'), name=dict(required=True, aliases=['user'], type='str'),
uid=dict(default=None, type='str'), uid=dict(default=None, type='str'),
non_unique=dict(default='no', type='bool'),
group=dict(default=None, type='str'), group=dict(default=None, type='str'),
groups=dict(default=None, type='str'), groups=dict(default=None, type='str'),
comment=dict(default=None, type='str'), comment=dict(default=None, type='str'),

Loading…
Cancel
Save