diff --git a/roles/mariadb/defaults/main.yml b/roles/mariadb/defaults/main.yml index 029b586..e7eb2f1 100644 --- a/roles/mariadb/defaults/main.yml +++ b/roles/mariadb/defaults/main.yml @@ -19,6 +19,11 @@ innodb_buffer_pool_size: 256M # See: https://mariadb.com/kb/en/mariadb/xtradbinnodb-server-system-variables innodb_buffer_pool_instances: 1 +# Ansible 2.7.x with PyMySQL seems to default to TCP connection so we should +# force it to use a Unix socket. +# See: https://github.com/ansible/ansible/issues/47736 +mariadb_login_unix_socket: /var/run/mysqld/mysqld.sock + # default is 100 but the max I've seen used is 5, so let's reduce it max_connections: 33 diff --git a/roles/mariadb/tasks/main.yml b/roles/mariadb/tasks/main.yml index 6cb8cfc..e6f8b1f 100644 --- a/roles/mariadb/tasks/main.yml +++ b/roles/mariadb/tasks/main.yml @@ -32,7 +32,7 @@ # 'localhost' needs to be the last item for idempotency, see # https://docs.ansible.com/ansible/latest/mysql_user_module.html - name: Update MariaDB root password for all root accounts - mysql_user: name=root host={{ item }} password={{ mariadb_root_password }} + mysql_user: name=root host={{ item }} password={{ mariadb_root_password }} login_unix_socket={{ mariadb_login_unix_socket }} loop: - "{{ inventory_hostname }}" - 127.0.0.1 diff --git a/roles/mariadb/templates/.my.cnf.j2 b/roles/mariadb/templates/.my.cnf.j2 index efe928d..04539fe 100644 --- a/roles/mariadb/templates/.my.cnf.j2 +++ b/roles/mariadb/templates/.my.cnf.j2 @@ -1,3 +1,4 @@ [client] user=root password='{{ mariadb_root_password }}' +login_unix_socket='{{ mariadb_login_unix_socket }}'