-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmysql_playbook.yml
57 lines (46 loc) · 1.24 KB
/
mysql_playbook.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
---
- name: Download MySQL Community repositori
get_url:
url: http://repo.mysql.com/mysql-community-release-el7-7.noarch.rpm
dest: /tmp
#- name: Install MySQL Community repositori
# command: /usr/bin/rpm -ivh /tmp/mysql-community-release-el7-7.noarch.rpm
- name: Install MySQL Server
yum:
name: mysql-server
state: present
- name: generate password root mysql
command: openssl rand -hex 7 creates=/root/.my.cnf
register: mysql_new_root_password
- name: tampilkan hasil generate password mysql
debug:
msg: password baru root mysql adalah "{{ mysql_new_root_password.stdout }}"
when: mysql_new_root_password.changed
- name: Install MySQL-Python (untuk remove anonymous user)
yum:
name: MySQL-python
state: present
- name: start and enable mysql-server
systemd:
name: mysqld
state: started
enabled: true
- name: rubah root password
mysql_user:
name: root
host: "{{ item }}"
password: "{{ root_db_password }}"
with_items:
- "{{ ansible_hostname }}"
- 127.0.0.1
- ::1
- localhost
- name: Remove test database jika ada
mysql_db:
name: test
state: absent
- name: Remove semua anonymous user mysql
mysql_user:
name: ''
host_all: yes
state: absent