mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02: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
|
||||
# before checking initctl, service output, and other tricks
|
||||
if pattern is not None:
|
||||
|
||||
psbin = '/bin/ps'
|
||||
if not os.path.exists(psbin):
|
||||
if os.path.exists('/usr/bin/ps'):
|
||||
psbin = '/usr/bin/ps'
|
||||
else:
|
||||
psbin = None
|
||||
|
||||
if psbin is not None:
|
||||
(rc, psout, pserr) = _run('%s %s' % (psbin, PS_OPTIONS))
|
||||
# If rc is 0, set running as appropriate
|
||||
# If ps command fails, fall back to other means.
|
||||
if rc == 0:
|
||||
if pattern in psout:
|
||||
running = True
|
||||
else:
|
||||
running = False
|
||||
running = False
|
||||
lines = psout.split("\n")
|
||||
for line in lines:
|
||||
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
|
||||
if INITCTL != None and running is None:
|
||||
|
|
Loading…
Add table
Reference in a new issue