fix bug in supervisorctl module

This commit is contained in:
Matt Wright 2012-08-28 19:21:05 -04:00
parent f9e9753141
commit a82928e7dc

View file

@ -19,8 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# #
SUPERVISORCTL = None
def _find_supervisorctl(): def _find_supervisorctl():
paths = ['/usr/local/bin', '/usr/bin'] paths = ['/usr/local/bin', '/usr/bin']
@ -29,11 +27,9 @@ def _find_supervisorctl():
if os.path.exists(e): if os.path.exists(e):
return e return e
module.fail_json(msg='supervisorctl is not installed')
def _is_running(name): def _is_running(name):
rc, out, err = _run('%s status %s' % (SUPERVISORCTL, name)) rc, out, err = _run('%s status %s' % (_find_supervisorctl(), name))
return 'RUNNING' in out return 'RUNNING' in out
@ -58,6 +54,9 @@ def main():
SUPERVISORCTL = _find_supervisorctl() SUPERVISORCTL = _find_supervisorctl()
if SUPERVISORCTL is None:
module.fail_json(msg='supervisorctl is not installed')
running = _is_running(name) running = _is_running(name)
if running and state == 'started': if running and state == 'started':