1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Merge pull request #1757 from AlanCoding/1704_debian_scan_services

Allow sysv to pick up services in Debian distros
This commit is contained in:
Alan Rominger 2016-05-03 15:16:02 -04:00
commit 53618aa181

View File

@ -59,8 +59,8 @@ class ServiceScanService(BaseService):
initctl_path = self.module.get_bin_path("initctl") initctl_path = self.module.get_bin_path("initctl")
chkconfig_path = self.module.get_bin_path("chkconfig") chkconfig_path = self.module.get_bin_path("chkconfig")
# Upstart and sysvinit # sysvinit
if initctl_path is not None and chkconfig_path is None: if service_path is not None and chkconfig_path is None:
rc, stdout, stderr = self.module.run_command("%s --status-all 2>&1 | grep -E \"\\[ (\\+|\\-) \\]\"" % service_path, use_unsafe_shell=True) rc, stdout, stderr = self.module.run_command("%s --status-all 2>&1 | grep -E \"\\[ (\\+|\\-) \\]\"" % service_path, use_unsafe_shell=True)
for line in stdout.split("\n"): for line in stdout.split("\n"):
line_data = line.split() line_data = line.split()
@ -72,6 +72,9 @@ class ServiceScanService(BaseService):
else: else:
service_state = "stopped" service_state = "stopped"
services.append({"name": service_name, "state": service_state, "source": "sysv"}) services.append({"name": service_name, "state": service_state, "source": "sysv"})
# Upstart
if initctl_path is not None and chkconfig_path is None:
p = re.compile('^\s?(?P<name>.*)\s(?P<goal>\w+)\/(?P<state>\w+)(\,\sprocess\s(?P<pid>[0-9]+))?\s*$') p = re.compile('^\s?(?P<name>.*)\s(?P<goal>\w+)\/(?P<state>\w+)(\,\sprocess\s(?P<pid>[0-9]+))?\s*$')
rc, stdout, stderr = self.module.run_command("%s list" % initctl_path) rc, stdout, stderr = self.module.run_command("%s list" % initctl_path)
real_stdout = stdout.replace("\r","") real_stdout = stdout.replace("\r","")