Merge pull request #8 from Martin819/master

Optimize noservices condition + fix missing pillar param
diff --git a/.kitchen.yml b/.kitchen.yml
index ac0cdc6..748722d 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -37,8 +37,9 @@
 
 suites:
 
-  - name: apache_server
+  - name: <%=ENV['SUITE'] || 'apache_server_php7'%>
     provisioner:
       pillars-from-files:
-        apache.sls: tests/pillar/apache_server.sls
+        apache.sls: tests/pillar/<%=ENV['SUITE'] || 'apache_server_php7'%>.sls
+
 # vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/.travis.yml b/.travis.yml
index 4f34af2..4daa25c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,8 +17,8 @@
   - bundle install
 
 env:
-    - PLATFORM=trevorj/salty-whales:trusty
-    - PLATFORM=trevorj/salty-whales:xenial
+    - PLATFORM=trevorj/salty-whales:trusty SUITE=apache_server_php5
+    - PLATFORM=trevorj/salty-whales:xenial SUITE=apache_server_php7
 
 
 before_script:
diff --git a/apache/server/service/init.sls b/apache/server/service/init.sls
index 79aa704..6270612 100644
--- a/apache/server/service/init.sls
+++ b/apache/server/service/init.sls
@@ -21,10 +21,8 @@
   - template: jinja
   - require:
     - pkg: apache_packages
-  {% if not grains.get('noservices', False) %}
   - watch_in:
     - service: apache_service
-  {% endif %}
 
 apache_security_config:
   file.managed:
@@ -33,10 +31,8 @@
   - template: jinja
   - require:
     - pkg: apache_packages
-  {% if not grains.get('noservices', False) %}
   - watch_in:
     - service: apache_service
-  {% endif %}
 
 {%- if grains.os_family == "Debian" %}
 /etc/apache2/conf-enabled/security.conf:
@@ -44,10 +40,7 @@
   - target: {{ server.conf_dir }}/security.conf
   - require:
     - file: {{ server.conf_dir }}/security.conf
-  {% if not grains.get('noservices', False) %}
-  - watch_in:
     - service: apache_service
-  {% endif %}
 {%- endif %}
 
 {% if not grains.get('noservices', False) %}
@@ -57,24 +50,25 @@
       - service: apache_service
 {% endif %}
 
-
-{% if not grains.get('noservices', False) %}
-
 apache_service:
   service.running:
   - name: {{ server.service }}
   - reload: true
   - enable: true
+  {% if grains.noservices is defined %}
+  - onlyif: {% if grains.get('noservices', "True") %}"True"{% else %}False{% endif %}
+  {% endif %}
   - require:
     - pkg: apache_packages
 
-{% endif%}
-
 {%- else %}
 
 apache_service_dead:
   service.dead:
   - name: {{ server.service }}
+  {% if grains.noservices is defined %}
+  - onlyif: {% if grains.get('noservices', "True") %}"True"{% else %}False{% endif %}
+  {% endif %}
 
 apache_remove_packages:
   pkg.purged:
diff --git a/apache/server/service/modules.sls b/apache/server/service/modules.sls
index 49bcaa2..9214543 100644
--- a/apache/server/service/modules.sls
+++ b/apache/server/service/modules.sls
@@ -71,10 +71,8 @@
   - creates: /etc/apache2/mods-enabled/{{ module }}.load
   - require:
     - pkg: apache_packages
-  {% if not grains.get('noservices', False) %}
   - watch_in:
     - service: apache_service
-  {% endif %}
 
 {%- endfor %}
 
diff --git a/apache/server/service/mpm.sls b/apache/server/service/mpm.sls
index 1fc4efd..58a6e94 100644
--- a/apache/server/service/mpm.sls
+++ b/apache/server/service/mpm.sls
@@ -16,10 +16,8 @@
     {%- for mpm_name, dummy in server.mpm.iteritems() if mpm_name != mpm_type %}
     - file: apache_mpm_{{ mpm_name }}_disable
     {%- endfor %}
-  {% if not grains.get('noservices', False) %}
   - watch_in:
     - service: apache_service
-  {% endif %}
 
 apache_mpm_{{ mpm_type }}_config:
   file.managed:
@@ -28,28 +26,22 @@
   - template: jinja
   - require:
     - pkg: apache_packages
-  {% if not grains.get('noservices', False) %}
   - watch_in:
     - service: apache_service
-  {% endif %}
 
 {%- else %}
 
 apache_mpm_{{ mpm_type }}_disable:
   file.absent:
   - name: /etc/apache2/mods-enabled/mpm_{{ mpm_type }}.load
-  {% if not grains.get('noservices', False) %}
   - watch_in:
     - service: apache_service
-  {% endif %}
 
 apache_mpm_{{ mpm_type }}_conf_disable:
   file.absent:
   - name: /etc/apache2/mods-enabled/mpm_{{ mpm_type }}.conf
-  {% if not grains.get('noservices', False) %}
   - watch_in:
     - service: apache_service
-  {% endif %}
 
 {%- endif %}
 
diff --git a/apache/server/site.sls b/apache/server/site.sls
index 3489787..04fe0b1 100644
--- a/apache/server/site.sls
+++ b/apache/server/site.sls
@@ -20,10 +20,8 @@
     site_name: "{{ site_name }}"
   - require:
     - pkg: apache_packages
-  {% if not grains.get('noservices', False) %}
   - watch_in:
     - service: apache_service
-  {% endif %}
 
 {%- if site.get('webdav', {}).get('enabled', False) %}
 {{ site.name }}_webdav_dir:
@@ -87,10 +85,8 @@
   - target: {{ server.vhost_dir }}/{{ site.type }}_{{ site.name }}{{ server.conf_ext }}
   - require:
     - file: {{ server.vhost_dir }}/{{ site.type }}_{{ site.name }}{{ server.conf_ext }}
-  {% if not grains.get('noservices', False) %}
   - watch_in:
     - service: apache_service
-  {% endif %}
 
 /etc/apache2/sites-enabled/{{ site.type }}_{{ site.name }}:
   file.absent
diff --git a/tests/pillar/apache_server.sls b/tests/pillar/apache_server_php5.sls
similarity index 98%
rename from tests/pillar/apache_server.sls
rename to tests/pillar/apache_server_php5.sls
index fe53ffa..0c75989 100644
--- a/tests/pillar/apache_server.sls
+++ b/tests/pillar/apache_server_php5.sls
@@ -4,6 +4,7 @@
     modules:
       - cgi
       - php
+    module_php: php5
     user:
       cloudlab:
         enabled: true
diff --git a/tests/pillar/apache_server.sls b/tests/pillar/apache_server_php7.sls
similarity index 98%
copy from tests/pillar/apache_server.sls
copy to tests/pillar/apache_server_php7.sls
index fe53ffa..64a21d8 100644
--- a/tests/pillar/apache_server.sls
+++ b/tests/pillar/apache_server_php7.sls
@@ -4,6 +4,7 @@
     modules:
       - cgi
       - php
+    module_php: php7.0
     user:
       cloudlab:
         enabled: true