mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-03 07:41:30 -07:00
tweak service module pattern= logic so ./hacking/test-module does not give false positives
This commit is contained in:
parent
bc571ccb55
commit
8eda23f856
1 changed files with 9 additions and 4 deletions
|
@ -68,21 +68,26 @@ def _get_service_status(name, pattern):
|
||||||
# If pattern is provided, search for that
|
# If pattern is provided, search for that
|
||||||
# before checking initctl, service output, and other tricks
|
# before checking initctl, service output, and other tricks
|
||||||
if pattern is not None:
|
if pattern is not None:
|
||||||
|
|
||||||
psbin = '/bin/ps'
|
psbin = '/bin/ps'
|
||||||
if not os.path.exists(psbin):
|
if not os.path.exists(psbin):
|
||||||
if os.path.exists('/usr/bin/ps'):
|
if os.path.exists('/usr/bin/ps'):
|
||||||
psbin = '/usr/bin/ps'
|
psbin = '/usr/bin/ps'
|
||||||
else:
|
else:
|
||||||
psbin = None
|
psbin = None
|
||||||
|
|
||||||
if psbin is not None:
|
if psbin is not None:
|
||||||
(rc, psout, pserr) = _run('%s %s' % (psbin, PS_OPTIONS))
|
(rc, psout, pserr) = _run('%s %s' % (psbin, PS_OPTIONS))
|
||||||
# If rc is 0, set running as appropriate
|
# If rc is 0, set running as appropriate
|
||||||
# If ps command fails, fall back to other means.
|
# If ps command fails, fall back to other means.
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
if pattern in psout:
|
running = False
|
||||||
running = True
|
lines = psout.split("\n")
|
||||||
else:
|
for line in lines:
|
||||||
running = False
|
if pattern in line and not "pattern=" in line:
|
||||||
|
# so as to not confuse ./hacking/test-module
|
||||||
|
running = True
|
||||||
|
break
|
||||||
|
|
||||||
# Check if we got upstart on the system and then the job state
|
# Check if we got upstart on the system and then the job state
|
||||||
if INITCTL != None and running is None:
|
if INITCTL != None and running is None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue