Add mariadb role
This commit is contained in:
parent
36b8ff05c8
commit
500789c3c3
5 changed files with 42 additions and 7 deletions
|
@ -11,13 +11,6 @@ etckeeper:
|
|||
- run:
|
||||
- sudo etckeeper commit "First commit"
|
||||
|
||||
mariadb:
|
||||
- install:
|
||||
- mariadb
|
||||
- run:
|
||||
command: sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql && sudo systemctl start mysqld.service && sudo mysql_secure_installation
|
||||
condition: "sudo find /var/lib/mysql -mindepth 1 | read"
|
||||
|
||||
rsync_backup:
|
||||
- run:
|
||||
- sudo ln -rsi dotfiles/systemd/rsync_backup.timer /etc/systemd/system/rsync_backup.timer
|
||||
|
|
|
@ -27,3 +27,4 @@
|
|||
- { role: protonvpn, tags: protonvpn }
|
||||
- { role: repos, tags: repos }
|
||||
- { role: libvirt, tags: libvirt }
|
||||
- { role: mariadb, tags: mariadb }
|
||||
|
|
6
roles/mariadb/handlers/main.yml
Normal file
6
roles/mariadb/handlers/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Start mysqld service
|
||||
systemd:
|
||||
name: mysqld
|
||||
state: started
|
||||
scope: system
|
3
roles/mariadb/meta/main.yml
Normal file
3
roles/mariadb/meta/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- role: check-sudo
|
32
roles/mariadb/tasks/main.yml
Normal file
32
roles/mariadb/tasks/main.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
- 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
|
Loading…
Add table
Reference in a new issue