This commit is contained in:
root 2022-09-04 17:37:33 +02:00
commit 4adbfd4601
2 changed files with 71 additions and 0 deletions

6
files/hws.cnf Normal file
View File

@ -0,0 +1,6 @@
[mysqld]
max_allowed_packet = 1G
max_connections = 500
[mysqldump]
max_allowed_packet = 1G

65
tasks/main.yml Normal file
View File

@ -0,0 +1,65 @@
---
- 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, jessie
tags: apt
apt:
name: "{{ item }}"
state: present
with_items:
- mysql-server
- mysql-client
when:
- ansible_distribution == "Debian"
- ansible_distribution_major_version == "8"
- name: install packages, stretch+
tags: apt
apt:
name: "{{ item }}"
state: present
with_items:
- mariadb-server
- mariadb-client
when:
- ansible_distribution == "Debian"
- ansible_distribution_major_version|int() >= 9
- name: mysql conf
copy:
src: hws.cnf
dest: /etc/mysql/conf.d
- name: is root password set?
stat:
path: /etc/mysql/jelszo
register: mysql_jelszo
- name: pwgen
delegate_to: localhost
command: "pwgen -s 16 1"
register: pwgen
when: 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: 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: not mysql_jelszo.stat.exists
# vim: set tabstop=2 shiftwidth=2 expandtab smarttab: