initial commit

This commit is contained in:
Patrick Neff 2022-01-24 19:01:07 +01:00
commit c5e60d80f9
3 changed files with 58 additions and 0 deletions

2
defaults/main.yml Normal file
View File

@ -0,0 +1,2 @@
mysql_users: []
mysql_databases: []

4
meta/main.yml Normal file
View File

@ -0,0 +1,4 @@
galaxy_info:
role_name: mariadb
dependencies: []

52
tasks/main.yml Normal file
View File

@ -0,0 +1,52 @@
- name: Install packages.
tags: mysql
ansible.builtin.package:
name:
- mariadb-server
- mariadb-client
- python3-pymysql
- name: Remove unnecessary root accounts.
community.mysql.mysql_user:
name: root
host: "{{ item }}"
state: absent
with_items:
- 127.0.0.1
- ::1
- "{{ ansible_hostname }}"
- name: Remove unnecessary anonymous accounts.
community.mysql.mysql_user:
name: ""
host: "{{ item }}"
state: absent
with_items:
- 127.0.0.1
- ::1
- "{{ ansible_hostname }}"
- name: Remove test database.
community.mysql.mysql_db:
db: tests
state: absent
- name: Create databases.
community.mysql.mysql_db:
login_unix_socket: /var/run/mysqld/mysqld.sock
encoding: "{{ item.encoding | default('utf8') }}"
target: "{{ item.target | default(omit) }}"
name: "{{ item.name }}"
state: present
with_items: "{{ mysql_databases }}"
- name: Create database users.
tags: mysql
community.mysql.mysql_user:
login_unix_socket: /var/run/mysqld/mysqld.sock
name: "{{ item.name }}"
host: "{{ item.host }}"
password: "{{ item.password }}"
state: present
priv: "{{ item.priv }}"
with_items: "{{ mysql_users }}"