Added Kitchen tests and travis
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..dbb9474
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,60 @@
+---
+driver:
+ name: docker
+ hostname: galera.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: galera
+ grains:
+ noservices: True
+ state_top:
+ base:
+ "*":
+ - linux
+ - galera
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - galera
+ - galeracluster_debian_repo
+ pillars-from-files:
+ galeracluster_debian_repo.sls: tests/pillar/repo_galeracluster.sls
+ dependencies:
+ - name: mysql
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-mysql.git
+ 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: master_cluster
+ provisioner:
+ pillars-from-files:
+ galera.sls: tests/pillar/master_cluster.sls
+
+ - name: slave_cluster
+ provisioner:
+ pillars-from-files:
+ galera.sls: tests/pillar/slave_cluster.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..7a77247
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,39 @@
+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/galera/map.jinja b/galera/map.jinja
index 7e9f065..65683f2 100644
--- a/galera/map.jinja
+++ b/galera/map.jinja
@@ -1,7 +1,7 @@
{%- set master = salt['grains.filter_by']({
'Debian': {
- 'pkgs': ['mysql-server-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
+ 'pkgs': ['mysql-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
'service': 'mysql',
'wsrep_provider': '/usr/lib/galera/libgalera_smm.so',
'log_file': '/var/log/mysql.log',
@@ -21,7 +21,7 @@
{%- set slave = salt['grains.filter_by']({
'Debian': {
- 'pkgs': ['mysql-server-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
+ 'pkgs': ['mysql-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
'service': 'mysql',
'wsrep_provider': '/usr/lib/galera/libgalera_smm.so',
'log_file': '/var/log/mysql.log',
@@ -36,5 +36,22 @@
'log_file': '/var/log/mariadb/mariadb.log',
'socket': '/var/run/mariadb/mysqld.sock',
'config': '/etc/my.cnf',
- },
-}, merge=pillar.galera.get('slave', {})) %}
+ },
+ }, merge=salt['grains.filter_by']({
+ 'trusty': {
+ 'pkgs': ['mysql-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
+ 'service': 'mysql',
+ 'wsrep_provider': '/usr/lib/galera/libgalera_smm.so',
+ 'log_file': '/var/log/mysql.log',
+ 'socket': '/var/run/mysqld/mysqld.sock',
+ 'config': '/etc/mysql/my.cnf',
+ },
+ 'xenial': {
+ 'pkgs': ['mysql-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'libmysqlclient-dev', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'],
+ 'service': 'mysql',
+ 'wsrep_provider': '/usr/lib/galera/libgalera_smm.so',
+ 'log_file': '/var/log/mysql.log',
+ 'socket': '/var/run/mysqld/mysqld.sock',
+ 'config': '/etc/mysql/my.cnf',
+ },
+}, grain='oscodename', merge=pillar.galera.get('slave', {}))) %}
diff --git a/galera/master.sls b/galera/master.sls
index 7a1025d..0fe43ce 100644
--- a/galera/master.sls
+++ b/galera/master.sls
@@ -25,6 +25,7 @@
pkg.installed:
- names: {{ master.pkgs }}
- refresh: true
+ - force_yes: True
galera_log_dir:
file.directory:
@@ -106,6 +107,8 @@
- require_in:
- pkg: galera_packages
+{%- if not grains.get('noservices', False) %}
+
galera_init_start_service:
cmd.run:
- name: /usr/local/sbin/galera_init.sh
@@ -128,8 +131,12 @@
galera_bootstrap_stop_service:
service.dead:
- name: {{ master.service }}
+ {%- if not grains.get('noservices', False) %}
- require:
- cmd: mysql_bootstrap_update_maint_password
+ {%- endif %}
+
+{%- endif %}
galera_bootstrap_init_config:
file.managed:
@@ -137,8 +144,12 @@
- source: salt://galera/files/my.cnf.init
- mode: 644
- template: jinja
+ {%- if not grains.get('noservices', False) %}
- require:
- service: galera_bootstrap_stop_service
+ {%- endif %}
+
+{%- if not grains.get('noservices', False) %}
galera_bootstrap_start_service_final:
cmd.run:
@@ -147,11 +158,15 @@
- file: galera_bootstrap_init_config
- file: galera_bootstrap_script
+{%- endif %}
+
galera_bootstrap_finish_flag:
file.touch:
- name: /var/lib/mysql/.galera_bootstrap
+ {%- if not grains.get('noservices', False) %}
- require:
- cmd: galera_bootstrap_start_service_final
+ {%- endif %}
- watch_in:
- file: galera_config
@@ -163,8 +178,12 @@
- source: salt://galera/files/my.cnf
- mode: 644
- template: jinja
+ {%- if not grains.get('noservices', False) %}
- require_in:
- service: galera_service
+ {%- endif %}
+
+{%- if not grains.get('noservices', False) %}
galera_service:
service.running:
@@ -173,3 +192,4 @@
- reload: true
{%- endif %}
+{%- endif %}
diff --git a/galera/server.sls b/galera/server.sls
index b9cddb9..a81a7e8 100644
--- a/galera/server.sls
+++ b/galera/server.sls
@@ -54,6 +54,7 @@
{%- endfor %}
+{%- if not grains.get('noservices', False) %}
{%- for user in server.get('users', []) %}
mysql_user_{{ user.name }}_{{ user.host }}:
@@ -67,5 +68,5 @@
{%- endif %}
{%- endfor %}
-
+{%- endif %}
{%- endif %}
\ No newline at end of file
diff --git a/galera/slave.sls b/galera/slave.sls
index 8b801fa..7310560 100644
--- a/galera/slave.sls
+++ b/galera/slave.sls
@@ -25,6 +25,7 @@
pkg.installed:
- names: {{ slave.pkgs }}
- refresh: true
+ - force_yes: True
galera_log_dir:
file.directory:
@@ -106,6 +107,8 @@
- require_in:
- pkg: galera_packages
+{%- if not grains.get('noservices', False) %}
+
galera_init_start_service:
cmd.run:
- name: /usr/local/sbin/galera_init.sh
@@ -131,14 +134,20 @@
- require:
- cmd: mysql_bootstrap_update_maint_password
+{%- endif %}
+
galera_bootstrap_init_config:
file.managed:
- name: {{ slave.config }}
- source: salt://galera/files/my.cnf
- mode: 644
- template: jinja
+ {%- if not grains.get('noservices', False) %}
- require:
- service: galera_bootstrap_stop_service
+ {%- endif %}
+
+{%- if not grains.get('noservices', False) %}
galera_bootstrap_start_service_final:
cmd.run:
@@ -156,6 +165,7 @@
- file: galera_config
{%- endif %}
+{%- endif %}
galera_config:
file.managed:
@@ -163,8 +173,12 @@
- source: salt://galera/files/my.cnf
- mode: 644
- template: jinja
+ {%- if not grains.get('noservices', False) %}
- require_in:
- service: galera_service
+ {%- endif %}
+
+{%- if not grains.get('noservices', False) %}
galera_service:
service.running:
@@ -173,3 +187,4 @@
- reload: true
{%- endif %}
+{%- endif %}
diff --git a/metadata.yml b/metadata.yml
index 2b94052..1087027 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,6 +1,6 @@
name: "galera"
version: "1.0"
-source: "https://github.com/tcpcloud/salt-formula-galera"
+source: "https://github.com/salt-formulas/salt-formula-galera"
dependencies:
- name: mysql
- source: "https://github.com/tcpcloud/salt-formula-mysql"
+ source: "https://github.com/salt-formulas/salt-formula-mysql"
diff --git a/tests/pillar/master_cluster.sls b/tests/pillar/master_cluster.sls
index 209654a..7257ce4 100644
--- a/tests/pillar/master_cluster.sls
+++ b/tests/pillar/master_cluster.sls
@@ -24,4 +24,4 @@
- name: haproxy
host: '%'
- name: haproxy
- host: 127.0.0.1
\ No newline at end of file
+ host: 127.0.0.1
diff --git a/tests/pillar/repo_galeracluster.sls b/tests/pillar/repo_galeracluster.sls
new file mode 100644
index 0000000..464a414
--- /dev/null
+++ b/tests/pillar/repo_galeracluster.sls
@@ -0,0 +1,10 @@
+linux:
+ system:
+ enabled: true
+ repo:
+ galeracluster:
+ source: 'deb http://releases.galeracluster.com/ubuntu {{ grains.get('oscodename') }} main'
+ key_id: BC19DDBA
+ key_server: hkp://p80.pool.sks-keyservers.net:80
+ mitaka-staging_PPA:
+ source: "deb http://ppa.launchpad.net/ubuntu-cloud-archive/mitaka-staging/ubuntu trusty main"