apache-formula/apache/service/running.sls
noelmcloughlin 47818fc360 refactor(formula): align to template-formula & improve ci features
FEATURE: Archlinux support
FEATURE: Windows support
FEATURE: Enhanced CI/CD
FEATURE: modular states

BREAKING CHANGE: 'apache.sls' converted to new style 'init.ssl'
BREAKING CHANGE: "logrotate.sls" became "config/logrotate.sls"
BREAKING CHANGE: "debian_full.sls" became "config/debian_full.sls"
BREAKING CHANGE: "flags.sls" became "config/flags.sls"
BREAKING CHANGE: "manage_security" became "config/manage_security.sls"
BREAKING CHANGE: "mod_*.sls" became "config/mod_*.sls"
BREAKING CHANGE: "no_default_host.sls" became "config/no_default_host.sls"
BREAKING CHANGE: "own_default_host.sls" became "config/own_default_host.sls"
BREAKING CHANGE: "register_site.sls" became "config/register_site.sls"
BREAKING CHANGE: "server_status.sls" became "config/server_status.sls"
BREAKING CHANGE: "vhosts/" became "config/vhosts/"
BREAKING CHANGE: "mod_security/" became "config/mod_security/"

NOT-BREAKING CHANGE: 'config.sls' became 'config/init.sls'
NOT-BREAKING CHANGE: 'uninstall.sls' symlinked to 'clean.sls'
2020-10-05 14:24:15 +01:00

65 lines
2.0 KiB
Plaintext

# -*- coding: utf-8 -*-
# vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_config_file = tplroot ~ '.config.file' %}
{%- set sls_config_registersite = tplroot ~ '.config.register_site' %}
{%- from tplroot ~ "/map.jinja" import apache with context %}
include:
- {{ sls_config_file }}
- {{ sls_config_registersite }}
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
- watch:
- sls: {{ sls_config_file }}
- retry: {{ apache.retry_option|json }}
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 }}
- 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 %}
- watch:
- sls: {{ sls_config_file }}
- require:
- sls: {{ sls_config_file }}
- 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 %}
- watch:
- sls: {{ sls_config_file }}
- require:
- sls: {{ sls_config_file }}
- service: apache-service-running