-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmysql.yml
More file actions
82 lines (70 loc) · 2.13 KB
/
Copy pathmysql.yml
File metadata and controls
82 lines (70 loc) · 2.13 KB
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
75
76
77
78
79
80
81
82
---
- hosts: all
become: True
tasks:
- name: install percona key
rpm_key:
key: https://downloads.percona.com/downloads/RPM-GPG-KEY-percona
state: present
- name: Install Percona Repo
yum:
name: https://repo.percona.com/yum/percona-release-latest.noarch.rpm
state: present
disable_gpg_check: yes
- name: Enable Repo
shell: "/usr/bin/percona-release setup ps-80"
- name: Install Percona Server
yum:
name: [ percona-server-server, 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 "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Cocacola+1'; flush privileges; "
sudo echo -e "[client]\nuser=root\npassword=Cocacola+1" > /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
- name: Disable firewall
service:
name: firewalld
state: stopped
# handlers:
# - name: start mysql
# service:
# name: mysql
# state: restarted
# enabled: yes