diff options
author | Brian Coca <bcoca@ansible.com> | 2015-10-23 18:44:01 -0400 |
---|---|---|
committer | Brian Coca <bcoca@ansible.com> | 2015-10-23 18:44:01 -0400 |
commit | dae3718e794951f6b3da031e7a26a29f5077a2dc (patch) | |
tree | 416eff05a0a428ac2d04577dfbe192290e3d8f2d | |
parent | 486d233cbe2097aaf46b8c00768582a79a8ef593 (diff) | |
parent | 6233e72001c4c8d785b7e82123ee6fb4c8c93a6e (diff) | |
download | ansible-modules-core-dae3718e794951f6b3da031e7a26a29f5077a2dc.tar.gz |
Merge pull request #2341 from reactormonk/devel
simpler way to check if systemd is the init system
-rw-r--r-- | system/service.py | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/system/service.py b/system/service.py index f9a8b1e2..d08b6cd6 100644 --- a/system/service.py +++ b/system/service.py @@ -403,22 +403,7 @@ class LinuxService(Service): self.svc_initscript = initscript def check_systemd(): - # verify systemd is installed (by finding systemctl) - if not location.get('systemctl', False): - return False - - # Check if init is the systemd command, using comm as cmdline could be symlink - try: - f = open('/proc/1/comm', 'r') - except IOError, err: - # If comm doesn't exist, old kernel, no systemd - return False - - for line in f: - if 'systemd' in line: - return True - - return False + return os.path.exists("/run/systemd/system/") or os.path.exists("/dev/.run/systemd/") or os.path.exists("/dev/.systemd/") # Locate a tool to enable/disable a service if location.get('systemctl',False) and check_systemd(): |