blob: 18d25ae732b7442fd373332cdba205238971114e (
plain)
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
|
# We run two servers listening different ports
# to be able to check replication (one server for master, another for standby).
- name: Install Repo
yum:
name: '{{ repo_link }}'
- name: Install MySQL community server
yum:
name: '{{ mysql_package_name }}'
- name: Create directories
file:
state: directory
path: "{{ item }}"
owner: mysql
group: mysql
loop:
- "{{ master_datadir }}"
- "{{ standby_datadir }}"
- "{{ standby_logdir }}"
- "{{ default_logdir }}"
- name: Copy cnf templates
template:
src: '{{ item.conf_templ }}'
dest: '{{ item.conf_dest }}'
owner: mysql
group: mysql
force: yes
loop:
- { conf_templ: my-1.cnf.j2, conf_dest: '{{ master_cnf }}' }
- { conf_templ: my-2.cnf.j2, conf_dest: '{{ standby_cnf }}' }
- name: Initialize DBs
shell: 'mysqld --user=mysql --initialize-insecure --datadir={{ item }}'
loop:
- '{{ master_datadir }}'
- '{{ standby_datadir }}'
- name: Start master services
shell: 'mysqld --defaults-file={{ master_cnf }} --user=mysql --datadir={{ master_datadir }} --log-error={{ mysqld_err_log }} &'
- name: Start standby services
shell: 'mysqld --defaults-file={{ standby_cnf }} --user=mysql --datadir={{ standby_datadir }} --log-error={{ mysqld_err_log }} &'
- name: Pause
pause: seconds=3
########### For painful debug uncomment the lines below ##
#- name: DEBUG Check log
# shell: 'cat {{ mysqld_err_log }}'
# ignore_errors: yes
##########################################################
- name: Check connection to the master
shell: 'echo "SHOW DATABASES;" | mysql -P {{ master_port }} -h 127.0.0.1'
- name: Check connection to the standby
shell: "echo \"SHOW VARIABLES LIKE '%version%';\" | mysql -P {{ standby_port }} -h 127.0.0.1"
|