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

Add working status detection for pf on FreeBSD

The return code of "service pf onestatus" is usually zero on FreeBSD (tested with FreeBSD 10.0), even if pf is not running. So the service module always thinks that pf is running, even when it needs to be started.
This commit is contained in:
David Fritzsche 2014-10-31 11:41:51 +01:00 committed by Matt Clay
parent e9a0fad36b
commit 14720b54ac

View file

@ -928,10 +928,13 @@ class FreeBsdService(Service):
def get_service_status(self): def get_service_status(self):
rc, stdout, stderr = self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, 'onestatus', self.arguments)) rc, stdout, stderr = self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, 'onestatus', self.arguments))
if rc == 1: if self.name == "pf":
self.running = False self.running = "Enabled" in stdout
elif rc == 0: else:
self.running = True if rc == 1:
self.running = False
elif rc == 0:
self.running = True
def service_enable(self): def service_enable(self):
if self.enable: if self.enable: