diff --git a/defaults/main.yml b/defaults/main.yml index 100cd49c603101226ebb5e097b20f3cb14468941..acba72a6235ae98849c82b0e6e7858c4c4db7a1c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -35,7 +35,7 @@ mariadb_query_cache_limit: 0 mariadb_query_cache_size: 0 # Import time zone tables -mariadb_time_zone_import: false +mariadb_time_zone_import: true # If the mariadb_root_auth variable is not set then nothing will be done to the # root account login, which, by default, uses a socket for logins and doesn't diff --git a/tasks/mariadb_root_password.yml b/tasks/mariadb_root_password.yml index 9e328da59bedddcee7f80d1095e0bc2df6f93bb8..6f965fe5ce81eb1f86fce4fa5eae21fd65e6fbe4 100644 --- a/tasks/mariadb_root_password.yml +++ b/tasks/mariadb_root_password.yml @@ -29,10 +29,10 @@ when: mariadb_community no_log: true - - name: Enable MariaDB root logins with a password - ansible.builtin.command: mysql -uroot -e "UPDATE mysql.user SET authentication_string=PASSWORD('{{ mariadb_root_password }}'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost'; FLUSH PRIVILEGES;" - when: not mariadb_community - no_log: true + # - name: Enable MariaDB root logins with a password + # ansible.builtin.command: mysql -uroot -e "UPDATE mysql.user SET authentication_string=PASSWORD('{{ mariadb_root_password }}'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost'; FLUSH PRIVILEGES;" + # when: not mariadb_community + # no_log: true - name: MariaDB root password written to /root/.my.cnf ansible.builtin.template: @@ -44,6 +44,24 @@ force: true no_log: true + - name: Query the MariaDB databases, users and version using the /root/.my.cnf file + community.mysql.mysql_info: + filter: + - users + return_empty_dbs: true + login_user: root + config_file: /root/.my.cnf + register: mariadb_info + + - name: Set a variable for the root authentication plugin + ansible.builtin.set_fact: + mariadb_root_auth_current: "{{ mariadb_info.users.localhost.root.plugin }}" + + - name: Debug MariaDB root authentication plugin + ansible.builtin.debug: + var: mariadb_root_auth_current + verbosity: 2 + tags: - mariadb ... diff --git a/tasks/mariadb_root_socket.yml b/tasks/mariadb_root_socket.yml index 6f6ee4da31f31294817e58dccd65b8dc4105d7b3..a5b52c06108c5ea86d8b955ee2fba6a16bbfba7c 100644 --- a/tasks/mariadb_root_socket.yml +++ b/tasks/mariadb_root_socket.yml @@ -16,18 +16,37 @@ - ( mariadb_root_password is defined ) and ( mariadb_root_password | length > 0 ) no_log: true - - name: Enable MariaDB root logins with a socket - ansible.builtin.command: mysql -uroot -p{{ mariadb_root_password }} -e "ALTER USER root@localhost IDENTIFIED VIA unix_socket; FLUSH PRIVILEGES;" mysql - when: - - not mariadb_community - - ( mariadb_root_password is defined ) and ( mariadb_root_password | length > 0 ) - no_log: true + # - name: Enable MariaDB root logins with a socket + # ansible.builtin.command: mysql -uroot -p{{ mariadb_root_password }} -e "ALTER USER root@localhost IDENTIFIED VIA unix_socket; FLUSH PRIVILEGES;" mysql + # when: + # - not mariadb_community + # - ( mariadb_root_password is defined ) and ( mariadb_root_password | length > 0 ) + # no_log: true - name: Remove /root/.my.cnf ansible.builtin.file: path: /root/.my.cnf state: absent + - name: Query the MariaDB users using a socket + community.mysql.mysql_info: + filter: + - databases + - users + - version + return_empty_dbs: true + login_user: root + login_unix_socket: /run/mysqld/mysqld.sock + register: mariadb_info + + - name: Set a variable for the root authentication plugin + ansible.builtin.set_fact: + mariadb_root_auth_current: "{{ mariadb_info.users.localhost.root.plugin }}" + + - name: Debug MariaDB root authentication plugin + ansible.builtin.debug: + var: mariadb_root_auth_current + verbosity: 2 tags: - mariadb ... diff --git a/tasks/tz.yml b/tasks/tz.yml index 5e4a16a78264a4a9b6432f78385d4597fde94408..de4848e39c9b5b12b67bf67d6d05fe30b11d7ae5 100644 --- a/tasks/tz.yml +++ b/tasks/tz.yml @@ -99,7 +99,7 @@ state: absent when: mariadb_tzdata_mariadb_file.stat.exists - - name: "/root/.my.tzdata file icontaining {{ mariadb_tzdata_latest }} present" + - name: "/root/.my.tzdata file containing {{ mariadb_tzdata_latest }} present" lineinfile: path: /root/.my.tzdata line: "{{ mariadb_tzdata_latest }}"