@ -110,6 +110,8 @@ def user_add(user, **kwargs):
cmd.append('-m')
cmd.append('-m')
else:
else:
cmd.append('-M')
cmd.append('-M')
elif key == 'system' and kwargs[key] == 'yes':
cmd.append('-r')
cmd.append(user)
cmd.append(user)
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
rc = subprocess.call(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if rc == 0:
if rc == 0:
@ -269,6 +271,7 @@ remove = params.get('remove', False)
# ===========================================
# ===========================================
# following options are specific to useradd
# following options are specific to useradd
createhome = params.get('createhome', 'yes')
createhome = params.get('createhome', 'yes')
system = params.get('system', 'no')
# ===========================================
# ===========================================
# following options are specific to usermod
# following options are specific to usermod
@ -278,6 +281,8 @@ if state not in [ 'present', 'absent' ]:
fail_json(msg='invalid state')
fail_json(msg='invalid state')
if createhome not in [ 'yes', 'no' ]:
if createhome not in [ 'yes', 'no' ]:
fail_json(msg='invalid createhome')
fail_json(msg='invalid createhome')
if system not in ['yes', 'no']:
fail_json(msg='invalid system')
if append not in [ 'yes', 'no' ]:
if append not in [ 'yes', 'no' ]:
fail_json(msg='invalid append')
fail_json(msg='invalid append')
if name is None:
if name is None:
@ -293,7 +298,8 @@ elif state == 'present':
if not user_exists(name):
if not user_exists(name):
changed = user_add(name, uid=uid, group=group, groups=groups,
changed = user_add(name, uid=uid, group=group, groups=groups,
comment=comment, home=home, shell=shell,
comment=comment, home=home, shell=shell,
password=password, createhome=createhome)
password=password, createhome=createhome,
system=system)
else:
else:
changed = user_mod(name, uid=uid, group=group, groups=groups,
changed = user_mod(name, uid=uid, group=group, groups=groups,
comment=comment, home=home, shell=shell,
comment=comment, home=home, shell=shell,