Minor changes
parent
8d5946e0ad
commit
540a81f0a6
|
@ -5,19 +5,19 @@ IMPORTANT
|
||||||
---------
|
---------
|
||||||
|
|
||||||
- DO NOT `vagrant up`! My Vagrantfile provides many VMs...
|
- DO NOT `vagrant up`! My Vagrantfile provides many VMs...
|
||||||
- Each slave communicate to his master. You can't mix mysql and mariadb.
|
- Each slave communicate to his master.
|
||||||
|
|
||||||
Tests
|
Tests
|
||||||
-----
|
-----
|
||||||
|
|
||||||
- vagrant up the master
|
- vagrant up the-master
|
||||||
- vagrant up the slave
|
- vagrant up the-slave
|
||||||
|
|
||||||
Wait master fully installed before run slave.
|
Wait master fully installed before run slave.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```
|
```
|
||||||
vagrant up buster-upstream-mariadb-master
|
vagrant up vbox-buster-default-master
|
||||||
vagrant up buster-upstream-mariadb-slave
|
vagrant up vbox-buster-default-slave
|
||||||
```
|
```
|
||||||
|
|
|
@ -3,13 +3,16 @@
|
||||||
- hosts: all
|
- hosts: all
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
|
|
||||||
- name: SETUP | Get facts
|
- name: SETUP | Get facts
|
||||||
setup:
|
setup:
|
||||||
register: s
|
register: s
|
||||||
|
|
||||||
- name: DEBUG | Show facts
|
- name: DEBUG | Show facts
|
||||||
debug:
|
debug:
|
||||||
var: s
|
var: s
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: APT | Install some packages
|
- name: APT | Install some packages
|
||||||
apt:
|
apt:
|
||||||
name: "{{ p }}"
|
name: "{{ p }}"
|
||||||
|
@ -22,11 +25,13 @@
|
||||||
roles:
|
roles:
|
||||||
- ../../
|
- ../../
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: COPY | Deploy first dump
|
- name: COPY | Deploy first dump
|
||||||
copy:
|
copy:
|
||||||
src: import1.sql
|
src: import1.sql
|
||||||
dest: /tmp/import1.sql
|
dest: /tmp/import1.sql
|
||||||
register: c
|
register: c
|
||||||
|
|
||||||
- name: MYSQL_DB | Import first dump
|
- name: MYSQL_DB | Import first dump
|
||||||
mysql_db:
|
mysql_db:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
|
@ -37,37 +42,47 @@
|
||||||
|
|
||||||
- hosts: slave
|
- hosts: slave
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
|
|
||||||
- name: SHELL | Get master IP
|
- name: SHELL | Get master IP
|
||||||
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
|
||||||
|
|
||||||
- name: SET_FACT | Apply some configuration
|
- name: SET_FACT | Apply some configuration
|
||||||
set_fact:
|
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'
|
||||||
mariadb_slave_import_from: "{{ ansible_hostname | replace ('slave', 'master') }}"
|
mariadb_slave_import_from: "{{ ansible_hostname | replace ('slave', 'master') }}"
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- ../../
|
- ../../
|
||||||
tasks:
|
tasks:
|
||||||
- name: COPY | Deploy dump
|
|
||||||
copy:
|
- block:
|
||||||
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
|
||||||
|
|
||||||
|
- name: MYSQL_DB | Import another dump
|
||||||
|
mysql_db:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: import
|
||||||
|
target: /tmp/import2.sql
|
||||||
|
loop: ['testrepl', 'norepl']
|
||||||
|
when: c.changed
|
||||||
|
|
||||||
delegate_to: "{{ mariadb_slave_import_from }}"
|
delegate_to: "{{ mariadb_slave_import_from }}"
|
||||||
register: c
|
|
||||||
- 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
|
|
||||||
- name: MYSQL_REPLICATION | Get slave infos
|
- name: MYSQL_REPLICATION | Get slave infos
|
||||||
mysql_replication:
|
mysql_replication:
|
||||||
mode: getslave
|
mode: getslave
|
||||||
register: slave
|
register: slave
|
||||||
|
|
||||||
- name: FAIL | if slave threads are not running
|
- name: FAIL | if slave threads are not running
|
||||||
fail:
|
fail:
|
||||||
msg: "Slave issue"
|
msg: "Slave issue"
|
||||||
|
@ -75,14 +90,12 @@
|
||||||
|
|
||||||
- hosts: galera
|
- hosts: galera
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: SET_FACT | Bypass https://github.com/ansible/ansible/issues/19874
|
|
||||||
set_fact:
|
|
||||||
ansible_distribution_release: 'buster'
|
|
||||||
when: ansible_facts.distribution_major_version == "buster/sid"
|
|
||||||
- name: SET_FACT | Apply some configuration
|
- name: SET_FACT | Apply some configuration
|
||||||
set_fact:
|
set_fact:
|
||||||
mariadb_galera_primary_node: '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-{{ mariadb_origin }}-galera-1'
|
mariadb_galera_primary_node: '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-{{ mariadb_origin }}-galera-1'
|
||||||
mariadb_wsrep_node_address: "{{ '127.0.0.1' if is_docker else ansible_eth1.ipv4.address }}"
|
mariadb_wsrep_node_address: "{{ '127.0.0.1' if is_docker else ansible_eth1.ipv4.address }}"
|
||||||
mariadb_version: '10.3'
|
mariadb_version: '10.3'
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- ../../
|
- ../../
|
||||||
|
|
Loading…
Reference in New Issue