1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fix up service module to make it start processes that are listed to be

running and to report errors from starting them
This commit is contained in:
Seth Vidal 2012-05-04 01:20:51 -04:00
parent b300aac551
commit 81418afbbb

View file

@ -138,9 +138,9 @@ status = status_stdout + status_stderr
running = False running = False
if status_stdout.find("not running") != -1: if status_stdout.find("stopped") != -1 or rc == 3:
running = False running = False
elif status_stdout.find("running") != -1: elif status_stdout.find("running") != -1 or rc == 0:
running = True running = True
elif name == 'iptables' and status_stdout.find("ACCEPT") != -1: elif name == 'iptables' and status_stdout.find("ACCEPT") != -1:
# iptables status command output is lame # iptables status command output is lame
@ -165,7 +165,7 @@ if state or enable:
# =========================================== # ===========================================
# determine if we are going to change anything # determine if we are going to change anything
if not running and state == "started": if not running and state in ("started", "running"):
changed = True changed = True
elif running and state == "stopped": elif running and state == "stopped":
changed = True changed = True
@ -183,13 +183,13 @@ if state or enable:
elif state == 'restarted': elif state == 'restarted':
rc1, stdout1, stderr1 = _run("%s %s stop" % (SERVICE, name)) rc1, stdout1, stderr1 = _run("%s %s stop" % (SERVICE, name))
rc2, stdout2, stderr2 = _run("%s %s start" % (SERVICE, name)) rc2, stdout2, stderr2 = _run("%s %s start" % (SERVICE, name))
rc_state = rc and rc1 and rc2 rc_state = rc + rc1 + rc2
stdout = stdout1 + stdout2 stdout = stdout1 + stdout2
stderr = stderr1 + stderr2 stderr = stderr1 + stderr2
out += stdout out += stdout
err += stderr err += stderr
rc = rc and rc_state rc = rc + rc_state
if rc != 0: if rc != 0: