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

@@ -19,17 +19,8 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
def _find_supervisorctl():
paths = ['/usr/local/bin', '/usr/bin']
for p in paths:
e = p + '/supervisorctl'
if os.path.exists(e):
return e
def _is_running(name):
rc, out, err = _run('%s status %s' % (_find_supervisorctl(), name))
def _is_running(name, supervisorctl):
rc, out, err = _run('%s status %s' % (supervisorctl, name))
return 'RUNNING' in out
@@ -52,14 +43,12 @@ def main():
name = module.params['name']
state = module.params['state']
SUPERVISORCTL = module.get_bin_path('supervisorctl')
if SUPERVISORCTL is None:
module.fail_json(msg='supervisorctl is not installed')
SUPERVISORCTL = module.get_bin_path('supervisorctl', True)
if SUPERVISORCTL is None:
module.fail_json(msg='supervisorctl is not installed')
running = _is_running(name)
running = _is_running(name, SUPERVISORCTL)
if running and state == 'started':
module.exit_json(changed=False, name=name, state=state)