From 14720b54acbc2468b2277146ab8b94ff8b7d9413 Mon Sep 17 00:00:00 2001 From: David Fritzsche Date: Fri, 31 Oct 2014 11:41:51 +0100 Subject: [PATCH] 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. --- lib/ansible/modules/system/service.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ansible/modules/system/service.py b/lib/ansible/modules/system/service.py index 9d92147234..a9aca1b939 100644 --- a/lib/ansible/modules/system/service.py +++ b/lib/ansible/modules/system/service.py @@ -928,10 +928,13 @@ class FreeBsdService(Service): def get_service_status(self): rc, stdout, stderr = self.execute_command("%s %s %s %s" % (self.svc_cmd, self.name, 'onestatus', self.arguments)) - if rc == 1: - self.running = False - elif rc == 0: - self.running = True + if self.name == "pf": + self.running = "Enabled" in stdout + else: + if rc == 1: + self.running = False + elif rc == 0: + self.running = True def service_enable(self): if self.enable: