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:
Stephen Fromm
2012-08-30 10:31:23 -07:00
parent e5a635672c
commit 6742e9c3f4
7 changed files with 21 additions and 49 deletions

View File

@@ -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':