From 2036db938bf644b983c3920b3182d0f23fb3b023 Mon Sep 17 00:00:00 2001 From: Mathieu Trossevin Date: Thu, 18 Jun 2020 15:53:52 +0200 Subject: [PATCH] [Cleanup] Cleanup the mysql role Remove the useless call for `cat` as `grep` take a file as it's second argument that tell it to search for the pattern in a specific file instead of whatever is passed to it through stdin. Name both task defining the position of the config directory for self-documentation purposes (and please ansible-lint defaults). Change role description to it's description in the readme instead of the default description asking for the role to be described. Don't compare to empty string, an empty string is already false while a non-empty string is true. --- mysql/meta/main.yml | 2 +- mysql/tasks/config_jessie.yml | 3 ++- mysql/tasks/config_stretch.yml | 3 ++- mysql/tasks/datadir.yml | 4 ++-- mysql/tasks/logdir.yml | 4 ++-- mysql/tasks/tmpdir.yml | 2 +- mysql/tasks/utils.yml | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mysql/meta/main.yml b/mysql/meta/main.yml index 82be1e3c..fef37b27 100644 --- a/mysql/meta/main.yml +++ b/mysql/meta/main.yml @@ -1,6 +1,6 @@ galaxy_info: author: Evolix - description: your description + description: Install and configure mysql issue_tracker_url: https://gitea.evolix.org/evolix/ansible-roles/issues diff --git a/mysql/tasks/config_jessie.yml b/mysql/tasks/config_jessie.yml index a5dd4d77..6b82de47 100644 --- a/mysql/tasks/config_jessie.yml +++ b/mysql/tasks/config_jessie.yml @@ -1,6 +1,7 @@ --- -- set_fact: +- name: "Define the config directory of mysql" + set_fact: mysql_config_directory: /etc/mysql/conf.d - name: "Copy MySQL defaults config file (jessie)" diff --git a/mysql/tasks/config_stretch.yml b/mysql/tasks/config_stretch.yml index d6d59efd..16aef4f9 100644 --- a/mysql/tasks/config_stretch.yml +++ b/mysql/tasks/config_stretch.yml @@ -1,6 +1,7 @@ --- -- set_fact: +- name: "Define the config directory of mysql" + set_fact: mysql_config_directory: /etc/mysql/mariadb.conf.d - name: "Copy MySQL defaults config file (Debian 9 or later)" diff --git a/mysql/tasks/datadir.yml b/mysql/tasks/datadir.yml index 28beb1ed..ee4e7bcf 100644 --- a/mysql/tasks/datadir.yml +++ b/mysql/tasks/datadir.yml @@ -14,7 +14,7 @@ register: mysql_current_real_datadir_test tags: - mysql - when: mysql_custom_datadir != '' + when: mysql_custom_datadir - block: - name: MySQL is stopped @@ -40,6 +40,6 @@ tags: - mysql when: - - mysql_custom_datadir != '' + - mysql_custom_datadir - mysql_custom_datadir != mysql_current_real_datadir_test.stdout - not mysql_custom_datadir_test.stat.exists diff --git a/mysql/tasks/logdir.yml b/mysql/tasks/logdir.yml index a1b3a8d8..959d8796 100644 --- a/mysql/tasks/logdir.yml +++ b/mysql/tasks/logdir.yml @@ -14,7 +14,7 @@ register: mysql_current_real_logdir_test tags: - mysql - when: mysql_custom_logdir != '' + when: mysql_custom_logdir - block: - name: MySQL is stopped @@ -40,6 +40,6 @@ tags: - mysql when: - - mysql_custom_logdir != '' + - mysql_custom_logdir - mysql_custom_logdir != mysql_current_real_logdir_test.stdout - not mysql_custom_logdir_test.stat.exists diff --git a/mysql/tasks/tmpdir.yml b/mysql/tasks/tmpdir.yml index e2c13dc5..69b4a4f4 100644 --- a/mysql/tasks/tmpdir.yml +++ b/mysql/tasks/tmpdir.yml @@ -20,4 +20,4 @@ notify: "{{ mysql_restart_handler_name }}" tags: - mysql - when: mysql_custom_tmpdir != '' + when: mysql_custom_tmpdir diff --git a/mysql/tasks/utils.yml b/mysql/tasks/utils.yml index 164507aa..48bc4d93 100644 --- a/mysql/tasks/utils.yml +++ b/mysql/tasks/utils.yml @@ -41,7 +41,7 @@ when: ansible_distribution_major_version is version('10', '>=') - name: Read debian-sys-maint password - shell: 'cat /etc/mysql/debian.cnf | grep -m1 "password = .*" | cut -d" " -f3' + shell: 'grep -m1 "password = .*" /etc/mysql/debian.cnf | cut -d" " -f3' register: mysql_debian_password changed_when: False check_mode: no