Stretch support

- Support Debian Stretch (MariaDB debian/upstream + Galera)
- Doc updated
- New travis tests (with Vagrant)
- Drop support of mysql_innodb_additional_mem_pool_size
- Xtrabackup optionnal installation + package name updatable
- Fix many issues with replication (Ansible 2.3)
- Auto-retreive master IP address on tests
- MySQL tools per OS release
This commit is contained in:
Emilien Mantel
2017-06-28 16:15:44 +02:00
parent 2423abf584
commit 2aec278e00
31 changed files with 215 additions and 210 deletions

View File

@@ -4,9 +4,8 @@ About tests
IMPORTANT
---------
- DO NOT `vagrant up`! My Vagrantfile provides 14 VMs (256MB each)...
- Each slave communicate to his master. You can't mix mysql and mariadb.
- This tests uses my [MySQL role](https://github.com/HanXHX/ansible-mysql).
- DO NOT `vagrant up`! My Vagrantfile provides many VMs...
- Each slave communicate to his master. You can't mix mysql and mariadb.
Tests
-----
@@ -19,25 +18,6 @@ Wait master fully installed before run slave.
Example:
```
sudo ansible-galaxy install HanXHX.mysql
vagrant up jessie-upstream-mariadb-master
vagrant up jessie-upstream-mariadb-slave
```
Supported platforms
-------------------
- Debian Jessie
Supported MySQL vendors
-----------------------
- MariaDB 10.0 / 10.1 / 10.2 (from Debian Jessie or MariaDB repository)
- MySQL 5.5 (from Debian repositories)
- Percona Server 5.5 / 5.6 / 5.7 (from Percona Repository)
About MySQL 5.6
---------------
You can get MySQL 5.6 for Debian with [Dotdeb](https://www.dotdeb.org) with my [Dotdeb role](https://github.com/HanXHX/ansible-debian-dotdeb). I give no support with this version (pull-request accepted). It can work but without GTID.

View File

@@ -1,5 +0,0 @@
FROM williamyeh/ansible:debian8-onbuild
RUN apt-get update
RUN apt-get install -y python-netaddr
CMD ["sh", "tests/travis.sh"]

View File

@@ -1,84 +0,0 @@
#!/usr/bin/perl
#
# This script generates ansible test config for Vagrant
#
use strict;
use warnings;
use Socket;
my @a = (
"jessie-default-mysql-master",
"jessie-default-mysql-slave",
"jessie-upstream-mariadb-master",
"jessie-upstream-mariadb-slave",
"jessie-upstream-percona-master",
"jessie-upstream-percona-slave",
"jessie-default-mariadb-master",
"jessie-default-mariadb-slave",
"jessie-upstream-mariadbgalera-1",
"jessie-upstream-mariadbgalera-2",
"jessie-upstream-mariadbgalera-3"
);
my $start_ip = '192.168.200.10';
my $iip = ip2long($start_ip);
my @galera = ();
foreach my $n (@a)
{
my @data = split(/-/, $n);
printf(
'["%s", "debian/%s64", "%s", [%s]],' . "\n",
$n,
$data[0],
long2ip($iip),
join(',', map { sprintf('"%s"', $_) } @data)
);
if($data[-1] eq 'slave')
{
open(FILE, '>', "host_vars/$n");
printf FILE (qq/his_master: '%s'\n/, long2ip($iip));
close(FILE);
}
# if($data[-1] =~ /^\d$/ && $data[-2] eq 'mariadbgalera')
# {
# open(FILE, '>', "host_vars/$n");
# printf FILE (qq/galera_id: '%s'\n/, $data[-1]);
# close(FILE);
# }
if($data[-2] eq 'mariadbgalera')
{
push(@galera, long2ip($iip));
goto SKIP;
}
open(FILE, '>', "group_vars/" . $data[2]);
printf FILE (qq/mysql_vendor: '%s'\n/, $data[2]);
close(FILE);
SKIP:
$iip++;
}
open(FILE, '>', 'group_vars/mariadbgalera');
say FILE qq/mysql_vendor: 'mariadb_galera'/;
say FILE qq/mariadb_galera_members:/;
foreach(@galera)
{
say FILE qq/ - '$_'/;
}
close(FILE);
sub ip2long {
return unpack("l*", pack("l*", unpack("N*", inet_aton(shift))));
}
sub long2ip {
return inet_ntoa(pack("N*", shift));
}

View File

@@ -1,4 +1,5 @@
mysql_bind_address: '{{ ansible_eth1.ipv4.address }}'
mysql_bind_address: '0.0.0.0'
mysql_extra_configuration:
innodb_commit_concurrency: 0
mysql_use_percona_apt: true
mysql_install_xtrabackup_package: true

View File

@@ -1 +0,0 @@
mysql_origin: 'default'

View File

@@ -1 +0,0 @@
mysql_vendor: 'mariadb'

View File

@@ -1,5 +1,5 @@
mysql_vendor: 'mariadb_galera'
mysql_galera_members:
- '192.168.200.18'
- '192.168.200.19'
- '192.168.200.20'
- '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-1'
- '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-2'
- '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-3'

View File

@@ -1 +0,0 @@
mysql_vendor: 'percona'

View File

@@ -2,7 +2,6 @@ mysql_replication_master: false
mysql_replication_slave: true
mysql_replication_user: 'replication'
mysql_replication_password: '1a2b3c'
mysql_replication_host: '{{ his_master }}'
mysql_server_id: 2
mysql_slave_ignore_db: ['norepl']

View File

@@ -1 +0,0 @@
mysql_origin: 'upstream'

View File

@@ -1 +0,0 @@
his_master: '192.168.200.17'

View File

@@ -1 +0,0 @@
his_master: '192.168.200.11'

View File

@@ -1 +0,0 @@
his_master: '192.168.200.13'

View File

@@ -1 +0,0 @@
his_master: '192.168.200.15'

View File

@@ -1,19 +1,13 @@
---
- hosts: all
pre_tasks:
- local_action: shell ssh-add $HOME/.vagrant.d/insecure_private_key
become: no
changed_when: false
tasks:
- apt: pkg={{ item }} state=present update_cache=yes cache_valid_time=3600
with_items:
- ca-certificates
- curl
- strace
- vim
- get_url: >
url=https://raw.githubusercontent.com/HanXHX/ansible-debian-bootstrap/master/files/bashrc
dest=/root/.bashrc
force=yes
- hosts: master
roles:
@@ -26,22 +20,40 @@
when: c.changed
- hosts: slave
pre_tasks:
- name: SHELL | Get master IP
shell: getent hosts {{ ansible_hostname | replace ('slave', 'master') }} | cut -d ' ' -f 1
register: ip
changed_when: false
- set_fact:
# MySQL don't read /etc/hosts (from vagrant host plugin)
mysql_replication_host: "{{ ip.stdout }}"
# Need this to use vagrant 'delegate_to'
mysql_slave_import_from: "{{ ansible_hostname | replace ('slave', 'master') }}"
roles:
- ../../
tasks:
- copy: src=import2.sql dest=/tmp/import2.sql
delegate_to: "{{ his_master }}"
delegate_to: "{{ mysql_slave_import_from }}"
register: c
- mysql_db: name={{ item }} state=import target=/tmp/import2.sql
with_items: ['testrepl', 'norepl']
delegate_to: "{{ his_master }}"
delegate_to: "{{ mysql_slave_import_from }}"
when: c.changed
- mysql_replication: mode=getslave
register: slave
- fail: msg="Slave issue"
when: slave.Slave_IO_Running != 'Yes' or slave.Slave_SQL_Running != 'Yes'
- hosts: mariadbgalera
vars:
mysql_galera_primary_node: 'jessie-upstream-mariadbgalera-1'
mysql_wsrep_node_address: "{{ ansible_eth1.ipv4.address }}"
mysql_mariadb_version: '10.1'
mysql_galera_primary_node: '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-1'
mysql_wsrep_node_address: "{{ ansible_all_ipv4_addresses[0] }}"
mysql_mariadb_version: '10.2'
pre_tasks:
- set_fact:
mysql_wsrep_node_address: "{{ ansible_eth1.ipv4.address }}"
when: not is_docker
roles:
- ../../