-
Notifications
You must be signed in to change notification settings - Fork 741
/
Copy pathconfigure.yml
68 lines (62 loc) · 1.9 KB
/
configure.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
---
- name: Protect my.cnf
ansible.builtin.file:
path: "{{ mysql_hardening_mysql_conf_file }}"
mode: "0640"
owner: "{{ mysql_cnf_owner }}"
group: "{{ mysql_cnf_group }}"
follow: true
state: file
- name: Ensure permissions on mysql-datadir are correct
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ mysql_hardening_user }}"
group: "{{ mysql_hardening_user }}"
mode: "0750"
when: item is defined and item != ""
loop:
- "{{ mysql_settings.settings.datadir }}"
- '{{ mysql_datadir | default("") }}'
- name: Ensure permissions on mysql-logfile are correct
ansible.builtin.file:
path: "{{ item }}"
state: file
owner: "{{ mysql_hardening_user }}"
group: "{{ mysql_hardening_group }}"
mode: "0640"
when:
- item is defined
- item != ""
- item != "stderr"
- item != "stdout"
loop:
- "{{ mysql_settings.settings.log_error }}"
- '{{ mysql_hardening_log_file | default("") }}'
- name: Check mysql configuration-directory exists and has right permissions
ansible.builtin.file:
path: "{{ mysql_hardening_mysql_confd_dir }}"
state: directory
owner: "{{ mysql_hardening_user }}"
group: "{{ mysql_hardening_group }}"
mode: "0750"
- name: Check include-dir directive is present in my.cnf
ansible.builtin.lineinfile:
dest: "{{ mysql_hardening_mysql_conf_file }}"
line: "!includedir {{ mysql_hardening_mysql_confd_dir }}"
insertafter: EOF
state: present
backup: true
notify: Restart mysql
- name: Apply hardening configuration
ansible.builtin.template:
src: hardening.cnf.j2
dest: "{{ mysql_hardening_mysql_confd_dir + '/hardening.cnf' }}"
owner: "{{ mysql_cnf_owner }}"
group: "{{ mysql_cnf_group }}"
mode: "0640"
notify: Restart mysql
- name: Enable mysql
ansible.builtin.service:
name: "{{ mysql_daemon }}"
enabled: "{{ mysql_daemon_enabled }}"