Skip to content
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

fix(systemd): fix service detection #94

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mongodb/service/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ include:
service.dead:
- name: {{ servicename }}
{% if grains.kernel|lower == 'linux' %}
- onlyif: systemctl list-units |grep {{ servicename }} >/dev/null 2>&1
- onlyif: systemctl list-unit-files |grep {{ servicename }} >/dev/null 2>&1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need those onlyif in service.* states?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... ensure it is dead only if the service exists?

Just fixing it, have not checked further if it would work without it at all.

{%- endif %} {# linux #}
- enable: False
{%- endif %}
Expand Down
19 changes: 14 additions & 5 deletions mongodb/service/running.sls
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ include:
- reload_modules: true
service.running:
- name: firewalld
- onlyif: systemctl list-units | grep firewalld >/dev/null 2>&1
- onlyif: systemctl list-unit-files | grep firewalld >/dev/null 2>&1
- enable: True
{%- endif %}
{%- endif %}
Expand Down Expand Up @@ -236,7 +236,7 @@ include:
- name: {{ servicename }}
- onlyif:
- {{ grains.kernel|lower == 'linux' }}
- systemctl list-units | grep {{ servicename }} >/dev/null 2>&1
- systemctl list-unit-files | grep {{ servicename }} >/dev/null 2>&1
- require:
- sls: {{ sls_software_install }}
- sls: {{ sls_config_users }}
Expand All @@ -252,14 +252,23 @@ include:
{%- else %}
service.running:
- name: {{ servicename }}
- enable: True
- onlyif: systemctl list-units | grep {{ servicename }} >/dev/null 2>&1
- onlyif: systemctl list-unit-files | grep {{ servicename }} >/dev/null 2>&1
- require:
- sls: {{ sls_software_install }}
- sls: {{ sls_config_users }}
{%- if 'config' in software and software['config'] is mapping %}
- watch:
- file: {{ formula }}-config-file-{{ servicename }}-file-managed
{%- endif %}
{{ formula }}-service-running-{{ comp }}-{{ servicename }}-enabled:
service.enabled:
- name: {{ servicename }}
- onlyif: systemctl list-unit-files | grep {{ servicename }} >/dev/null 2>&1
{%- endif %}
- require:
- sls: {{ sls_software_install }}
- sls: {{ sls_config_users }}
{%- if 'config' in software and software['config'] is mapping %}
- watch:
- file: {{ formula }}-config-file-{{ servicename }}-file-managed
{%- endif %}

Expand Down