Few improvements(#33)

* README update
* Remove useless legacy files
* Small refactoring for Galera Cluster
* Modern Ansible
* Some changes on travis + Vagrant
* Help debug: display all facts
* Fix galera config for docker
This commit is contained in:
Emilien M
2019-04-16 13:55:38 +02:00
committed by GitHub
parent 1ec3b388a0
commit 1ebc0e9391
20 changed files with 122 additions and 127 deletions

View File

@@ -1,9 +1,11 @@
---
- set_fact:
booboo: "{{ mariadb_datadir }}/.ansible_galera_boostrap"
- name: SET_FACT | Prepare mark var
set_fact:
__mark: "{{ mariadb_datadir }}/.ansible_galera_boostrap"
- name: STAT | Bootstrap mark
stat: path={{ booboo }}
stat:
path: "{{ __mark }}"
register: s
- block:
@@ -12,7 +14,9 @@
mariadb_notify_restart: false
- name: SERVICE | Stop MariaDB
service: name=mysql state=stopped
service:
name: mysql
state: stopped
- name: COMMAND | Bootstrap first node (systemd)
command: galera_new_cluster
@@ -29,6 +33,6 @@
when: not s.stat.exists or mariadb_galera_resetup
- name: COMMAND | Create Bootstrap mark
command: "touch {{ booboo }}"
command: "touch {{ __mark }}"
args:
creates: "{{ booboo }}"
creates: "{{ __mark }}"

View File

@@ -7,18 +7,18 @@
register: galeraconfig
- name: INCLUDE | Bootstrap first node
include: 'bootstrap.yml'
import_tasks: 'bootstrap.yml'
when: inventory_hostname == mariadb_galera_primary_node
- name: INCLUDE | Configure other nodes
include: 'nodes.yml'
import_tasks: 'nodes.yml'
when: inventory_hostname != mariadb_galera_primary_node
- name: SERVICE | Restart MariaDB if needed
service:
name: mysql
state: restarted
when: >
when:
((galeraconfig or (p is defined and p.changed)) and
(bootstrap_run is not defined)) or
((inventory_hostname != mariadb_galera_primary_node) and

View File

@@ -1,17 +1,16 @@
---
- name: INCLUDE | Use Percona repository
include: 'percona/apt.yml'
- name: INCLUDE | Setup Percona repository
import_tasks: 'percona/apt.yml'
when: mariadb_use_percona_apt
- name: INCLUDE | Install MariaDB from Debian repo
include: 'mariadb/default.yml'
when: mariadb_origin == 'default' and mariadb_vendor == 'mariadb'
- name: INCLUDE | Install MariaDB from MariaDB repo
include: 'mariadb/upstream.yml'
- name: INCLUDE | Setup MariaDB repository
import_tasks: 'mariadb/upstream.yml'
when: mariadb_origin == 'upstream'
- name: INCLUDE | Install MariaDB
import_tasks: 'mariadb/default.yml'
- name: APT | Install few MariaDB related tools
apt:
pkg: "{{ mariadb_tools }}"

View File

@@ -28,4 +28,4 @@
- name: APT | Install Galera
apt:
pkg: galera-3
when: mariadb_vendor == 'mariadb_galera'
when: mariadb_use_galera

View File

@@ -19,6 +19,3 @@
apt_repository:
repo: 'deb-src {{ mariadb_repository }} {{ ansible_distribution_release }} main'
when: mariadb_upstream_apt_src
- name: INCLUDE | Normal Install
include: default.yml

View File

@@ -10,7 +10,7 @@
changed_when: false
- name: INCLUDE | Install
include: install/main.yml
import_tasks: install/main.yml
- name: TEMPLATE | Deploy configuration
template:
@@ -28,7 +28,7 @@
service:
name: mysql
state: restarted
when: >
when:
(config.changed or extraconfig.changed) and
not mariadb_galera_resetup
@@ -42,15 +42,15 @@
backup: yes
- name: INCLUDE | Galera
include: galera/main.yml
when: mariadb_vendor == 'mariadb_galera'
import_tasks: galera/main.yml
when: mariadb_use_galera
- name: INCLUDE | Replication
include: replication/main.yml
import_tasks: replication/main.yml
when: mariadb_replication_master or mariadb_replication_slave
- name: INCLUDE | Secure install
include: 'secure.yml'
import_tasks: 'secure.yml'
- name: SERVICE | Ensure service is started
service:

View File

@@ -1,9 +1,9 @@
---
- name: INCLUDE | Replication Master
include: master.yml
import_tasks: master.yml
when: mariadb_replication_master
- name: INCLUDE | Replication slave
include: slave.yml
import_tasks: slave.yml
when: mariadb_replication_slave

View File

@@ -19,19 +19,19 @@
register: slave_status
- name: INCLUDE | Transfert /etc/mysql/debian.cnf from master
include: slave/ssh.yml
import_tasks: slave/ssh.yml
when: mariadb_slave_replicate_mysqldb or ((slave_status.failed is defined or not slave_status.Is_Slave) and mariadb_slave_import_data)
- name: INCLUDE | Import data
include: slave/import_data.yml
import_tasks: slave/import_data.yml
when: (slave_status.failed is defined or not slave_status.Is_Slave) and mariadb_slave_import_data
- name: INCLUDE | Configure replication
include: slave/replication.yml
import_tasks: slave/replication.yml
when: (slave_status.failed is defined or not slave_status.Is_Slave) or mariadb_slave_force_setup
- name: INCLUDE | Transfert /etc/mysql/debian.cnf from master
include: slave/debiancnf.yml
import_tasks: slave/debiancnf.yml
when: mariadb_slave_replicate_mysqldb
- name: MYSQL_REPLICATION | Get slave status
@@ -41,4 +41,4 @@
register: slave_status
- name: Configure GTID
include: slave/gtid.yml
import_tasks: slave/gtid.yml

View File

@@ -9,7 +9,10 @@
delegate_to: "{{ mariadb_slave_import_from }}"
- name: LOCAL_ACTION FILE | Secure fetched file
local_action: file path=/tmp/{{ mariadb_slave_import_from }}/debian.cnf mode=0600
local_action:
module: file
path: "/tmp/{{ mariadb_slave_import_from }}/debian.cnf"
mode: 0600
become: no
- name: COPY | Fetched file to /etc/mysql/debian.cnf

View File

@@ -7,7 +7,9 @@
port: 22
- name: COMMAND | Prepare backup another server
command: innobackupex --no-timestamp {{ mariadb_backup_dir }} creates={{ mariadb_backup_dir }}
command: innobackupex --no-timestamp {{ mariadb_backup_dir }}
args:
creates: "{{ mariadb_backup_dir }}"
delegate_to: "{{ mariadb_slave_import_from }}"
register: backup
@@ -24,7 +26,8 @@
when: backup.changed and not mariadb_slave_replicate_mysqldb
- name: MYSQL_VARIABLES | Get datadir
mysql_variables: variable=datadir
mysql_variables:
variable: datadir
register: datadir
- name: SET_FACT | related to mysql datadir
@@ -74,6 +77,8 @@
mariadb_master_gtid: "{{ master_gtid.stdout }}"
- name: FILE | Delete dump
file: path={{ mariadb_backup_dir }} state=absent
file:
path: "{{ mariadb_backup_dir }}"
state: absent
delegate_to: "{{ mariadb_slave_import_from }}"
when: mariadb_slave_import_flush_dump