initial commit
This commit is contained in:
commit
c5e60d80f9
|
@ -0,0 +1,2 @@
|
|||
mysql_users: []
|
||||
mysql_databases: []
|
|
@ -0,0 +1,4 @@
|
|||
galaxy_info:
|
||||
role_name: mariadb
|
||||
|
||||
dependencies: []
|
|
@ -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 }}"
|
Loading…
Reference in New Issue