Merge pull request #6 from Martin819/master
Added Kitchen tests and Travis
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..ac0cdc6
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,44 @@
+---
+driver:
+ name: docker
+ hostname: apache.ci.local
+ use_sudo: false
+
+provisioner:
+ name: salt_solo
+ salt_install: bootstrap
+ salt_bootstrap_url: https://bootstrap.saltstack.com
+ salt_version: latest
+ require_chef: false
+ log_level: error
+ formula: apache
+ grains:
+ noservices: True
+ state_top:
+ base:
+ "*":
+ - apache
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - apache
+
+verifier:
+ name: inspec
+ sudo: true
+
+
+platforms:
+ - name: <%=ENV['PLATFORM'] || 'ubuntu-xenial'%>
+ driver_config:
+ image: <%=ENV['PLATFORM'] || 'trevorj/salty-whales:xenial'%>
+ platform: ubuntu
+
+suites:
+
+ - name: apache_server
+ provisioner:
+ pillars-from-files:
+ apache.sls: tests/pillar/apache_server.sls
+# vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..4f34af2
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,40 @@
+sudo: required
+services:
+ - docker
+
+install:
+ - pip install PyYAML
+ - pip install virtualenv
+ - |
+ test -e Gemfile || cat <<EOF > Gemfile
+ source 'https://rubygems.org'
+ gem 'rake'
+ gem 'test-kitchen'
+ gem 'kitchen-docker'
+ gem 'kitchen-inspec'
+ gem 'inspec'
+ gem 'kitchen-salt', :git => 'https://github.com/salt-formulas/kitchen-salt.git'
+ - bundle install
+
+env:
+ - PLATFORM=trevorj/salty-whales:trusty
+ - PLATFORM=trevorj/salty-whales:xenial
+
+
+before_script:
+ - set -o pipefail
+ - make test | tail
+
+script:
+ - test ! -e .kitchen.yml || bundle exec kitchen test -t tests/integration
+
+notifications:
+ webhooks:
+ urls:
+ - https://webhooks.gitter.im/e/6123573504759330786b
+ on_success: change # options: [always|never|change] default: always
+ on_failure: never # options: [always|never|change] default: always
+ on_start: never # options: [always|never|change] default: always
+ on_cancel: never # options: [always|never|change] default: always
+ on_error: never # options: [always|never|change] default: always
+ email: false
diff --git a/apache/map.jinja b/apache/map.jinja
index 8e9566c..9a871cc 100644
--- a/apache/map.jinja
+++ b/apache/map.jinja
@@ -5,9 +5,9 @@
'service': 'apache2',
'mod_wsgi': 'libapache2-mod-wsgi',
'mod_php': 'libapache2-mod-php5',
- 'mod_perl': 'libapache2-mod-perl2',
- 'mod_xsendfile': 'libapache2-mod-xsendfile',
- 'mod_auth_kerb': 'libapache2-mod-auth-kerb',
+ 'mod_perl': 'libapache2-mod-perl2',
+ 'mod_xsendfile': 'libapache2-mod-xsendfile',
+ 'mod_auth_kerb': 'libapache2-mod-auth-kerb',
'htpasswd_dir': '/etc/apache2',
'vhost_dir': '/etc/apache2/sites-available',
'conf_dir': '/etc/apache2/conf-available',
@@ -57,7 +57,44 @@
'service_user': 'apache',
'service_group': 'apache',
},
-}, merge=salt['pillar.get']('apache:server')) %}
+}, merge=salt['grains.filter_by']({
+ 'trusty': {
+ 'pkgs': ['apache2', 'apache2-utils'],
+ 'service': 'apache2',
+ 'mod_wsgi': 'libapache2-mod-wsgi',
+ 'mod_php': 'libapache2-mod-php5',
+ 'module_php': 'php5',
+ 'mod_perl': 'libapache2-mod-perl2',
+ 'mod_xsendfile': 'libapache2-mod-xsendfile',
+ 'mod_auth_kerb': 'libapache2-mod-auth-kerb',
+ 'htpasswd_dir': '/etc/apache2',
+ 'vhost_dir': '/etc/apache2/sites-available',
+ 'conf_dir': '/etc/apache2/conf-available',
+ 'conf_ext': '.conf',
+ 'log_dir': '/var/log/apache2',
+ 'www_dir': '/var/www',
+ 'service_user': 'www-data',
+ 'service_group': 'www-data',
+ },
+ 'xenial': {
+ 'pkgs': ['apache2'],
+ 'service': 'apache2',
+ 'mod_wsgi': 'libapache2-mod-wsgi',
+ 'mod_php': 'libapache2-mod-php7.0',
+ 'module_php': 'php7.0',
+ 'mod_perl': 'libapache2-mod-perl2',
+ 'mod_xsendfile': 'libapache2-mod-xsendfile',
+ 'mod_auth_kerb': 'libapache2-mod-auth-kerb',
+ 'htpasswd_dir': '/etc/apache2',
+ 'vhost_dir': '/etc/apache2/sites-available',
+ 'conf_dir': '/etc/apache2/conf-available',
+ 'conf_ext': '.conf',
+ 'log_dir': '/var/log/apache2',
+ 'www_dir': '/var/www',
+ 'service_user': 'www-data',
+ 'service_group': 'www-data',
+ },
+}, grain='oscodename', merge=salt['pillar.get']('apache:server'))) %}
{%- set listen_ports = {} %}
{%- if server.site is defined %}
diff --git a/apache/server/service/init.sls b/apache/server/service/init.sls
index 319680c..79aa704 100644
--- a/apache/server/service/init.sls
+++ b/apache/server/service/init.sls
@@ -21,8 +21,10 @@
- template: jinja
- require:
- pkg: apache_packages
+ {% if not grains.get('noservices', False) %}
- watch_in:
- service: apache_service
+ {% endif %}
apache_security_config:
file.managed:
@@ -31,8 +33,10 @@
- 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:
@@ -40,14 +44,21 @@
- 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) %}
/etc/apache2/sites-enabled/000-default.conf:
file.absent:
- watch_in:
- service: apache_service
+{% endif %}
+
+
+{% if not grains.get('noservices', False) %}
apache_service:
service.running:
@@ -57,6 +68,8 @@
- require:
- pkg: apache_packages
+{% endif%}
+
{%- else %}
apache_service_dead:
diff --git a/apache/server/service/modules.sls b/apache/server/service/modules.sls
index cee92fe..49bcaa2 100644
--- a/apache/server/service/modules.sls
+++ b/apache/server/service/modules.sls
@@ -21,7 +21,7 @@
- require:
- pkg: apache_packages
-{%- set module = 'php5' %}
+{%- set module = server.module_php %}
{%- endif %}
@@ -71,8 +71,10 @@
- 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 58a6e94..1fc4efd 100644
--- a/apache/server/service/mpm.sls
+++ b/apache/server/service/mpm.sls
@@ -16,8 +16,10 @@
{%- 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:
@@ -26,22 +28,28 @@
- 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 04fe0b1..3489787 100644
--- a/apache/server/site.sls
+++ b/apache/server/site.sls
@@ -20,8 +20,10 @@
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:
@@ -85,8 +87,10 @@
- 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