mirror of
https://github.com/HanXHX/ansible-mysql.git
synced 2026-04-21 14:42:09 +07:00
Few improvements
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user