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
pull/20/head
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

@ -1,22 +1,38 @@
matrix:
include:
- env: PLATFORM=debian-jessie ORIGIN=default VENDOR=mysql
- env: PLATFORM=debian-jessie ORIGIN=default VENDOR=mariadb
- env: PLATFORM=debian-jessie ORIGIN=upstream VENDOR=mariadb
- env: PLATFORM=debian-jessie ORIGIN=upstream VENDOR=mariadb_galera
- env: PLATFORM=debian-jessie ORIGIN=upstream VENDOR=percona
env:
- PLATFORM='docker-jessie-default-mysql-master' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-jessie-upstream-mariadb-master' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-jessie-upstream-mariadb-master' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-jessie-upstream-percona-master' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-jessie-upstream-mariadbgalera-1' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-stretch-default-mysql-master' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-stretch-upstream-mariadb-master' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-stretch-upstream-mariadb-master' ANSIBLE_VERSION='ansible>=2.3,<2.4'
- PLATFORM='docker-stretch-upstream-mariadbgalera-1' ANSIBLE_VERSION='ansible>=2.3,<2.4'
sudo: required
dist: trusty
language: python
services:
- docker
language: python
before_install:
- wget https://releases.hashicorp.com/vagrant/1.9.5/vagrant_1.9.5_x86_64.deb
- sudo dpkg -i vagrant_1.9.5_x86_64.deb
install:
- pip install "$ANSIBLE_VERSION"
script:
- docker build -f tests/$PLATFORM.Dockerfile -t test-$PLATFORM . && docker run -e "ORIGIN=$ORIGIN" -e "VENDOR=$VENDOR" --name $PLATFORM test-$PLATFORM
- VAGRANT_DEFAULT_PROVIDER=docker vagrant up $PLATFORM
- >
VAGRANT_DEFAULT_PROVIDER=docker vagrant provision $PLATFORM
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
- VAGRANT_DEFAULT_PROVIDER=docker vagrant status
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View File

@ -5,18 +5,31 @@ MySQL vendors for Debian Ansible role
Install and configure MySQL or MariaDB (Galera Cluster) or Percona Server. Manage replication (master/slave). Create users and databases.
| OS | Vendor | Origin | Managed versions |
| --------------- | ----------------------- | --------- | ------------------- |
| Debian Jessie | MySQL | Debian | 5.5 / 5.6 |
| Debian Jessie | MariaDB | Debian | 10.0 |
| Debian Jessie | MariaDB | Upstream | 10.0 / 10.1 / 10.2 |
| Debian Jessie | MariaDB Galera Cluster | Upstream | 10.1 / 10.2 |
| Debian Jessie | Percona server | Upstream | 5.5 / 5.6 / 5.7 |
| OS | Vendor | Origin | Managed versions |
| --------------- | ----------------------- | --------- | ------------------------- |
| Debian Jessie | MySQL | Debian | 5.5 / 5.6 |
| Debian Jessie | MariaDB | Debian | 10.0 |
| Debian Jessie | MariaDB | Upstream | 10.0 / 10.1 / 10.2 / 10.3 |
| Debian Jessie | MariaDB Galera Cluster | Upstream | 10.1 / 10.2 |
| Debian Jessie | Percona server | Upstream | 5.5 / 5.6 / 5.7 |
| Debian Stretch | MariaDB | Debian | 10.1 |
| Debian Stretch | MariaDB | Upstream | 10.1 / 10.2 / 10.3 |
| Debian Stretch | MariaDB Galera Cluster | Upstream | 10.1 / 10.2 |
Notes
-----
* MySQL 5.6 on Jessie needs backports repository
* MySQL server no longer exists on Debian Stretch
* Percona Server is not available (soon?) on Debian Stretch
* Galera Cluster is experimental
* Due to Vagrant + Docker limitation (private network), replication/galera can't be checked with Travis
* If you need to test this role with Vagrant, you must install hostmanager plugin: `vagrant plugin install vagrant-hostmanager`
Requirements
------------
None. But if you need MySQL 5.6 (from Debian respository), you must install backports.
None.
Role Variables
--------------

114
Vagrantfile vendored
View File

