mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
d9bfda2dcd
use-forking-daemon.patch -> #14337 the other patchesr are for #13788 With thanks to Tim Serong who created the patches.
75 lines
2.2 KiB
Diff
75 lines
2.2 KiB
Diff
From 9617d339273ceecd3b47cbcd8c331080faac48f8 Mon Sep 17 00:00:00 2001
|
|
From: Massimiliano Torromeo <massimilianotorromeo@artera.it>
|
|
Date: Mon, 14 Apr 2014 18:01:18 +0200
|
|
Subject: [PATCH] Allow systemd parametrized services to be enabled by the
|
|
service state.
|
|
|
|
This makes the systemd.get_all function return the combined output of
|
|
list-units and list-unit-files and the systemd.available function will
|
|
also check for the base unit name stripped of the user parameter
|
|
(e.g. dhcpcd@eth0 will be considered available if dhcpcd@.service exists)
|
|
---
|
|
salt/modules/systemd.py | 18 +++++++++++++-----
|
|
1 file changed, 13 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/salt/modules/systemd.py b/salt/modules/systemd.py
|
|
index e2cfb1d..72079d7 100644
|
|
--- a/salt/modules/systemd.py
|
|
+++ b/salt/modules/systemd.py
|
|
@@ -82,7 +82,7 @@ def _get_all_units():
|
|
r')\s+loaded\s+(?P<active>[^\s]+)')
|
|
|
|
out = __salt__['cmd.run_stdout'](
|
|
- 'systemctl --full list-units | col -b'
|
|
+ 'systemctl --full --no-legend --no-pager list-units | col -b'
|
|
)
|
|
|
|
ret = {}
|
|
@@ -104,7 +104,7 @@ def _get_all_unit_files():
|
|
r')\s+(?P<state>.+)$')
|
|
|
|
out = __salt__['cmd.run_stdout'](
|
|
- 'systemctl --full list-unit-files | col -b'
|
|
+ 'systemctl --full --no-legend --no-pager list-unit-files | col -b'
|
|
)
|
|
|
|
ret = {}
|
|
@@ -195,7 +195,7 @@ def get_all():
|
|
|
|
salt '*' service.get_all
|
|
'''
|
|
- return sorted(_get_all_units().keys())
|
|
+ return sorted(set(_get_all_units().keys() + _get_all_unit_files().keys()))
|
|
|
|
|
|
def available(name):
|
|
@@ -209,7 +209,15 @@ def available(name):
|
|
|
|
salt '*' service.available sshd
|
|
'''
|
|
- return _canonical_template_unit_name(name) in get_all()
|
|
+ name = _canonical_template_unit_name(name)
|
|
+ units = get_all()
|
|
+ if name in units:
|
|
+ return True
|
|
+ elif '@' in name:
|
|
+ templatename = name[:name.find('@') + 1]
|
|
+ return templatename in units
|
|
+ else:
|
|
+ return False
|
|
|
|
|
|
def missing(name):
|
|
@@ -224,7 +232,7 @@ def missing(name):
|
|
|
|
salt '*' service.missing sshd
|
|
'''
|
|
- return not _canonical_template_unit_name(name) in get_all()
|
|
+ return not available(name)
|
|
|
|
|
|
def start(name):
|
|
--
|
|
1.9.3
|
|
|