-
-
Notifications
You must be signed in to change notification settings - Fork 588
Expand file tree
/
Copy pathmain.yml
More file actions
88 lines (78 loc) · 2.2 KB
/
Copy pathmain.yml
File metadata and controls
88 lines (78 loc) · 2.2 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
83
84
85
86
87
88
---
- name: Add an Apt signing key, uses whichever key is at the URL
ansible.builtin.apt_key:
url: "https://mariadb.org/mariadb_release_signing_key.asc"
state: present
- name: Add MariaDB PPA
deb822_repository:
repo: "{{ mariadb_ppa }}"
update_cache: yes
register: result
until: result is success
retries: 3
delay: 5
- name: Install MySQL client
ansible.builtin.apt:
name: "{{ mariadb_client_package }}"
state: "{{ mariadb_client_package_state | default(apt_package_state) }}"
update_cache: true
- block:
- name: Install MySQL server
ansible.builtin.apt:
name: "{{ mariadb_server_package }}"
state: "{{ mariadb_server_package_state | default(apt_package_state) }}"
cache_valid_time: "{{ apt_cache_valid_time }}"
- name: Disable MariaDB binary logging
template:
src: disable-binary-logging.cnf
dest: /etc/mysql/conf.d
owner: root
group: root
mode: '0644'
when: mysql_binary_logging_disabled | bool
notify: restart mysql server
- name: Copy .my.cnf file with root password credentials.
template:
src: my.cnf.j2
dest: ~/.my.cnf
owner: root
group: root
mode: '0600'
- name: Copy server config file with MariaDB optimisations.
template:
src: 50-server.cnf.j2
dest: /etc/mysql/mariadb.conf.d/50-server.cnf
mode: '0644'
notify: restart mysql server
- name: Set root user password
mysql_user:
name: root
host: "{{ item }}"
password: "{{ mysql_root_password }}"
check_implicit_admin: yes
column_case_sensitive: no
state: present
login_unix_socket: /var/run/mysqld/mysqld.sock
no_log: true
loop:
- "{{ inventory_hostname }}"
- 127.0.0.1
- ::1
- localhost
- name: Delete anonymous MySQL server users
mysql_user:
name: ""
host: "{{ item }}"
state: absent
column_case_sensitive: no
no_log: true
loop:
- localhost
- "{{ inventory_hostname }}"
- "{{ ansible_hostname }}"
- name: Remove the test database
mysql_db:
name: test
state: absent
no_log: true
when: (wordpress_sites.items() | count) > (sites_using_remote_db | count)