@ -35,15 +35,8 @@ if os.path.exists('/etc/master.passwd'):
# invoke adduser in lieu of useradd, nor pw in lieu of usermod.
# invoke adduser in lieu of useradd, nor pw in lieu of usermod.
# That is, this won't work on FreeBSD.
# That is, this won't work on FreeBSD.
def get_bin_path(module, arg):
bin = module.get_bin_path(arg)
if bin is None:
module.fail_json(msg="Cannot find %s" % arg)
else:
return bin
def user_del(module, user, **kwargs):
def user_del(module, user, **kwargs):
cmd = [get_bin_path(module, 'userdel')]
cmd = [module.get_bin_path('userdel', True)]
for key in kwargs:
for key in kwargs:
if key == 'force' and kwargs[key] == 'yes':
if key == 'force' and kwargs[key] == 'yes':
cmd.append('-f')
cmd.append('-f')
@ -56,7 +49,7 @@ def user_del(module, user, **kwargs):
return (rc, out, err)
return (rc, out, err)
def user_add(module, user, **kwargs):
def user_add(module, user, **kwargs):
cmd = [get_bin_path(module, 'useradd')]
cmd = [module. get_bin_path('useradd', True )]
for key in kwargs:
for key in kwargs:
if key == 'uid' and kwargs[key] is not None:
if key == 'uid' and kwargs[key] is not None:
cmd.append('-u')
cmd.append('-u')
@ -103,7 +96,7 @@ Without spwd, we would have to resort to reading /etc/shadow
to get the encrypted string. For now, punt on idempotent password changes.
to get the encrypted string. For now, punt on idempotent password changes.
"""
"""
def user_mod(module, user, **kwargs):
def user_mod(module, user, **kwargs):
cmd = [get_bin_path(module, 'usermod')]
cmd = [module. get_bin_path('usermod', True )]
info = user_info(user)
info = user_info(user)
for key in kwargs:
for key in kwargs:
if key == 'uid':
if key == 'uid':