-
Notifications
You must be signed in to change notification settings - Fork 8
/
mysql.yml
69 lines (59 loc) · 1.97 KB
/
mysql.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
---
- hosts: all
become: True
tasks:
- name: Install Percona Repo
yum:
name: https://repo.percona.com/yum/percona-release-latest.noarch.rpm
state: present
- name: Install Percona Server
yum:
name: [ Percona-Server-server-57.x86_64, vim ]
state: present
- name: Enable binlogs
ini_file:
path: /etc/my.cnf
section: mysqld
option: log_bin
value: mysql-bin
- name: Change server_id
ini_file:
path: /etc/my.cnf
section: mysqld
option: server_id
value: "{{ ['10','20','30']|random }}"
- name: Change binlog format
ini_file:
path: /etc/my.cnf
section: mysqld
option: binlog_format
value: row
- name: start mysql
service:
name: mysql
state: restarted
enabled: yes
- name: Wait for MySQL
pause:
seconds=20
- name: Change mysql root password and keep track in
shell: |
password_match=`awk '/A temporary password is generated for/ {a=$0} END{ print a }' /var/log/mysqld.log | awk '{print $(NF)}'`
echo $password_match
mysql -uroot -p$password_match --connect-expired-password -e "SET SESSION sql_log_bin=0; SET GLOBAL validate_password_policy = 0; SET GLOBAL validate_password_length = 6; SET GLOBAL validate_password_number_count = 0; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'cocacola'; flush privileges; "
sudo echo -e "[client]\nuser=root\npassword=cocacola" > /root/.my.cnf
args:
creates: /root/.my.cnf
register: change_temp_pass
- meta: flush_handlers
- debug:
var: change_temp_pass
- name: Disable SELinux
shell: |
sudo setenforce 0
# handlers:
# - name: start mysql
# service:
# name: mysql
# state: restarted
# enabled: yes