@ -5,42 +5,86 @@
Vagrant.configure("2") do |config|
vms = [
["jessie-default-mysql-master", "debian/jessie64", "192.168.200.10", ["jessie","default","mysql","master"]],
["jessie-default-mysql-slave", "debian/jessie64", "192.168.200.11", ["jessie","default","mysql","slave"]],
["jessie-upstream-mariadb-master", "debian/jessie64", "192.168.200.12", ["jessie","upstream","mariadb","master"]],
["jessie-upstream-mariadb-slave", "debian/jessie64", "192.168.200.13", ["jessie","upstream","mariadb","slave"]],
["jessie-upstream-percona-master", "debian/jessie64", "192.168.200.14", ["jessie","upstream","percona","master"]],
["jessie-upstream-percona-slave", "debian/jessie64", "192.168.200.15", ["jessie","upstream","percona","slave"]],
["jessie-default-mariadb-master", "debian/jessie64", "192.168.200.16", ["jessie","default","mariadb","master"]],
["jessie-default-mariadb-slave", "debian/jessie64", "192.168.200.17", ["jessie","default","mariadb","slave"]],
["jessie-upstream-mariadbgalera-1", "debian/jessie64", "192.168.200.18", ["jessie","upstream","mariadbgalera","1"]],
["jessie-upstream-mariadbgalera-2", "debian/jessie64", "192.168.200.19", ["jessie","upstream","mariadbgalera","2"]],
["jessie-upstream-mariadbgalera-3", "debian/jessie64", "192.168.200.20", ["jessie","upstream","mariadbgalera","3"]]
]
vbox_deb_jessie = 'debian/jessie64'
vbox_deb_stretch = 'debian/stretch64'
dk_deb_jessie = 'hanxhx/vagrant-ansible:debian8'
dk_deb_stretch = 'hanxhx/vagrant-ansible:debian9'
config.vm.provider "virtualbox" do |v|
v.cpus = 1
v.memory = 256
end
config.hostmanager.enabled = true
config.hostmanager.manage_host = false
config.hostmanager.manage_guest = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = false
vms.each do |vm|
config.vm.define vm[0] do |m|
m.vm.hostname = vm[0]
m.vm.box = vm[1]
m.vm.network "private_network", ip: vm[2]
cases = [
# Debian Jessie
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: dk_deb_jessie, vars: {mysql_origin: 'default', mysql_vendor: 'mysql' }, groups: ['master'] },
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: nil, vars: {mysql_origin: 'default', mysql_vendor: 'mysql' }, groups: ['slave'] },
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: dk_deb_jessie, vars: {mysql_origin: 'default', mysql_vendor: 'mariadb' }, groups: ['master'] },
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: nil, vars: {mysql_origin: 'default', mysql_vendor: 'mariadb' }, groups: ['slave'] },
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: dk_deb_jessie, vars: {mysql_origin: 'upstream', mysql_vendor: 'mariadb' }, groups: ['master'] },
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: nil, vars: {mysql_origin: 'upstream', mysql_vendor: 'mariadb' }, groups: ['slave'] },
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: dk_deb_jessie, vars: {mysql_origin: 'upstream', mysql_vendor: 'percona' }, groups: ['master'] },
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: nil, vars: {mysql_origin: 'upstream', mysql_vendor: 'percona' }, groups: ['slave'] },
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: dk_deb_jessie, vars: {mysql_origin: 'upstream' }, groups: ['mariadbgalera', '1'] },
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: nil, vars: {mysql_origin: 'upstream' }, groups: ['mariadbgalera', '2'] },
{ os_name: 'jessie', vbox: vbox_deb_jessie, docker: nil, vars: {mysql_origin: 'upstream' }, groups: ['mariadbgalera', '3'] },
# Debian Stretch
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mysql_origin: 'default', mysql_vendor: 'mysql' }, groups: ['master'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mysql_origin: 'default', mysql_vendor: 'mysql' }, groups: ['slave'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mysql_origin: 'default', mysql_vendor: 'mariadb' }, groups: ['master'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mysql_origin: 'default', mysql_vendor: 'mariadb' }, groups: ['slave'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mysql_origin: 'upstream', mysql_vendor: 'mariadb' }, groups: ['master'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mysql_origin: 'upstream', mysql_vendor: 'mariadb' }, groups: ['slave'] },
# { os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mysql_origin: 'upstream', mysql_vendor: 'percona' }, groups: ['master'] },
# { os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mysql_origin: 'upstream', mysql_vendor: 'percona' }, groups: ['slave'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: dk_deb_stretch, vars: {mysql_origin: 'upstream' }, groups: ['mariadbgalera', '1'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mysql_origin: 'upstream' }, groups: ['mariadbgalera', '2'] },
{ os_name: 'stretch', vbox: vbox_deb_stretch, docker: nil, vars: {mysql_origin: 'upstream' }, groups: ['mariadbgalera', '3'] },
]
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.groups = {
vm[3][0] => vm[0],
vm[3][1] => vm[0],
vm[3][2] => vm[0],
vm[3][3] => vm[0],
}
ansible.verbose = 'vv'
ansible.sudo = true
end
end
end
cases.each_with_index do |opts,index|
name = 'docker-' + opts[:os_name] + '-' + opts[:vars].map{|k,v| "#{v}"}.join('-') + '-' + opts[:groups].join('-')
iplsb = 10 + index
ip = '192.168.201.' + iplsb.to_s
next if opts[:docker].nil?
config.vm.define name do |m|
m.vm.network "private_network", ip: ip
m.vm.provider "docker" do |d|
d.image = opts[:docker]
d.remains_running = true
d.has_ssh = true
end
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
ansible.sudo = true
ansible.extra_vars = opts[:vars].merge({ is_docker: true })
ansible.groups = { opts[:groups][0] => name }
end
end
end
cases.each_with_index do |opts,index|
name = 'vbox-' + opts[:os_name] + '-' + opts[:vars].map{|k,v| "#{v}"}.join('-') + '-' + opts[:groups].join('-')
iplsb = 10 + index
ip = '192.168.200.' + iplsb.to_s
config.vm.define name do |m|
m.vm.hostname = name
m.vm.box = opts[:vbox]
m.vm.network "private_network", ip: ip
m.vm.provider "virtualbox" do |v|
v.cpus = 1
v.memory = 256
end
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
ansible.sudo = true
ansible.extra_vars = opts[:vars].merge({ is_docker: false })
ansible.groups = { opts[:groups][0] => name }
end
end
end
end

