From 29a62038b7a6c4ecf59aa35de8106d84b8e99e2a Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 31 Jul 2018 17:56:11 +0200 Subject: [PATCH] module_utils_service: Fix glob path of rc.d (#43018) Some distribtuions like SUSE has the rc%.d directories under /etc/init.d Quote of /etc/rc.d.README on SLES11. "Some people expect the system startup scripts in /etc/rc.d/. We use a slightly different structure for better LSB compliance." --- changelogs/fragments/service.yml | 4 ++++ lib/ansible/module_utils/service.py | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 changelogs/fragments/service.yml diff --git a/changelogs/fragments/service.yml b/changelogs/fragments/service.yml new file mode 100644 index 0000000000..4dbe8375a2 --- /dev/null +++ b/changelogs/fragments/service.yml @@ -0,0 +1,4 @@ +--- +bugfixes: +- Fix glob path of rc.d + Some distribtuions like SUSE has the rc%.d directories under /etc/init.d diff --git a/lib/ansible/module_utils/service.py b/lib/ansible/module_utils/service.py index dc345f5916..a296afb2c9 100644 --- a/lib/ansible/module_utils/service.py +++ b/lib/ansible/module_utils/service.py @@ -48,8 +48,12 @@ def sysv_is_enabled(name, runlevel=None): :kw runlevel: runlevel to check (default: None) ''' if runlevel: + if not os.path.isdir('/etc/rc0.d/'): + return bool(glob.glob('/etc/init.d/rc%s.d/S??%s' % (runlevel, name))) return bool(glob.glob('/etc/rc%s.d/S??%s' % (runlevel, name))) else: + if not os.path.isdir('/etc/rc0.d/'): + return bool(glob.glob('/etc/init.d/rc?.d/S??%s' % name)) return bool(glob.glob('/etc/rc?.d/S??%s' % name))