Migrate apt_repository, group, and supervisorctl to use module.get_bin_path

reviewable/pr18780/r1
Stephen Fromm 12 years ago
parent 61bc4bc0ed
commit a284228e10

@ -26,17 +26,7 @@
import platform
APT = "/usr/bin/apt-get"
def _find_binary(module):
binaries = ['/usr/bin/add-apt-repository']
for e in binaries:
if os.path.exists(e):
return e
module.fail_json(msg='Unabled to find any of the following executables '
'%s' % binaries)
ADD_APT_REPO = 'add-apt-repository'
def _run(cmd):
# returns (rc, stdout, stderr) from shell command
@ -56,7 +46,10 @@ def main():
module = AnsibleModule(argument_spec=arg_spec)
add_apt_repository = _find_binary(module)
add_apt_repository = module.get_bin_path(ADD_APT_REPO)
if add_apt_repository is None:
module.fail_json(msg='Unabled to find any of the following executables '
'%s' % binaries)
repo = module.params['repo']
state = module.params['state']

@ -21,12 +21,11 @@
import grp
def get_bin_path(module, arg):
if os.path.exists('/usr/sbin/%s' % arg):
return '/usr/sbin/%s' % arg
elif os.path.exists('/sbin/%s' % arg):
return '/sbin/%s' % arg
else:
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]

@ -52,7 +52,9 @@ def main():
name = module.params['name']
state = module.params['state']
SUPERVISORCTL = _find_supervisorctl()
SUPERVISORCTL = module.get_bin_path('supervisorctl')
if SUPERVISORCTL is None:
module.fail_json(msg='supervisorctl is not installed')
if SUPERVISORCTL is None:
module.fail_json(msg='supervisorctl is not installed')

Loading…
Cancel
Save