New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upstart module only finds legacy services #1915
Comments
I think the regression might be there now because of 3c48f22 which introduced a check to see if a service is there. |
Thanks for the find. |
The simple fix is to extend the glob to find files in |
Proposed fix: diff --git a/salt/modules/upstart.py b/salt/modules/upstart.py
index 8005a7a..82f4708 100644
--- a/salt/modules/upstart.py
+++ b/salt/modules/upstart.py
@@ -122,6 +122,19 @@ def _sysv_is_enabled(name):
return not _sysv_is_disabled(name)
+def _iter_service_names():
+ found = set()
+ for line in glob.glob('/etc/init.d/*'):
+ name = os.path.basename(line)
+ found.add(name)
+ yield name
+ for line in glob.glob('/etc/init/*.conf'):
+ name = os.path.basename(line)[:-5]
+ if name in found:
+ continue
+ yield name
+
+
def get_enabled():
'''
Return the enabled services
@@ -131,8 +144,7 @@ def get_enabled():
salt '*' service.get_enabled
'''
ret = set()
- for line in glob.glob('/etc/init.d/*'):
- name = os.path.basename(line)
+ for name in _iter_service_names():
if _service_is_upstart(name):
if _upstart_is_enabled(name):
ret.add(name)
@@ -152,8 +164,7 @@ def get_disabled():
salt '*' service.get_disabled
'''
ret = set()
- for line in glob.glob('/etc/init.d/*'):
- name = os.path.basename(line)
+ for name in _iter_service_names():
if _service_is_upstart(name):
if _upstart_is_disabled(name):
ret.add(name) |
I think the whole idea of detecting sysvinit and upstart is not correct. There are valid cases for init scripts being symlinks. Instead I would do this on top of the above patch: diff --git a/salt/modules/upstart.py b/salt/modules/upstart.py
index 82f4708..f1837ce 100644
--- a/salt/modules/upstart.py
+++ b/salt/modules/upstart.py
@@ -100,9 +100,7 @@ def _service_is_sysv(name):
executable, like README or skeleton.
'''
script = '/etc/init.d/{0}'.format(name)
- if not _is_symlink(script):
- return os.access(script, os.X_OK)
- return False
+ return not _service_is_upstart(name) and os.access(script, os.X_OK) |
Thanks! I will get this in! |
I just noticed the patch was wrongly indented. The second for loop has to be on the same level as the first. |
Thanks, I should have caught that, fixed |
The upstart module only looks for files in /etc/init.d which however are only dummy files. If you install a service to /etc/init only salt thinks the service does not exist and will fail. I only noticed this with the current master because salt is now unable to bring any of my services online with the running state.
The text was updated successfully, but these errors were encountered: