ansible-role-mariadb/tasks/main.yml

53 lines
1.2 KiB
YAML
Raw Normal View History

2022-01-24 19:01:07 +01:00
- 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 }}"