From 010e4798f6ae2015b7124ae9c40ede15ab4a364b Mon Sep 17 00:00:00 2001 From: Chris Croome <chris@webarchitects.co.uk> Date: Fri, 3 Nov 2023 18:17:32 +0000 Subject: [PATCH] additional checks for running in check mode added --- .pre-commit-config.yaml | 6 +++--- README.md | 6 ++++++ tasks/mysqltuner.yml | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9cf5c7f..594791b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,19 +17,19 @@ repos: name: YAML Lint # https://github.com/ansible/ansible-lint/releases - repo: https://github.com/ansible/ansible-lint.git - rev: v6.20.3 + rev: v6.21.1 hooks: - id: ansible-lint name: Ansible Lint language: python additional_dependencies: # https://github.com/kellyjonbrazil/jc/releases - - jc==1.23.4 + - jc==1.23.6 # https://github.com/jmespath/jmespath.py/tags - jmespath==1.0.1 # https://github.com/jackdewinter/pymarkdown/releases - repo: https://github.com/jackdewinter/pymarkdown.git - rev: v0.9.13.4 + rev: v0.9.14 hooks: - id: pymarkdown name: Markdown Lint diff --git a/README.md b/README.md index 322edfe..12d4fb7 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,12 @@ mariadb_config: default_character_set: utf8mb4 ``` +You can get the existing configuration as YAML using: + +```bash +cat /etc/mysql/mariadb.conf.d/50-server.cnf | jc --ini -p | yq -o=yaml -P +``` + ### mariadb_mysqltuner A boolean, `mariadb_mysqltuner` defaults to `true` and results in [MySQLTuner](https://github.com/major/MySQLTuner-perl) being installed using a Debian package or from GitHub depending on the version specified using `mariadb_mysqltuner_version`. diff --git a/tasks/mysqltuner.yml b/tasks/mysqltuner.yml index 8f4c1d1..cc1372d 100644 --- a/tasks/mysqltuner.yml +++ b/tasks/mysqltuner.yml @@ -147,6 +147,11 @@ depth: 1 update: true + - name: Check that MySQLTuner code is present + ansible.builtin.stat: + path: /usr/local/src/MySQLTuner-perl/mysqltuner.pl + register: mariadb_mysqltuner_script + - name: MySQLTuner script in place ansible.builtin.copy: src: /usr/local/src/MySQLTuner-perl/mysqltuner.pl @@ -155,6 +160,7 @@ mode: "0755" owner: root group: root + when: mariadb_mysqltuner_script.stat.exists | bool - name: Directory for MySQLTuner assets in place ansible.builtin.file: @@ -164,6 +170,11 @@ owner: root group: root + - name: Check that MySQLTuner passwords is present + ansible.builtin.stat: + path: /usr/local/src/MySQLTuner-perl/basic_passwords.txt + register: mariadb_mysqltuner_passwords + - name: MySQLTuner basic_passwords.txt file in place ansible.builtin.copy: src: /usr/local/src/MySQLTuner-perl/basic_passwords.txt @@ -172,6 +183,12 @@ mode: "0644" owner: root group: root + when: mariadb_mysqltuner_passwords.stat.exists | bool + + - name: Check that MySQLTuner vulnerabilities is present + ansible.builtin.stat: + path: /usr/local/src/MySQLTuner-perl/vulnerabilities.csv + register: mariadb_mysqltuner_vulnerabilities - name: MySQLTuner vulnerabilities.csv file in place ansible.builtin.copy: @@ -181,6 +198,7 @@ mode: "0644" owner: root group: root + when: mariadb_mysqltuner_vulnerabilities.stat.exists | bool when: >- ( ansible_local.dpkg.installed is not defined ) or -- GitLab