[mysql_hardening] Allow setting the mysql_distribution (#473)

* [mysql_hardening] Allow setting the mysql_distribution

On some operating systems, the package for MySQL is not `mysql-server`,
and so the default check for this will not yield the correct result.
This change adds an escape hatch by letting the user set
`mysql_distribution`.  Additionally, it verifies that it is set to a
legal value if the user has set it.

Closes #472

Signed-off-by: Shawn Wilsher <656602+sdwilsh@users.noreply.github.com>

* Update roles/mysql_hardening/tasks/main.yml

Co-authored-by: Sebastian Gumprich <rndmh3ro@users.noreply.github.com>
This commit is contained in:
Shawn Wilsher 2021-08-15 11:03:07 -07:00 committed by GitHub
parent bfd3f96355
commit 9ab06a5e06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,13 +22,21 @@
with_dict: '{{ os_vars }}'
tags: always
- name: Check that the variable mysql_distribution is set correctly
ansible.builtin.assert:
that: mysql_distribution == 'mysql' or mysql_distribution == 'mariadb'
fail_msg: 'mysql_distribution must be set to either mysql or mariadb!'
when: mysql_distribution is defined
- name: Gather package facts to check for mysql/mariadb version
ansible.builtin.package_facts:
manager: auto
when: not mysql_distribution is defined
- name: Check if MySQL or MariaDB is used
set_fact:
mysql_distribution: "{{ ansible_facts.packages['mysql-server'] is defined | ternary('mysql', 'mariadb') }}"
when: not mysql_distribution is defined
- name: Check which MySQL/MariaDB version is used
community.mysql.mysql_info: