From 9490c868e05dd47fa5c5649ea187064f7988f75b Mon Sep 17 00:00:00 2001
From: Niels Abspoel <aboe@spectre.wraith.lan>
Date: Fri, 9 Nov 2018 00:25:52 +0100
Subject: [PATCH] use watch module: apache-[restart|reload] consequently

---
 apache/certificates.sls      | 12 ++++++++++++
 apache/config.sls            | 36 ++++++++++++++++++++++++++++++++++++
 apache/debian_full.sls       |  4 ++++
 apache/defaults.yaml         |  2 ++
 apache/flags.sls             |  8 ++++++++
 apache/init.sls              | 21 +++++++++++++++------
 apache/manage_security.sls   |  4 ++++
 apache/mod_actions.sls       |  4 ++++
 apache/mod_cgi.sls           |  4 ++++
 apache/mod_dav_svn.sls       |  8 ++++++++
 apache/mod_fastcgi.sls       | 10 ++++++++++
 apache/mod_fcgid.sls         |  4 ++++
 apache/mod_geoip.sls         |  6 +++++-
 apache/mod_headers.sls       |  4 ++++
 apache/mod_mpm.sls           | 16 ++++++++++++++++
 apache/mod_pagespeed.sls     |  4 ++++
 apache/mod_perl2.sls         | 14 ++++++++++++++
 apache/mod_php5.sls          | 12 ++++++++++++
 apache/mod_proxy.sls         |  8 ++++++++
 apache/mod_proxy_fcgi.sls    |  4 ++++
 apache/mod_proxy_http.sls    |  8 ++++++++
 apache/mod_remoteip.sls      | 16 ++++++++++++++++
 apache/mod_rewrite.sls       |  8 ++++++++
 apache/mod_security/init.sls | 20 ++++++++++++++++++++
 apache/mod_socache_shmcb.sls |  4 ++++
 apache/mod_ssl.sls           | 24 ++++++++++++++++++++++++
 apache/mod_suexec.sls        |  4 ++++
 apache/mod_vhost_alias.sls   |  4 ++++
 apache/mod_wsgi.sls          | 12 ++++++++++++
 apache/mod_xsendfile.sls     | 10 ++++++++++
 apache/modules.sls           | 24 ++++++++++++++++++++++++
 apache/no_default_vhost.sls  |  4 ++++
 apache/own_default_vhost.sls |  4 ++++
 apache/register_site.sls     |  4 ++++
 apache/vhosts/cleanup.sls    |  4 ++++
 apache/vhosts/standard.sls   | 12 ++++++++++++
 36 files changed, 340 insertions(+), 7 deletions(-)

diff --git a/apache/certificates.sls b/apache/certificates.sls
index ce9ffa2..c0aaeea 100644
--- a/apache/certificates.sls
+++ b/apache/certificates.sls
@@ -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 %}
diff --git a/apache/config.sls b/apache/config.sls
index 45c40b9..9caeaae 100644
--- a/apache/config.sls
+++ b/apache/config.sls
@@ -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 }}
diff --git a/apache/debian_full.sls b/apache/debian_full.sls
index 44bba6b..2104fe1 100644
--- a/apache/debian_full.sls
+++ b/apache/debian_full.sls
@@ -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
 
diff --git a/apache/defaults.yaml b/apache/defaults.yaml
index 25ac23b..e0799e8 100644
--- a/apache/defaults.yaml
+++ b/apache/defaults.yaml
@@ -3,6 +3,8 @@
 
 apache:
   manage_service_states: True
+  service_state: running
+  service_enable: True
 
   mod_security:
     crs_install: False
diff --git a/apache/flags.sls b/apache/flags.sls
index f303b98..4d6f1e0 100644
--- a/apache/flags.sls
+++ b/apache/flags.sls
@@ -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 %}
diff --git a/apache/init.sls b/apache/init.sls
index 16deadd..bbe1d7d 100644
--- a/apache/init.sls
+++ b/apache/init.sls
@@ -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 %}
 
diff --git a/apache/manage_security.sls b/apache/manage_security.sls
index 32f44fd..f4b176c 100644
--- a/apache/manage_security.sls
+++ b/apache/manage_security.sls
@@ -12,6 +12,10 @@
       - pkg: apache
     - watch_in:
       - module: apache-restart