View File

@ -45,7 +45,6 @@ mysql_thread_concurrency: 2
# InnoDB settings.
mysql_innodb_file_per_table: '1'
mysql_innodb_buffer_pool_size: "{{ (ansible_memtotal_mb * 0.2) | round | int }}M"
mysql_innodb_additional_mem_pool_size: '20M' # See: http://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_additional_mem_pool_size
mysql_innodb_log_file_size: '64M'
mysql_innodb_log_buffer_size: '8M'
mysql_innodb_flush_log_at_trx_commit: '1'
@ -134,6 +133,8 @@ mysql_mariadb_repository: "http://ftp.igh.cnrs.fr/pub/mariadb/repo/{{ mysql_mari
mysql_percona_version: '5.6'
mysql_percona_repository: 'http://repo.percona.com/apt'
mysql_use_percona_apt: false
mysql_install_xtrabackup_package: false
mysql_xtrabackup_package: "{{ mysql_default_xtrabackup_package }}"
# Galera
mysql_galera_resetup: false

View File

@ -4,11 +4,12 @@ galaxy_info:
description: Install and configure MySQL or MariaDB (Galera Cluster) or Percona server on Debian
company:
license: GPLv2
min_ansible_version: 2.0
min_ansible_version: 2.3
platforms:
- name: Debian
versions:
- jessie
- stretch
galaxy_tags:
- database
- database:sql
@ -20,5 +21,7 @@ galaxy_info:
- debian
- galera
- cluster
- jessie
- stretch
dependencies: []

View File

@ -35,9 +35,8 @@
- name: APT | Install few MySQL related tools
apt: pkg={{ item }} state=present install_recommends=no
with_items:
- mytop
- percona-toolkit
- percona-xtrabackup
- python-mysqldb
- mysqltuner
with_items: "{{ mysql_tools }}"
- name: APT | Install percona-xtrabackup if needed
apt: pkg={{ mysql_xtrabackup_package }}
when: mysql_install_xtrabackup_package

View File

@ -19,4 +19,3 @@
- name: APT | Install Galera
apt: pkg=galera-3 state=present
when: mysql_vendor == 'mariadb_galera'

View File

@ -1,7 +1,8 @@
---
- name: APT | Install MariaDB key
apt_key: keyserver="keyserver.ubuntu.com" id="0xcbcb082a1bb943db" state=present
apt_key: keyserver="keyserver.ubuntu.com" id={{ item }} state=present
with_items: ['0xcbcb082a1bb943db', '0xf1656f24c74cd1d8']
- name: APT | Add MariaDB repository
apt_repository: repo='deb {{ mysql_mariadb_repository }} {{ ansible_distribution_release }} main' state=present
@ -12,4 +13,3 @@
- name: INCLUDE | Normal Install
include: default.yml

View File

@ -1,5 +1,8 @@
---
- name: INCLUDE_VARS | Related to OS version
include_vars: "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
- name: STAT | Check if mysql exists
stat: path=/etc/init.d/mysql
register: mysql_exists

View File

