mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Add option required=(True|False) to get_bin_path and update modules
Added required as optional argument to get_bin_path(). It defaults to false. Updated following modules to use required=True when calling get_bin_path(): apt_repository, easy_install, group, pip, supervisorctl, and user. Also removed _find_supervisorctl() from supervisorctl module and updated _is_running() to not need it.
This commit is contained in:
13
library/user
13
library/user
@@ -35,15 +35,8 @@ if os.path.exists('/etc/master.passwd'):
|
||||
# invoke adduser in lieu of useradd, nor pw in lieu of usermod.
|
||||
# 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):
|
||||
cmd = [get_bin_path(module, 'userdel')]
|
||||
cmd = [module.get_bin_path('userdel', True)]
|
||||
for key in kwargs:
|
||||
if key == 'force' and kwargs[key] == 'yes':
|
||||
cmd.append('-f')
|
||||
@@ -56,7 +49,7 @@ def user_del(module, user, **kwargs):
|
||||
return (rc, out, err)
|
||||
|
||||
def user_add(module, user, **kwargs):
|
||||
cmd = [get_bin_path(module, 'useradd')]
|
||||
cmd = [module.get_bin_path('useradd', True)]
|
||||
for key in kwargs:
|
||||
if key == 'uid' and kwargs[key] is not None:
|
||||
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.
|
||||
"""
|
||||
def user_mod(module, user, **kwargs):
|
||||
cmd = [get_bin_path(module, 'usermod')]
|
||||
cmd = [module.get_bin_path('usermod', True)]
|
||||
info = user_info(user)
|
||||
for key in kwargs:
|
||||
if key == 'uid':
|
||||
|
||||
Reference in New Issue
Block a user