+    - require_in:
+      - module: apache-restart
+      - module: apache-reload
+      - service: apache
 {%- endmacro %}
 
 include:
diff --git a/apache/mod_actions.sls b/apache/mod_actions.sls
index e747963..2cf2703 100644
--- a/apache/mod_actions.sls
+++ b/apache/mod_actions.sls
@@ -11,5 +11,9 @@ a2enmod actions:
       - pkg: apache
     - watch_in:
       - module: apache-restart
+    - require_in:
+      - module: apache-restart
+      - module: apache-reload
+      - service: apache
 
 {% endif %}
diff --git a/apache/mod_cgi.sls b/apache/mod_cgi.sls
index caa2ab0..223b093 100644
--- a/apache/mod_cgi.sls
+++ b/apache/mod_cgi.sls
@@ -14,5 +14,9 @@ include:
       - pkg: apache
     - watch_in:
       - module: apache-restart
+    - require_in:
+      - module: apache-restart
+      - module: apache-reload
+      - service: apache
 
 {% endif %}
diff --git a/apache/mod_dav_svn.sls b/apache/mod_dav_svn.sls
index cf29fee..e65a650 100644
--- a/apache/mod_dav_svn.sls
+++ b/apache/mod_dav_svn.sls
@@ -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 %}
diff --git a/apache/mod_fastcgi.sls b/apache/mod_fastcgi.sls
index d3c5117..196e3b0 100644
--- a/apache/mod_fastcgi.sls
+++ b/apache/mod_fastcgi.sls
@@ -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 %}
 
diff --git a/apache/mod_fcgid.sls b/apache/mod_fcgid.sls
index 66327df..485aa16 100644
--- a/apache/mod_fcgid.sls
+++ b/apache/mod_fcgid.sls
@@ -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 %}
diff --git a/apache/mod_geoip.sls b/apache/mod_geoip.sls
index a94b4b2..aaa5c73 100644
--- a/apache/mod_geoip.sls
+++ b/apache/mod_geoip.sls
@@ -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:
diff --git a/apache/mod_headers.sls b/apache/mod_headers.sls
index fa2be47..a13875e 100644
--- a/apache/mod_headers.sls
+++ b/apache/mod_headers.sls
@@ -11,5 +11,9 @@ a2enmod headers:
       - pkg: apache
     - watch_in:
       - module: apache-restart
+    - require_in:
+      - module: apache-restart
+      - module: apache-reload
+      - service: apache
 
 {% endif %}
diff --git a/apache/mod_mpm.sls b/apache/mod_mpm.sls
index f51c992..0c69e88 100644
--- a/apache/mod_mpm.sls
+++ b/apache/mod_mpm.sls
@@ -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 %}
diff --git a/apache/mod_pagespeed.sls b/apache/mod_pagespeed.sls
index c8b9a70..bc76f8e 100644
--- a/apache/mod_pagespeed.sls
+++ b/apache/mod_pagespeed.sls
@@ -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'] %}
diff --git a/apache/mod_perl2.sls b/apache/mod_perl2.sls
index 16b9e24..255d027 100644
--- a/apache/mod_perl2.sls
+++ b/apache/mod_perl2.sls
@@ -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 %}
diff --git a/apache/mod_php5.sls b/apache/mod_php5.sls
index 93e16a3..2162101 100644
--- a/apache/mod_php5.sls
+++ b/apache/mod_php5.sls
@@ -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 %}
 
