Simplify service management
In our environment a simple state ensuring the service is running and having it reload on configuration changes should be more than sufficient. Additionally, remove restart retries and useless log/config dumping on failures. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
b22a6cf1bb
commit
e1685ffbeb
@ -30,10 +30,6 @@ apache-config-vhosts-standard-{{ id }}:
|
||||
- require:
|
||||
- pkg: apache-package-install-pkg-installed
|
||||
- watch_in:
|
||||
- module: apache-service-running-reload
|
||||
- require_in:
|
||||
- module: apache-service-running-restart
|
||||
- module: apache-service-running-reload
|
||||
- service: apache-service-running
|
||||
|
||||
{%- if site.get('DocumentRoot') != False %}
|
||||
@ -57,10 +53,6 @@ apache-config-vhosts-standard-{{ id }}-cmd-run-a2en:
|
||||
- require:
|
||||
- file: apache-config-vhosts-standard-{{ id }}
|
||||
- watch_in:
|
||||
- module: apache-service-running-reload
|
||||
- require_in:
|
||||
- module: apache-service-running-restart
|
||||
- module: apache-service-running-reload
|
||||
- service: apache-service-running
|
||||
|
||||
{%- else %}
|
||||
@ -72,10 +64,6 @@ apache-config-vhosts-standard-{{ id }}-cmd-run-a2dis:
|
||||
- require:
|
||||
- file: apache-config-vhosts-standard-{{ id }}
|
||||
- watch_in:
|
||||
- module: apache-service-running-reload
|
||||
- require_in:
|
||||
- module: apache-service-running-restart
|
||||
- module: apache-service-running-reload
|
||||
- service: apache-service-running
|
||||
|
||||
{%- endif %}
|
||||
|
@ -5,46 +5,12 @@
|
||||
{%- from tplroot ~ "/map.jinja" import apache with context %}
|
||||
|
||||
apache-service-running:
|
||||
{%- if salt['pillar.get']('apache:manage_service_states', True) %}
|
||||
{# By default run apache service states (unless pillar is false) #}
|
||||
service.running:
|
||||
- name: {{ apache.service.name }}
|
||||
- enable: True
|
||||
- retry: {{ apache.retry_option|json }}
|
||||
- reload: True
|
||||
cmd.run:
|
||||
- names:
|
||||
- journalctl -xe -u {{ apache.service.name }} || tail -20 /var/log/messages || true
|
||||
- (service {{ apache.service.name }} restart && service {{ apache.service.name }} status) || true
|
||||
- cat {{ apache.config }}
|
||||
- journalctl -xe -u {{ apache.service.name }} || true
|
||||
- onfail:
|
||||
- service: apache-service-running
|
||||
{%- endif %}
|
||||
|
||||
{# The following states are by default inert and can be used #}
|
||||
{# by other states to trigger a restart or reload as needed. #}
|
||||
|
||||
apache-service-running-restart:
|
||||
module.wait:
|
||||
{%- if apache.service_state in ['running'] %}
|
||||
- name: service.restart
|
||||
- m_name: {{ apache.service.name }}
|
||||
{%- else %}
|
||||
- name: cmd.run
|
||||
- cmd: {{ apache.custom_reload_command|default('apachectl graceful') }}
|
||||
- python_shell: True
|
||||
{%- endif %}
|
||||
- require:
|
||||
- service: apache-service-running
|
||||
|
||||
apache-service-running-reload:
|
||||
module.wait:
|
||||
{%- if apache.service_state in ['running'] %}
|
||||
- name: service.reload
|
||||
- m_name: {{ apache.service.name }}
|
||||
{%- else %}
|
||||
- name: cmd.run
|
||||
- cmd: {{ apache.custom_reload_command|default('apachectl graceful') }}
|
||||
- python_shell: True
|
||||
{%- endif %}
|
||||
- require:
|
||||
- service: apache-service-running
|
||||
|
Loading…
Reference in New Issue
Block a user