diff --git a/roles/database_server/tasks/main.yml b/roles/database_server/tasks/main.yml index d945ce1d4ae3ed9046d8787ace1bacdde962f742..184a201f14348ee211e02c71f576c1d84c01cda6 100644 --- a/roles/database_server/tasks/main.yml +++ b/roles/database_server/tasks/main.yml @@ -32,48 +32,37 @@ group: root mode: 0400 -- name: Check if root user authentication is based on use of unix_socket module (Stretch default) +- name: Check if root user authentication is based on use of unix_socket module command: mysql --skip-column-names -B -e "select 1 from mysql.user where user='root' and plugin='unix_socket';" - when: "ansible_distribution_release == 'stretch'" register: "root_using_unix_socket_authentication" changed_when: false -- name: Disable use of unix socket login on Debian Stretch (temporary workaround) +# @TODO: This is essentially a leftover from the days of Debian +# Jessie, which by default did not use unix socket +# authentication for the root account. To make the deployment +# the same on both distros, unix socket authentication was +# disabled on Debian Stretch at the time. It might be worth the +# effort to revisit this and figure out if unix socket +# authentication should be reenabled instead (and whether +# password for the root account should be used at all). +- name: Disable use of unix socket login command: "mysql -B -e \"update mysql.user set plugin='' where user='root' and plugin='unix_socket'; flush privileges;\"" - when: "ansible_distribution_release == 'stretch' and root_using_unix_socket_authentication.stdout" + when: "root_using_unix_socket_authentication.stdout" -- name: Remove UTF-8 encoding configuration file from the old location on Debian Stretch - file: - path: "/etc/mysql/conf.d/utf8.cnf" - state: absent - when: "ansible_distribution_release == 'stretch'" - register: mariadb_utf8_configuration_stretch - -- name: Set UTF-8 encoding as default for MariaDB (on Jessie) - copy: - src: "utf8.cnf" - dest: "/etc/mysql/conf.d/utf8.cnf" - owner: root - group: root - mode: 0644 - when: "ansible_distribution_release == 'jessie'" - register: mariadb_utf8_configuration_jessie - -- name: Set UTF-8 encoding as default for MariaDB (on Stretch) +- name: Set UTF-8 encoding as default for MariaDB copy: src: "utf8.cnf" dest: "/etc/mysql/mariadb.conf.d/90-utf8.cnf" owner: root group: root mode: 0644 - when: "ansible_distribution_release == 'stretch'" - register: mariadb_utf8_configuration_stretch + register: mariadb_utf8_configuration - name: Restart MariaDB in order to use UTF-8 as default character set service: name: mysql state: restarted - when: mariadb_utf8_configuration_jessie.changed or mariadb_utf8_configuration_stretch.changed + when: mariadb_utf8_configuration.changed tags: # [ANSIBLE0016] Tasks that run when changed should likely be handlers # UTF-8 configuration must be applied immediatelly in order to ensure that