@ -15,13 +15,17 @@
ignore_errors: yes
register: slave_status
- name: INCLUDE | Transfert /etc/mysql/debian.cnf from master
include: slave/ssh.yml
when: mysql_slave_replicate_mysqldb or ((slave_status.failed is defined or not slave_status.Is_Slave) and mysql_slave_import_data)
- name: INCLUDE | Import data
include: slave/import_data.yml
when: slave_status.failed is defined and mysql_slave_import_data
when: (slave_status.failed is defined or not slave_status.Is_Slave) and mysql_slave_import_data
- name: INCLUDE | Configure replication
include: slave/replication.yml
when: slave_status.failed is defined or mysql_slave_force_setup
when: (slave_status.failed is defined or not slave_status.Is_Slave) or mysql_slave_force_setup
- name: INCLUDE | Transfert /etc/mysql/debian.cnf from master
include: slave/debiancnf.yml

View File

@ -1,7 +1,6 @@
---
# Doc: https://www.percona.com/doc/percona-xtrabackup/2.1/howtos/recipes_ibkx_gtid.html
- name: WAIT_FOR | source data (prevent rsync bug) - TODO find another hack
wait_for: host={{ mysql_slave_import_from }} port=22
@ -26,14 +25,15 @@
- name: SET_FACT | related to mysql datadir
set_fact:
mysql_mysql_datadir: "{{ datadir.msg[0][1] }}"
mysql_binlog_info: "{{ datadir.msg[0][1] }}/xtrabackup_binlog_info"
mysql_mysql_datadir: "{{ datadir.msg }}"
mysql_binlog_info: "{{ datadir.msg }}/xtrabackup_binlog_info"
- name: SERVICE | Stop MySQL before importing data
service: name=mysql state=stopped
# TODO: add an "ignore warning"
- name: COMMAND | Sync backup to slave - TODO remove vagrant as static user (see why mysql_backup_user is not working)
shell: "sudo -E rsync --rsync-path='sudo rsync' -a -e 'ssh -o StrictHostKeyChecking=no' vagrant@{{ mysql_slave_import_from }}:{{ mysql_backup_dir }}/ {{ mysql_mysql_datadir }}/"
shell: "sudo -E rsync --rsync-path='sudo rsync' -a -e 'ssh -o StrictHostKeyChecking=no' {{ mysql_backup_user }}@{{ mysql_slave_import_from }}:{{ mysql_backup_dir }}/ {{ mysql_mysql_datadir }}/"
become: no
- name: FILE | Re-apply owner

View File

@ -20,4 +20,3 @@
- name: MYSQL_REPLICATION | Start slave
mysql_replication: mode=startslave

View File

@ -0,0 +1,19 @@
---
- name: SHELL | Create SSH key if needed on slave
shell: "ssh-keygen -b 2048 -t rsa -f {{ ansible_env.HOME }}/.ssh/id_rsa -q -N ''"
args:
creates: "{{ ansible_env.HOME }}/.ssh/id_rsa"
- name: COMMAND | Get pub key
command: cat {{ ansible_env.HOME }}/.ssh/id_rsa.pub
register: pub_key
changed_when: false
- name: AUTHORIZED_KEY | Auth slave to backup host
authorized_key:
user: "{{ mysql_backup_user }}"
state: present
key: "{{ pub_key.stdout }}"
delegate_to: "{{ mysql_slave_import_from }}"
become: yes

View File

@ -63,9 +63,6 @@ thread_concurrency = {{ mysql_thread_concurrency }}
# InnoDB settings.
innodb_file_per_table = {{ mysql_innodb_file_per_table }}
innodb_buffer_pool_size = {{ mysql_innodb_buffer_pool_size }}
{% if mysql_innodb_additional_mem_pool_size is defined %}
innodb_additional_mem_pool_size = {{ mysql_innodb_additional_mem_pool_size }}
{% endif %}
# It craches after install (mysql 5.5)... TODO FIX -> http://dev.mysql.com/doc/refman/5.6/en/innodb-data-log-reconfiguration.html
#innodb_log_file_size = {{ mysql_innodb_log_file_size }}
#innodb_log_buffer_size = {{ mysql_innodb_log_buffer_size }}

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:
- ../../

View File

@ -0,0 +1,7 @@
mysql_tools:
- mytop
- percona-toolkit
- python-mysqldb
- mysqltuner
mysql_default_xtrabackup_package: 'percona-xtrabackup'

View File

@ -0,0 +1,6 @@
mysql_tools:
- percona-toolkit
- python-mysqldb
- mysqltuner
mysql_default_xtrabackup_package: 'percona-xtrabackup-24'