add mysql service

This commit is contained in:
LinuxSquare 2024-08-24 00:19:21 +02:00
parent 1ee7c8be8d
commit 1184d3dff5
6 changed files with 37 additions and 4 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.vscode/

View file

@ -1,3 +0,0 @@
{
"ansible.python.interpreterPath": "/bin/python"
}

View file

@ -0,0 +1,9 @@
- hosts: localhost
tasks:
- name: Create mysql directory
file:
path: /var/lib/mysql
recurse: yes
owner: mysql
group: mysql
state: directory

View file

@ -1 +1,3 @@
- import_playbook:
- import_playbook: pkg.ansible.yml
- import_playbook: directory.ansible.yml
- import_playbook: service.ansible.yml

9
mysql/pkg.ansible.yml Normal file
View file

@ -0,0 +1,9 @@
- hosts: localhost
tasks:
- name: Install mariadb package
package:
state: present
name:
- mariadb
- mariadb-client
- mariadb-openrc

15
mysql/service.ansible.yml Normal file
View file

@ -0,0 +1,15 @@
- hosts: localhost
tasks:
- name: Test if directory exists
shell: |
test /var/lib/mysql/mysql
register: MYSQL_DIRECTORY_EXISTS
- name: MariaDB setup
shell: |
/etc/init.d/mariadb setup
when: not MYSQL_DIRECTORY_EXISTS
- name: Enable mariadb service
service:
name: mariadb
state: started
enabled: true