mirror of
https://github.com/dev-sec/ansible-collection-hardening
synced 2024-11-10 09:14:18 +00:00
[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:
parent
bfd3f96355
commit
9ab06a5e06
1 changed files with 8 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue