Skip to content

Commit

Permalink
add verify-task to check if mysql is running and enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Gumprich <[email protected]>
  • Loading branch information
Sebastian Gumprich committed Dec 6, 2022
1 parent b0454fa commit 22b12a7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions molecule/mysql_hardening/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
update_cache: true
when: ansible_distribution == 'Debian'

- name: include tests for the service
include_tasks: verify_tasks/service.yml

- name: download cinc-auditor
get_url:
url: https://omnitruck.cinc.sh/install.sh
Expand Down
19 changes: 19 additions & 0 deletions molecule/mysql_hardening/verify_tasks/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Load variables from role to use the "mysql_daemon" variable
ansible.builtin.include_role:
name: devsec.hardening.mysql_hardening
apply:
tags:
- never

- name: Populate service facts
ansible.builtin.service_facts:

- debug:
var: ansible_facts.services

- name: Check if MySQL is running and enabled
assert:
that:
- "ansible_facts.services[mysql_daemon + '.service'].state == 'running'"
- "ansible_facts.services[mysql_daemon + '.service'].status == 'enabled'"
2 changes: 1 addition & 1 deletion roles/mysql_hardening/vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
mysql_daemon: mysql
mysql_daemon: mariadb

mysql_hardening_mysql_conf_file: '/etc/mysql/my.cnf'
mysql_hardening_mysql_confd_dir: '/etc/mysql/conf.d'
Expand Down

0 comments on commit 22b12a7

Please sign in to comment.