Few improvements
parent
1ec3b388a0
commit
f92a79f122
|
@ -1,9 +1,11 @@
|
||||||
---
|
---
|
||||||
- set_fact:
|
- name: SET_FACT | Prepare mark var
|
||||||
booboo: "{{ mariadb_datadir }}/.ansible_galera_boostrap"
|
set_fact:
|
||||||
|
__mark: "{{ mariadb_datadir }}/.ansible_galera_boostrap"
|
||||||
|
|
||||||
- name: STAT | Bootstrap mark
|
- name: STAT | Bootstrap mark
|
||||||
stat: path={{ booboo }}
|
stat:
|
||||||
|
path: "{{ __mark }}"
|
||||||
register: s
|
register: s
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
@ -12,7 +14,9 @@
|
||||||
mariadb_notify_restart: false
|
mariadb_notify_restart: false
|
||||||
|
|
||||||
- name: SERVICE | Stop MariaDB
|
- name: SERVICE | Stop MariaDB
|
||||||
service: name=mysql state=stopped
|
service:
|
||||||
|
name: mysql
|
||||||
|
state: stopped
|
||||||
|
|
||||||
- name: COMMAND | Bootstrap first node (systemd)
|
- name: COMMAND | Bootstrap first node (systemd)
|
||||||
command: galera_new_cluster
|
command: galera_new_cluster
|
||||||
|
@ -29,6 +33,6 @@
|
||||||
when: not s.stat.exists or mariadb_galera_resetup
|
when: not s.stat.exists or mariadb_galera_resetup
|
||||||
|
|
||||||
- name: COMMAND | Create Bootstrap mark
|
- name: COMMAND | Create Bootstrap mark
|
||||||
command: "touch {{ booboo }}"
|
command: "touch {{ __mark }}"
|
||||||
args:
|
args:
|
||||||
creates: "{{ booboo }}"
|
creates: "{{ __mark }}"
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
service:
|
service:
|
||||||
name: mysql
|
name: mysql
|
||||||
state: restarted
|
state: restarted
|
||||||
when: >
|
when:
|
||||||
((galeraconfig or (p is defined and p.changed)) and
|
((galeraconfig or (p is defined and p.changed)) and
|
||||||
(bootstrap_run is not defined)) or
|
(bootstrap_run is not defined)) or
|
||||||
((inventory_hostname != mariadb_galera_primary_node) and
|
((inventory_hostname != mariadb_galera_primary_node) and
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
service:
|
service:
|
||||||
name: mysql
|
name: mysql
|
||||||
state: restarted
|
state: restarted
|
||||||
when: >
|
when:
|
||||||
(config.changed or extraconfig.changed) and
|
(config.changed or extraconfig.changed) and
|
||||||
not mariadb_galera_resetup
|
not mariadb_galera_resetup
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,10 @@
|
||||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||||
|
|
||||||
- name: LOCAL_ACTION FILE | Secure fetched file
|
- 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
|
become: no
|
||||||
|
|
||||||
- name: COPY | Fetched file to /etc/mysql/debian.cnf
|
- name: COPY | Fetched file to /etc/mysql/debian.cnf
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
port: 22
|
port: 22
|
||||||
|
|
||||||
- name: COMMAND | Prepare backup another server
|
- 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 }}"
|
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||||
register: backup
|
register: backup
|
||||||
|
|
||||||
|
@ -24,7 +26,8 @@
|
||||||
when: backup.changed and not mariadb_slave_replicate_mysqldb
|
when: backup.changed and not mariadb_slave_replicate_mysqldb
|
||||||
|
|
||||||
- name: MYSQL_VARIABLES | Get datadir
|
- name: MYSQL_VARIABLES | Get datadir
|
||||||
mysql_variables: variable=datadir
|
mysql_variables:
|
||||||
|
variable: datadir
|
||||||
register: datadir
|
register: datadir
|
||||||
|
|
||||||
- name: SET_FACT | related to mysql datadir
|
- name: SET_FACT | related to mysql datadir
|
||||||
|
@ -74,6 +77,8 @@
|
||||||
mariadb_master_gtid: "{{ master_gtid.stdout }}"
|
mariadb_master_gtid: "{{ master_gtid.stdout }}"
|
||||||
|
|
||||||
- name: FILE | Delete dump
|
- name: FILE | Delete dump
|
||||||
file: path={{ mariadb_backup_dir }} state=absent
|
file:
|
||||||
|
path: "{{ mariadb_backup_dir }}"
|
||||||
|
state: absent
|
||||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||||
when: mariadb_slave_import_flush_dump
|
when: mariadb_slave_import_flush_dump
|
||||||
|
|
|
@ -2,20 +2,28 @@
|
||||||
|
|
||||||
- hosts: all
|
- hosts: all
|
||||||
tasks:
|
tasks:
|
||||||
- apt: pkg={{ item }} state=present update_cache=yes cache_valid_time=3600
|
- name: APT | Install some packages
|
||||||
loop:
|
apt:
|
||||||
- ca-certificates
|
name: "{{ p }}"
|
||||||
- curl
|
update_cache: yes
|
||||||
- strace
|
cache_valid_time: 3600
|
||||||
- vim
|
vars:
|
||||||
|
p: ['ca-certificates', 'curl', 'strace', 'vim']
|
||||||
|
|
||||||
- hosts: master
|
- hosts: master
|
||||||
roles:
|
roles:
|
||||||
- ../../
|
- ../../
|
||||||
tasks:
|
tasks:
|
||||||
- copy: src=import1.sql dest=/tmp/import1.sql
|
- name: COPY | Deploy first dump
|
||||||
|
copy:
|
||||||
|
src: import1.sql
|
||||||
|
dest: /tmp/import1.sql
|
||||||
register: c
|
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']
|
loop: ['testrepl', 'norepl']
|
||||||
when: c.changed
|
when: c.changed
|
||||||
|
|
||||||
|
@ -25,7 +33,8 @@
|
||||||
shell: getent hosts {{ ansible_hostname | replace ('slave', 'master') }} | cut -d ' ' -f 1
|
shell: getent hosts {{ ansible_hostname | replace ('slave', 'master') }} | cut -d ' ' -f 1
|
||||||
register: ip
|
register: ip
|
||||||
changed_when: false
|
changed_when: false
|
||||||
- set_fact:
|
- name: SET_FACT | Apply some configuration
|
||||||
|
set_fact:
|
||||||
# MariaDB don't read /etc/hosts (from vagrant host plugin)
|
# MariaDB don't read /etc/hosts (from vagrant host plugin)
|
||||||
mariadb_replication_host: "{{ ip.stdout }}"
|
mariadb_replication_host: "{{ ip.stdout }}"
|
||||||
# Need this to use vagrant 'delegate_to'
|
# Need this to use vagrant 'delegate_to'
|
||||||
|
@ -33,16 +42,27 @@
|
||||||
roles:
|
roles:
|
||||||
- ../../
|
- ../../
|
||||||
tasks:
|
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 }}"
|
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||||
register: c
|
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']
|
loop: ['testrepl', 'norepl']
|
||||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||||
when: c.changed
|
when: c.changed
|
||||||
- mysql_replication: mode=getslave
|
- name: MYSQL_REPLICATION | Get slave infos
|
||||||
|
mysql_replication:
|
||||||
|
mode: getslave
|
||||||
register: slave
|
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'
|
when: slave.Slave_IO_Running != 'Yes' or slave.Slave_SQL_Running != 'Yes'
|
||||||
|
|
||||||
- hosts: mariadbgalera
|
- hosts: mariadbgalera
|
||||||
|
|
Loading…
Reference in New Issue