use watch module: apache-[restart|reload] consequently

This commit is contained in:
Niels Abspoel 2018-11-09 00:25:52 +01:00
parent 17d3d84595
commit 9490c868e0
36 changed files with 340 additions and 7 deletions

View File

@ -17,6 +17,10 @@ apache_cert_config_{{ site }}_key_file:
- group: root
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}
{% if confcert.SSLCertificateFile is defined and confcert.SSLCertificateFile_content is defined %}
@ -31,6 +35,10 @@ apache_cert_config_{{ site }}_cert_file:
- group: root
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}
{% if confcert.SSLCertificateChainFile is defined and confcert.SSLCertificateChainFile_content is defined %}
@ -45,6 +53,10 @@ apache_cert_config_{{ site }}_bundle_file:
- group: root
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}
{%- endfor %}

View File

@ -9,6 +9,10 @@ include:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{{ apache.configfile }}:
@ -19,6 +23,10 @@ include:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
- context:
apache: {{ apache }}
@ -29,6 +37,10 @@ include:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% if grains['os_family']=="Debian" %}
@ -40,6 +52,10 @@ include:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{{ apache.portsfile }}:
@ -50,6 +66,10 @@ include:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
- context:
apache: {{ apache }}
@ -62,6 +82,10 @@ include:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}
@ -74,6 +98,10 @@ include:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
- context:
apache: {{ apache }}
@ -88,6 +116,10 @@ include:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{{ apache.portsfile }}:
@ -98,6 +130,10 @@ include:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
- context:
apache: {{ apache }}

View File

@ -24,6 +24,10 @@ a2dissite 000-default{{ apache.confext }}:
- onlyif: test -f /etc/apache2/sites-enabled/000-default{{ apache.confext }}
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
- require:
- pkg: apache

View File

@ -3,6 +3,8 @@
apache:
manage_service_states: True
service_state: running
service_enable: True
mod_security:
crs_install: False

View File

@ -13,6 +13,10 @@ a2enflag {{ flag }}:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endfor %}
{% for module in salt['pillar.get']('apache:flags:disabled', []) %}
@ -23,6 +27,10 @@ a2disflag -f {{ flag }}:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endfor %}
{% endif %}

View File

@ -12,26 +12,35 @@ apache:
- system: True
{# By default run apache service states (unless pillar is false) #}
{% if salt['pillar.get']('apache:manage_service_states', True) %}
service.running:
service.{{apache.service_state}}:
- name: {{ apache.service }}
{% if apache.service_state in [ 'running', 'dead' ] %}
- enable: True
- require:
- module: apache-restart
- module: apache-reload
{% endif %}
# The following states are inert by default and can be used by other states to
# trigger a restart or reload as needed.
apache-reload:
module.wait:
{% if apache.service_state in ['running'] %}
- name: service.reload
- m_name: {{ apache.service }}
- require:
- module: apache-restart
{% else %}
- name: cmd.run
- cmd: {{apache.custom_reload_command|default('apachectl graceful')}}
- python_shell: True
{% endif %}
apache-restart:
module.wait:
{% if apache.service_state in ['running'] %}
- name: service.restart
- m_name: {{ apache.service }}
{% else %}
- name: cmd.run
- cmd: {{apache.custom_reload_command|default('apachectl graceful')}}
- python_shell: True
{% endif %}
{% else %}

View File

@ -12,6 +12,10 @@
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{%- endmacro %}
include:

View File

@ -11,5 +11,9 @@ a2enmod actions:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -14,5 +14,9 @@ include:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -16,6 +16,10 @@ a2enmod dav_svn:
- pkg: libapache2-mod-svn
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
a2enmod authz_svn:
cmd.run:
@ -26,5 +30,9 @@ a2enmod authz_svn:
- pkg: libapache2-mod-svn
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -12,6 +12,12 @@ mod-fastcgi:
- require:
- pkgrepo: repo-fastcgi
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
repo-fastcgi:
pkgrepo.managed:
@ -28,6 +34,10 @@ a2enmod fastcgi:
- pkg: mod-fastcgi
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -20,5 +20,9 @@ a2enmod fcgid for apache.mod_fcgid:
- pkg: mod-fcgid
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -12,9 +12,13 @@ mod-geoip:
- {{ apache.mod_geoip_database }}
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% if grains['os_family']=="RedHat" %}
geoip conf:

View File

@ -11,5 +11,9 @@ a2enmod headers:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -13,6 +13,10 @@ a2enmod {{ mpm_module }}:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
file.managed:
- name: /etc/apache2/mods-available/{{ mpm_module }}.conf
- template: jinja
@ -22,6 +26,10 @@ a2enmod {{ mpm_module }}:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
# Deactivate the other mpm modules as a previous step
{% for mod in ['mpm_prefork', 'mpm_worker', 'mpm_event'] if not mod == mpm_module %}
@ -34,6 +42,10 @@ a2dismod {{ mod }}:
- cmd: a2enmod {{ mpm_module }}
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endfor %}
{% endif %}
@ -53,5 +65,9 @@ include:
- pkg: httpd
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -17,6 +17,10 @@ a2enmod pagespeed:
- require:
- pkg: libapache2-mod-pagespeed
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% for dir in ['/var/cache/mod_pagespeed', '/var/log/pagespeed'] %}

View File

@ -9,6 +9,12 @@ mod-perl2:
- order: 180
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% if grains['os_family']=="Debian" %}
a2enmod perl2:
@ -19,6 +25,10 @@ a2enmod perl2:
- pkg: mod-perl2
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% elif grains['os_family']=="FreeBSD" %}
@ -31,5 +41,9 @@ a2enmod perl2:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -19,6 +19,10 @@ a2enmod php5:
- pkg: mod-php5
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% if 'apache' in pillar and 'php-ini' in pillar['apache'] %}
/etc/php5/apache2/php.ini:
@ -27,6 +31,10 @@ a2enmod php5:
- order: 225
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
- require:
- pkg: apache
- pkg: mod-php5
@ -43,6 +51,10 @@ a2enmod php5:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -13,6 +13,10 @@ a2enmod mod_proxy:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% elif grains['os_family']=="FreeBSD" %}
{{ apache.modulesdir }}/040_mod_proxy.conf:
@ -24,5 +28,9 @@ a2enmod mod_proxy:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -13,5 +13,9 @@ a2enmod proxy_fcgi:
- cmd: a2enmod proxy
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -15,6 +15,10 @@ a2enmod proxy_http:
- cmd: a2enmod proxy
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% elif grains['os_family']=="FreeBSD" %}
{{ apache.modulesdir }}/040_mod_proxy_http.conf:
@ -26,5 +30,9 @@ a2enmod proxy_http:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -11,6 +11,10 @@ a2enmod remoteip:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
a2enconf remoteip:
cmd.run:
@ -20,6 +24,10 @@ a2enconf remoteip:
- pkg: apache
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
/etc/apache2/conf-available/remoteip.conf:
file.managed:
@ -29,6 +37,10 @@ a2enconf remoteip:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}
@ -46,6 +58,10 @@ include:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -12,6 +12,10 @@ a2enmod rewrite:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% elif grains['os_family']=="FreeBSD" %}
@ -24,5 +28,9 @@ a2enmod rewrite:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -9,6 +9,12 @@ mod-security:
- order: 180
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% if apache.mod_security.crs_install %}
mod-security-crs:
@ -17,6 +23,12 @@ mod-security-crs:
- order: 180
- require:
- pkg: mod-security
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}
{% if apache.mod_security.manage_config %}
@ -32,6 +44,10 @@ mod-security-main-config:
- pkg: mod-security
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}
{% if grains['os_family']=="Debian" %}
@ -43,4 +59,8 @@ a2enmod security2:
- pkg: mod-security
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -14,6 +14,10 @@ include:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
- context:
module_name: socache_shmcb

