2015-07-12 17:15:59 +07:00
|
|
|
---
|
|
|
|
|
2015-08-11 15:22:58 +07:00
|
|
|
- hosts: all
|
|
|
|
tasks:
|
|
|
|
- apt: pkg={{ item }} state=present update_cache=yes cache_valid_time=3600
|
|
|
|
with_items:
|
2017-06-28 21:15:44 +07:00
|
|
|
- ca-certificates
|
|
|
|
- curl
|
2015-08-11 15:22:58 +07:00
|
|
|
- strace
|
|
|
|
- vim
|
2015-08-09 02:34:17 +07:00
|
|
|
|
2015-08-11 15:22:58 +07:00
|
|
|
- hosts: master
|
2015-08-09 02:34:17 +07:00
|
|
|
roles:
|
|
|
|
- ../../
|
2015-08-11 15:22:58 +07:00
|
|
|
tasks:
|
|
|
|
- copy: src=import1.sql dest=/tmp/import1.sql
|
|
|
|
register: c
|
|
|
|
- mysql_db: name={{ item }} state=import target=/tmp/import1.sql
|
|
|
|
with_items: ['testrepl', 'norepl']
|
|
|
|
when: c.changed
|
2015-08-09 02:34:17 +07:00
|
|
|
|
2015-08-11 15:22:58 +07:00
|
|
|
- hosts: slave
|
2017-06-28 21:15:44 +07:00
|
|
|
pre_tasks:
|
|
|
|
- name: SHELL | Get master IP
|
|
|
|
shell: getent hosts {{ ansible_hostname | replace ('slave', 'master') }} | cut -d ' ' -f 1
|
|
|
|
register: ip
|
|
|
|
changed_when: false
|
|
|
|
- set_fact:
|
|
|
|
# MySQL don't read /etc/hosts (from vagrant host plugin)
|
|
|
|
mysql_replication_host: "{{ ip.stdout }}"
|
|
|
|
# Need this to use vagrant 'delegate_to'
|
|
|
|
mysql_slave_import_from: "{{ ansible_hostname | replace ('slave', 'master') }}"
|
2015-08-09 02:34:17 +07:00
|
|
|
roles:
|
|
|
|
- ../../
|
2015-08-11 15:22:58 +07:00
|
|
|
tasks:
|
|
|
|
- copy: src=import2.sql dest=/tmp/import2.sql
|
2017-06-28 21:15:44 +07:00
|
|
|
delegate_to: "{{ mysql_slave_import_from }}"
|
2015-08-11 15:22:58 +07:00
|
|
|
register: c
|
|
|
|
- mysql_db: name={{ item }} state=import target=/tmp/import2.sql
|
|
|
|
with_items: ['testrepl', 'norepl']
|
2017-06-28 21:15:44 +07:00
|
|
|
delegate_to: "{{ mysql_slave_import_from }}"
|
2015-08-11 15:22:58 +07:00
|
|
|
when: c.changed
|
2017-06-28 21:15:44 +07:00
|
|
|
- mysql_replication: mode=getslave
|
|
|
|
register: slave
|
|
|
|
- fail: msg="Slave issue"
|
|
|
|
when: slave.Slave_IO_Running != 'Yes' or slave.Slave_SQL_Running != 'Yes'
|
2015-08-09 02:34:17 +07:00
|
|
|
|
2016-09-23 16:40:35 +07:00
|
|
|
- hosts: mariadbgalera
|
2016-09-23 22:03:13 +07:00
|
|
|
vars:
|
2017-06-28 21:15:44 +07:00
|
|
|
mysql_galera_primary_node: '{% if is_docker %}docker-{% else %}vbox-{% endif %}{{ ansible_distribution_release }}-upstream-mariadbgalera-1'
|
|
|
|
mysql_wsrep_node_address: "{{ ansible_all_ipv4_addresses[0] }}"
|
2017-06-28 22:43:35 +07:00
|
|
|
mysql_mariadb_version: '10.1'
|
2017-06-28 21:15:44 +07:00
|
|
|
pre_tasks:
|
|
|
|
- set_fact:
|
|
|
|
mysql_wsrep_node_address: "{{ ansible_eth1.ipv4.address }}"
|
|
|
|
when: not is_docker
|
2016-09-23 16:40:35 +07:00
|
|
|
roles:
|
|
|
|
- ../../
|
|
|
|
|