-
Notifications
You must be signed in to change notification settings - Fork 0
/
droid.yml
74 lines (72 loc) · 2.94 KB
/
droid.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
description: "Configure MySQL Server for Binary Log Replication"
variables:
use_legacy_templating: true
module_mysql_repln:
binary_log_path: "/var/log/mysql/mysql-bin.log"
tasks:
-
name: "Copy replication master configuration to the master"
command: "fs:copy"
sudo: true
arguments:
src: "!{{ mod_path}}/assets/mysqld_repln_master.cnf.template"
dest: "/etc/mysql/conf.d/mysqld_repln_master.cnf"
host_filter: "host.variables['replication_role'] == 'master'"
-
name: "Copy replication slave configuration to the slave"
command: "fs:copy"
sudo: true
arguments:
src: "!{{ mod_path}}/assets/mysqld_repln_slave.cnf.template"
dest: "/etc/mysql/conf.d/mysqld_repln_slave.cnf"
host_filter: "host.variables['replication_role'] == 'slave'"
-
name: "Create a MySQL user account for replication"
command: "mysql:adduser"
arguments:
url: "mysql://root:{{{ passwords.mysql.root }}}@localhost/"
username: "repln"
password: "{{{ passwords.mysql.repln }}}"
allowed-host: "%"
grant: "REPLICATION SLAVE"
grant-level: "*.*"
host_filter: "host.variables['replication_role'] == 'master'"
-
name: "Configure the slave with information about its master"
command: "mysql:master-info"
arguments:
url: "mysql://root:{{{ passwords.mysql.root }}}@localhost/"
master_hostname: "{{{ host.variables.replication_master_host }}}"
replication_username: "repln"
replication_password: "{{{ passwords.mysql.repln }}}"
host_filter: "host.variables['replication_role'] == 'slave'"
-
name: "Restart the slave MySQL service"
command: "service:restart"
sudo: true
arguments:
name: "mysql"
host_filter: "host.variables['replication_role'] == 'slave'"
-
name: "Restart the master MySQL service to allow replication to commence"
command: "service:restart"
sudo: true
arguments:
name: "mysql"
host_filter: "host.variables['replication_role'] == 'master'"
-
name: "Copy data to the master"
command: "fs:copy"
arguments:
src: "!{{{ host.variables.initial_data_path }}}"
dest: "/tmp/db-{{{ host.variables.initial_data_dbname }}}.sql"
host_filter: "(host.variables['replication_role'] == 'master') && host.variables['initial_data_path'] && host.variables['initial_data_dbname']"
-
name: "Load data into the master"
command: "mysql:load"
arguments:
url: "mysql://root:{{{ passwords.mysql.root }}}@localhost/{{{ host.variables.initial_data_dbname }}}"
source: "/tmp/db-{{{ host.variables.initial_data_dbname }}}.sql"
create: ~
gzip: ~
host_filter: "(host.variables['replication_role'] == 'master') && host.variables['initial_data_path'] && host.variables['initial_data_dbname']"