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

@@ -20,22 +20,15 @@
import grp
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 group_del(module, group):
cmd = [get_bin_path(module, 'groupdel'), group]
cmd = [module.get_bin_path('groupdel', True), group]
p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = p.communicate()
rc = p.returncode
return (rc, out, err)
def group_add(module, group, **kwargs):
cmd = [get_bin_path(module, 'groupadd')]
cmd = [module.get_bin_path('groupadd', True)]
for key in kwargs:
if key == 'gid' and kwargs[key] is not None:
cmd.append('-g')
@@ -49,7 +42,7 @@ def group_add(module, group, **kwargs):
return (rc, out, err)
def group_mod(module, group, **kwargs):
cmd = [get_bin_path(module, 'groupmod')]
cmd = [module.get_bin_path('groupmod', True)]
info = group_info(group)
for key in kwargs:
if key == 'gid':