Merge "Change mysql-wsrep package"
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 bcdd272..65683f2 100644
--- a/galera/map.jinja
+++ b/galera/map.jinja
@@ -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..3728ba2 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:
@@ -62,6 +63,37 @@
- require:
- pkg: galera_packages
+{%- elif grains.get('init', None) == "systemd" %}
+
+galera_systemd_directory_present:
+ file.directory:
+ - name: /etc/systemd/system/mysql.service.d
+ - user: root
+ - group: root
+ - mode: 755
+ - require:
+ - pkg: galera_packages
+
+galera_override_limit_no_file:
+ file.managed:
+ - name: /etc/systemd/system/mysql.service.d/override.conf
+ - contents: |
+ [Service]
+ LimitNOFILE=1024000
+ - require:
+ - pkg: galera_packages
+ - file: galera_systemd_directory_present
+ - watch_in:
+ - service: galera_service
+
+mysql_restart_systemd:
+ module.wait:
+ - name: service.systemctl_reload
+ - watch:
+ - file: /etc/systemd/system/mysql.service.d/override.conf
+ - require_in:
+ - service: galera_service
+
{%- endif %}
galera_conf_debian:
@@ -106,6 +138,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 +162,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 +175,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 +189,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 +209,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 +223,4 @@
- reload: true
{%- endif %}
+{%- endif %}
diff --git a/galera/meta/heka.yml b/galera/meta/heka.yml
index eee3fa5..7b94f96 100644
--- a/galera/meta/heka.yml
+++ b/galera/meta/heka.yml
@@ -9,7 +9,7 @@
galera:
engine: logstreamer
log_directory: "/var/log"
- file_match: 'mysql/error.log$'
+ file_match: 'mysql/error\.log$'
differentiator: ["galera"]
decoder: "galera_decoder"
splitter: "galera_splitter"
diff --git a/galera/server.sls b/galera/server.sls
index 0d6572b..a81a7e8 100644
--- a/galera/server.sls
+++ b/galera/server.sls
@@ -37,6 +37,7 @@
- template: jinja
- defaults:
database_name: {{ database_name }}
+ database: {{ database }}
- require:
- file: mysql_dirs
- mysql_database: mysql_database_{{ database_name }}
@@ -53,6 +54,7 @@
{%- endfor %}
+{%- if not grains.get('noservices', False) %}
{%- for user in server.get('users', []) %}
mysql_user_{{ user.name }}_{{ user.host }}:
@@ -66,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..6f2ada3 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:
@@ -62,6 +63,37 @@
- require:
- pkg: galera_packages
+{%- elif grains.get('init', None) == "systemd" %}
+
+galera_systemd_directory_present:
+ file.directory:
+ - name: /etc/systemd/system/mysql.service.d
+ - user: root
+ - group: root
+ - mode: 755
+ - require:
+ - pkg: galera_packages
+
+galera_override_limit_no_file:
+ file.managed:
+ - name: /etc/systemd/system/mysql.service.d/override.conf
+ - contents: |
+ [Service]
+ LimitNOFILE=1024000
+ - require:
+ - pkg: galera_packages
+ - file: galera_systemd_directory_present
+ - watch_in:
+ - service: galera_service
+
+mysql_restart_systemd:
+ module.wait:
+ - name: service.systemctl_reload
+ - watch:
+ - file: /etc/systemd/system/mysql.service.d/override.conf
+ - require_in:
+ - service: galera_service
+
{%- endif %}
galera_conf_debian:
@@ -106,6 +138,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 +165,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 +196,7 @@
- file: galera_config
{%- endif %}
+{%- endif %}
galera_config:
file.managed:
@@ -163,8 +204,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 +218,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"