setup-cockpit/roles/mariadb/tasks/main.yml

32 lines
731 B
YAML

---
- name: Install mariadb (Archlinux)
become: true
pacman:
name:
- mariadb
when: ansible_distribution == 'Archlinux'
- name: Install mariadb (Debian)
become: true
apt:
name:
- mariadb
when: ansible_distribution == 'Debian'
- name: Initialize mariadb
become: true
command: mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
register: result
changed_when: "'table already exists!' not in result.stdout"
notify: Start mysqld service
- name: Secure the installation
become: true
command: mysql_secure_installation
when: "'table already exists!' not in result.stdout"
- name: Stop mysqld service
systemd:
name: mysqld
state: stopped
scope: system