Skip to content

Commit

Permalink
New features added
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
digiserg committed Jan 11, 2024
1 parent 24e59a4 commit a1149cc
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 1 deletion.
8 changes: 8 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions tasks/root-password.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions tasks/setup_alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tasks/setup_debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions tasks/setup_redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tasks/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions templates/mariadb.cnf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit a1149cc

Please sign in to comment.