View File

@ -14,6 +14,10 @@ a2enmod mod_ssl:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
/etc/apache2/mods-available/ssl.conf:
file.managed:
@ -32,12 +36,20 @@ mod_ssl:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{{ apache.confdir }}/ssl.conf:
file.absent:
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% elif grains['os_family']=="FreeBSD" %}
@ -55,6 +67,10 @@ include:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}
@ -71,6 +87,10 @@ include:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% if grains['os_family']=="Debian" %}
a2endisconf tls-defaults:
@ -88,4 +108,8 @@ a2endisconf tls-defaults:
- file: {{ apache.confdir }}/tls-defaults.conf
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -14,5 +14,9 @@ include:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -11,5 +11,9 @@ a2enmod vhost_alias:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -8,6 +8,12 @@ mod_wsgi:
- name: {{ apache.mod_wsgi }}
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% if 'conf_mod_wsgi' in apache %}
{{ apache.conf_mod_wsgi }}:
@ -16,4 +22,10 @@ mod_wsgi:
- onlyif: test -f {{ apache.conf_mod_wsgi }}
- require:
- pkg: mod_wsgi
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -9,6 +9,12 @@ mod-xsendfile:
- order: 180
- require:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% if grains['os_family']=="Debian" %}
a2enmod xsendfile:
@ -19,6 +25,10 @@ a2enmod xsendfile:
- pkg: mod-xsendfile
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -12,6 +12,10 @@ a2enmod {{ module }}:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endfor %}
{% for module in salt['pillar.get']('apache:modules:disabled', []) %}
@ -23,6 +27,10 @@ a2dismod -f {{ module }}:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endfor %}
{% elif grains['os_family']=="RedHat" %}
@ -39,6 +47,10 @@ find /etc/httpd/ -name '*.conf' -type f -exec sed -i -e 's/\(^#\)\(\s*LoadModule
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endfor %}
{% for module in salt['pillar.get']('apache:modules:disabled', []) %}
@ -50,6 +62,10 @@ find /etc/httpd/ -name '*.conf' -type f -exec sed -i -e 's/\(^\s*LoadModule.{{ m
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endfor %}
{% elif salt['grains.get']('os_family') == 'Suse' or salt['grains.get']('os') == 'SUSE' %}
@ -66,6 +82,10 @@ a2enmod {{ module }}:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endfor %}
{% for module in salt['pillar.get']('apache:modules:disabled', []) %}
@ -77,6 +97,10 @@ a2dismod -f {{ module }}:
- pkg: apache
- watch_in:
- module: apache-restart
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endfor %}
{% endif %}

View File

@ -12,5 +12,9 @@ a2dissite 000-default.conf:
- pkg: apache
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -13,5 +13,9 @@ apache_own-default-vhost:
- pkg: apache
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}

View File

@ -49,6 +49,10 @@
- watch_in:
- cmd: {{ a2modid }}
- module: apache-reload
- require_in:
- module: apache-restart
- module; apache-reload
- service: apache
{% endif %}
##########################################

View File

@ -29,6 +29,10 @@ a2dissite {{ filename }}:
- onlyif: "test -L {{ dirpath}}/{{ filename }} || test -f {{ dirpath}}/{{ filename }}"
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}
{% endfor %}

View File

@ -19,6 +19,10 @@ apache_vhosts_{{ id }}:
- pkg: apache
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% if site.get('DocumentRoot') != False %}
{{ id }}-documentroot:
@ -39,6 +43,10 @@ a2ensite {{ id }}{{ apache.confext }}:
- file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% else %}
a2dissite {{ id }}{{ apache.confext }}:
cmd.run:
@ -47,6 +55,10 @@ a2dissite {{ id }}{{ apache.confext }}:
- file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% endif %}
{% endif %}