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

@@ -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