Few improvements

pull/33/head
Emilien Mantel 2019-04-12 11:14:39 +02:00
parent 1ec3b388a0
commit f92a79f122
6 changed files with 57 additions and 25 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

@ -18,7 +18,7 @@
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

@ -28,7 +28,7 @@
service:
name: mysql
state: restarted
when: >
when:
(config.changed or extraconfig.changed) and
not mariadb_galera_resetup

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

View File

@ -2,20 +2,28 @@
- hosts: all
tasks:
- apt: pkg={{ item }} state=present update_cache=yes cache_valid_time=3600
loop:
- ca-certificates
- curl
- strace
- vim
- name: APT | Install some packages
apt:
name: "{{ p }}"
update_cache: yes
cache_valid_time: 3600
vars:
p: ['ca-certificates', 'curl', 'strace', 'vim']
- hosts: master
roles:
- ../../
tasks:
- copy: src=import1.sql dest=/tmp/import1.sql
- name: COPY | Deploy first dump
copy:
src: import1.sql
dest: /tmp/import1.sql
register: c
- mysql_db: name={{ item }} state=import target=/tmp/import1.sql
- name: MYSQL_DB | Import first dump
mysql_db:
name: "{{ item }}"
state: import
target: /tmp/import1.sql
loop: ['testrepl', 'norepl']
when: c.changed
@ -25,7 +33,8 @@
shell: getent hosts {{ ansible_hostname | replace ('slave', 'master') }} | cut -d ' ' -f 1
register: ip
changed_when: false
- set_fact:
- name: SET_FACT | Apply some configuration
set_fact:
# MariaDB don't read /etc/hosts (from vagrant host plugin)
mariadb_replication_host: "{{ ip.stdout }}"
# Need this to use vagrant 'delegate_to'
@ -33,16 +42,27 @@
roles:
- ../../
tasks:
- copy: src=import2.sql dest=/tmp/import2.sql
- name: COPY | Deploy dump
copy:
src: import2.sql
dest: /tmp/import2.sql
delegate_to: "{{ mariadb_slave_import_from }}"
register: c
- mysql_db: name={{ item }} state=import target=/tmp/import2.sql
- name: MYSQL_DB | Import another dump
mysql_db:
name: "{{ item }}"
state: import
target: /tmp/import2.sql
loop: ['testrepl', 'norepl']
delegate_to: "{{ mariadb_slave_import_from }}"
when: c.changed
- mysql_replication: mode=getslave
- name: MYSQL_REPLICATION | Get slave infos
mysql_replication:
mode: getslave
register: slave
- fail: msg="Slave issue"
- name: FAIL | if slave threads are not running
fail:
msg: "Slave issue"
when: slave.Slave_IO_Running != 'Yes' or slave.Slave_SQL_Running != 'Yes'
- hosts: mariadbgalera