New features added

- Support for setting the root user password
- It is possible to install additional packages required by MariaDB
- Configure MariaDB using `mariadb_options`
- Fixes users creation for servers requiring authentication
- Adds support for SSL
This commit is contained in:
Sergio Rua 2024-01-11 12:49:42 +01:00
parent 24e59a44c8
commit a1149ccda3
8 changed files with 45 additions and 1 deletions

View File

@ -78,6 +78,14 @@ mariadb_mysqldump_raw: |
quote-names
max_allowed_packet = 16M
# additional options to add to mariadb
#mariadb_options:
# key_buffer_size: 100M
# install also these packages
#mariadb_additional_packages:
# - mariadb-pam
# Changes the root password the first time and uses this variable
# to connect to mariadb for any other operations
#mariadb_root_password: changeme

View File

@ -32,6 +32,7 @@
- name: Include task users.yml
ansible.builtin.import_tasks: users.yml
tags: mariadb_users
when:
- mariadb_users is defined
- mariadb_replication_role != "replica"

View File

@ -35,4 +35,6 @@
when:
- mariadb_root_password is defined and mariadb_root_password != ""
- mariadb_create_root_my_cnf is defined and mariadb_create_root_my_cnf
no_log: true
# code: language=ansible

View File

@ -8,6 +8,15 @@
state: present
notify: Setup MariaDB
- name: Install additional packages (package)
ansible.builtin.package:
name: "{{ mariadb_additional_packages }}"
state: present
when:
- mariadb_additional_packages is defined
- mariadb_additional_packages | length > 0
notify: Setup MariaDB
- name: Check if mariadb command exists
ansible.builtin.stat:
path: /usr/bin/mariadb

View File

@ -82,3 +82,11 @@
- python3-pymysql
state: present
update_cache: true
- name: Install additional packages (apt)
ansible.builtin.apt:
name: "{{ mariadb_additional_packages }}"
state: present
when:
- mariadb_additional_packages is defined
- mariadb_additional_packages | length > 0

View File

@ -27,6 +27,14 @@
- python3-PyMySQL
state: present
- name: Install additional packages (dnf)
ansible.builtin.dnf:
name: "{{ mariadb_additional_packages }}"
state: present
when:
- mariadb_additional_packages is defined
- mariadb_additional_packages | length > 0
- name: Check if mariadb command exists
ansible.builtin.stat:
path: /usr/bin/mariadb

View File

@ -8,8 +8,10 @@
state: "{{ item.state | default('present') }}"
append_privs: "{{ item.append_privs | default('no') }}"
encrypted: "{{ item.encrypted | default('no') }}"
plugin_auth_string: "{{ item.plugin_auth_string | default(omit) }}"
login_unix_socket: "{{ mariadb_unix_socket }}"
login_user: root
login_user: "{{ mariadb_root_user | default('root') }}"
login_password: "{{ mariadb_root_password | default(omit) }}"
check_implicit_admin: true
loop: "{{ mariadb_users }}"
no_log: true

View File

@ -58,5 +58,11 @@ ssl_key = {{ mariadb_ssl_key }}
ssl_ca = {{ mariadb_ssl_ca }}
{% endif %}
{% if mariadb_options is defined %}
{% for key, value in mariadb_options.items() %}
{{ key }} = {{ value }}
{% endfor %}
{% endif %}
[mysqldump]
{{ mariadb_mysqldump_raw }}