108 lines
2.8 KiB
YAML
108 lines
2.8 KiB
YAML
---
|
|
- name: /var/lib/mysql bind mount in fstab
|
|
lineinfile:
|
|
dest: /etc/fstab
|
|
line: '/data/mysql /var/lib/mysql none bind 0 0'
|
|
register: fstab_mysql
|
|
|
|
- name: mount /var/lib/mysql
|
|
shell: 'mkdir -p /var/lib/mysql && mv /var/lib/mysql /data && mkdir -p /var/lib/mysql && mount /var/lib/mysql'
|
|
when: fstab_mysql.changed
|
|
|
|
- name: install packages, debian8
|
|
tags: apt
|
|
apt:
|
|
name:
|
|
- mysql-server
|
|
- mysql-client
|
|
state: present
|
|
when:
|
|
- ansible_distribution == "Debian"
|
|
- ansible_distribution_major_version == "8"
|
|
|
|
- name: install packages, debian9-99 ubuntu20-99
|
|
tags: apt
|
|
apt:
|
|
name:
|
|
- mariadb-server
|
|
- mariadb-client
|
|
state: present
|
|
when:
|
|
- (ansible_distribution == "Debian" and ansible_distribution_major_version|int() >= 9) or
|
|
(ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int() >= 20)
|
|
|
|
- name: install packages, rhel9
|
|
tags: dnf
|
|
dnf:
|
|
name:
|
|
- mysql-server
|
|
- mysql
|
|
state: present
|
|
when:
|
|
- (ansible_distribution == "RedHat" and ansible_distribution_major_version|int() == 9) or
|
|
(ansible_distribution == "AlmaLinux" and ansible_distribution_major_version|int() == 9)
|
|
|
|
- name: install packages, rhel10-99
|
|
tags: dnf
|
|
dnf:
|
|
name:
|
|
- mysql8.4-server
|
|
- mysql8.4
|
|
state: present
|
|
when:
|
|
- ansible_distribution == "RedHat" and ansible_distribution_major_version|int() >= 10
|
|
|
|
- name: enable mysqld service
|
|
systemd_service:
|
|
name: mysqld
|
|
enabled: true
|
|
|
|
- name: mysql conf (debian)
|
|
copy:
|
|
src: hws.cnf
|
|
dest: /etc/mysql/conf.d
|
|
when:
|
|
- (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
|
|
|
|
- name: mysql conf (redhat)
|
|
copy:
|
|
src: hws.cnf
|
|
dest: /etc/my.cnf.d/ZZ_hws.cnf
|
|
when:
|
|
- ansible_distribution == "RedHat" or ansible_distribution == "AlmaLinux"
|
|
|
|
# root jelszo csak regi borderekhez kellett
|
|
|
|
- name: is root password set?
|
|
stat:
|
|
path: /etc/mysql/jelszo
|
|
register: mysql_jelszo
|
|
when:
|
|
- (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
|
|
|
|
- name: pwgen
|
|
delegate_to: localhost
|
|
command: "pwgen -s 16 1"
|
|
register: pwgen
|
|
when:
|
|
- (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
|
|
- not mysql_jelszo.stat.exists
|
|
|
|
- name: write mysql root passwd to file
|
|
copy:
|
|
content: "{{ mysql_root | default(pwgen.stdout) }}\n"
|
|
dest: /etc/mysql/jelszo
|
|
mode: "0400"
|
|
when:
|
|
- (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
|
|
- not mysql_jelszo.stat.exists
|
|
|
|
- name: set mysql root passwd
|
|
shell: "echo \"SET PASSWORD FOR 'root'@'localhost' = PASSWORD('{{ mysql_root | default(pwgen.stdout) }}');\" | mysql -u root"
|
|
when:
|
|
- (ansible_distribution == "Debian" or ansible_distribution == "Ubuntu")
|
|
- not mysql_jelszo.stat.exists
|
|
|
|
|
|
# vim: set tabstop=2 shiftwidth=2 expandtab smarttab:
|