/
setup-Debian.yml
42 lines (37 loc) · 1.24 KB
/
setup-Debian.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
---
- name: Check if MySQL is already installed.
ansible.builtin.stat:
path: "{{ mysql_config_file }}"
register: mysql_installed
- name: Update apt cache if MySQL is not yet installed.
ansible.builtin.apt:
update_cache: yes
changed_when: False
when: not mysql_installed.stat.exists
- name: Ensure MySQL Python libraries are installed.
ansible.builtin.apt:
name: "{{ mysql_python_package_debian }}"
state: present
- name: Ensure MySQL packages are installed.
ansible.builtin.apt:
name: "{{ mysql_packages }}"
state: present
policy_rc_d: 101
register: deb_mysql_install_packages
# Because Ubuntu starts MySQL as part of the install process, we need to stop
# mysql and remove the logfiles in case the user set a custom log file size.
- name: Ensure MySQL is stopped after initial install.
ansible.builtin.service:
name: "{{ mysql_daemon }}"
state: stopped
when: not mysql_installed.stat.exists
- name: Delete innodb log files created by apt package after initial install.
ansible.builtin.file:
path: "{{ mysql_datadir }}/{{ item }}"
state: absent
with_items:
- ib_logfile0
- ib_logfile1
when: >
not mysql_installed.stat.exists
and ansible_distribution_major_version | int < 12