diff --git a/apache/mod_proxy.sls b/apache/mod_proxy.sls
index ee6ad80..14c3088 100644
--- a/apache/mod_proxy.sls
+++ b/apache/mod_proxy.sls
@@ -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 %}
diff --git a/apache/mod_proxy_fcgi.sls b/apache/mod_proxy_fcgi.sls
index d95d1ed..c36eec3 100644
--- a/apache/mod_proxy_fcgi.sls
+++ b/apache/mod_proxy_fcgi.sls
@@ -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 %}
diff --git a/apache/mod_proxy_http.sls b/apache/mod_proxy_http.sls
index 78e4d09..f251a73 100644
--- a/apache/mod_proxy_http.sls
+++ b/apache/mod_proxy_http.sls
@@ -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 %}
diff --git a/apache/mod_remoteip.sls b/apache/mod_remoteip.sls
index 718a01d..b2d399d 100644
--- a/apache/mod_remoteip.sls
+++ b/apache/mod_remoteip.sls
@@ -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 %}
diff --git a/apache/mod_rewrite.sls b/apache/mod_rewrite.sls
index 03bc2ba..39cb60c 100644
--- a/apache/mod_rewrite.sls
+++ b/apache/mod_rewrite.sls
@@ -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 %}
diff --git a/apache/mod_security/init.sls b/apache/mod_security/init.sls
index 9c5f353..7eecad5 100644
--- a/apache/mod_security/init.sls
+++ b/apache/mod_security/init.sls
@@ -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 %}
diff --git a/apache/mod_socache_shmcb.sls b/apache/mod_socache_shmcb.sls
index af8cb3e..95fb710 100644
--- a/apache/mod_socache_shmcb.sls
+++ b/apache/mod_socache_shmcb.sls
@@ -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
 
diff --git a/apache/mod_ssl.sls b/apache/mod_ssl.sls
index affd084..f420ecb 100644
--- a/apache/mod_ssl.sls
+++ b/apache/mod_ssl.sls
@@ -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 %}
diff --git a/apache/mod_suexec.sls b/apache/mod_suexec.sls
index 522b873..b4742d7 100644
--- a/apache/mod_suexec.sls
+++ b/apache/mod_suexec.sls
@@ -14,5 +14,9 @@ include:
       - pkg: apache
     - watch_in:
       - module: apache-restart
+    - require_in:
+      - module: apache-restart
+      - module: apache-reload
+      - service: apache
 
 {% endif %}
diff --git a/apache/mod_vhost_alias.sls b/apache/mod_vhost_alias.sls
index 21ac644..c85a391 100644
--- a/apache/mod_vhost_alias.sls
+++ b/apache/mod_vhost_alias.sls
@@ -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 %}
diff --git a/apache/mod_wsgi.sls b/apache/mod_wsgi.sls
index fd00ac6..ca2ddaf 100644
--- a/apache/mod_wsgi.sls
+++ b/apache/mod_wsgi.sls
@@ -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 %}
diff --git a/apache/mod_xsendfile.sls b/apache/mod_xsendfile.sls
index e86f075..b03cadf 100644
--- a/apache/mod_xsendfile.sls
+++ b/apache/mod_xsendfile.sls
@@ -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 %}
 
diff --git a/apache/modules.sls b/apache/modules.sls
index adf88c0..1594724 100644
--- a/apache/modules.sls
+++ b/apache/modules.sls
@@ -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 %}
diff --git a/apache/no_default_vhost.sls b/apache/no_default_vhost.sls
index f316b9e..cab12df 100644
--- a/apache/no_default_vhost.sls
+++ b/apache/no_default_vhost.sls
@@ -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 %}
diff --git a/apache/own_default_vhost.sls b/apache/own_default_vhost.sls
index a04a8b0..37ee1b3 100644
--- a/apache/own_default_vhost.sls
+++ b/apache/own_default_vhost.sls
@@ -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 %}
diff --git a/apache/register_site.sls b/apache/register_site.sls
index 5a55a7a..5bb93e7 100644
--- a/apache/register_site.sls
+++ b/apache/register_site.sls
@@ -49,6 +49,10 @@
     - watch_in:
       - cmd: {{ a2modid }}
       - module: apache-reload
+    - require_in:
+      - module: apache-restart
+      - module; apache-reload
+      - service: apache
 
 {% endif %}
 ##########################################
diff --git a/apache/vhosts/cleanup.sls b/apache/vhosts/cleanup.sls
index 83b7fa8..e6b3dec 100644
--- a/apache/vhosts/cleanup.sls
+++ b/apache/vhosts/cleanup.sls
@@ -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 %}
diff --git a/apache/vhosts/standard.sls b/apache/vhosts/standard.sls
index 6ce2484..5ad967b 100644
--- a/apache/vhosts/standard.sls
+++ b/apache/vhosts/standard.sls
@@ -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 %}
 
-- 
GitLab