Added Kitchen tests and Travis + moved Kibana repo info to pillar (#17)
* Added Kitchen tests and Travis + moved Kibana repo info to pillar
* show 'make test' errors in Travis
* Update .travis.yml and notififcations
* Moved repo install to separate file
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..1342bad
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,51 @@
+---
+driver:
+ name: docker
+ hostname: kibana.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: kibana
+ grains:
+ noservices: True
+ state_top:
+ base:
+ "*":
+ - linux
+ - kibana
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - kibana
+ - kibana_debian_repo
+ pillars-from-files:
+ kibana_debian_repo.sls: tests/pillar/kibana_debian_repo.sls
+ dependencies:
+ - name: linux
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-linux.git
+
+verifier:
+ name: inspec
+ sudo: true
+
+platforms:
+ - name: <%=ENV['PLATFORM'] || 'ubuntu-xenial'%>
+ driver_config:
+ image: <%=ENV['PLATFORM'] || 'trevorj/salty-whales:xenial'%>
+ platform: ubuntu
+
+suites:
+
+ - name: kibana_server
+ provisioner:
+ pillars-from-files:
+ kibana.sls: tests/pillar/kibana_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/kibana/server.sls b/kibana/server.sls
index 9f24c69..6898a97 100644
--- a/kibana/server.sls
+++ b/kibana/server.sls
@@ -1,21 +1,12 @@
{%- from "kibana/map.jinja" import server with context %}
+{%- from "linux/map.jinja" import system with context %}
{%- if server.enabled %}
-{%- if server.addrepo is defined and grains['os_family'] == 'Debian' %}
-
-kibana_repo:
- pkgrepo.managed:
- - humanname: Kibana Repository
- - name: deb http://packages.elastic.co/kibana/4.1/debian stable main
- - dist: stable
- - file: /etc/apt/sources.list.d/kibana.list
- - key_url: https://packages.elastic.co/GPG-KEY-elasticsearch
-
-{%- endif %}
-
kibana_package:
pkg.installed:
- - name: {{ server.pkgname }}
+ - name: {{ server.pkgname }}
+
+{%- if not grains.get('noservices', False) %}
kibana_service:
service.running:
@@ -24,6 +15,8 @@
- watch:
- file: {{ server.configpath }}
+{%- endif %}
+
{{ server.configpath }}:
file.managed:
- source: salt://kibana/files/kibana.yml
diff --git a/tests/pillar/kibana_debian_repo.sls b/tests/pillar/kibana_debian_repo.sls
new file mode 100644
index 0000000..5863bb2
--- /dev/null
+++ b/tests/pillar/kibana_debian_repo.sls
@@ -0,0 +1,8 @@
+linux:
+ system:
+ enabled: true
+ repo:
+ kibana:
+ source: 'deb http://packages.elastic.co/kibana/4.1/debian stable main'
+ key_id: 46095ACC8548582C1A2699A9D27D666CD88E42B4
+ key_server: hkp://p80.pool.sks-keyservers.net:80
\ No newline at end of file
diff --git a/tests/pillar/kibana_server.sls b/tests/pillar/kibana_server.sls
index ad8ad52..115494c 100644
--- a/tests/pillar/kibana_server.sls
+++ b/tests/pillar/kibana_server.sls
@@ -9,4 +9,3 @@
engine: elasticsearch
host: localhost
port: 9200
-