roles/mariadb: Use Unix socket for MariaDB tasks

Otherwise Ansible fails due to PyMySQL using a TCP connection.

See: https://github.com/ansible/ansible/issues/47736
This commit is contained in:
Alan Orth 2019-07-23 17:26:23 +03:00
parent 7d8457e5b3
commit 2fadb9029a
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
3 changed files with 7 additions and 1 deletions

View File

@ -19,6 +19,11 @@ innodb_buffer_pool_size: 256M
# See: https://mariadb.com/kb/en/mariadb/xtradbinnodb-server-system-variables # See: https://mariadb.com/kb/en/mariadb/xtradbinnodb-server-system-variables
innodb_buffer_pool_instances: 1 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 # default is 100 but the max I've seen used is 5, so let's reduce it
max_connections: 33 max_connections: 33

View File

@ -32,7 +32,7 @@
# 'localhost' needs to be the last item for idempotency, see # 'localhost' needs to be the last item for idempotency, see
# https://docs.ansible.com/ansible/latest/mysql_user_module.html # https://docs.ansible.com/ansible/latest/mysql_user_module.html
- name: Update MariaDB root password for all root accounts - 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: loop:
- "{{ inventory_hostname }}" - "{{ inventory_hostname }}"
- 127.0.0.1 - 127.0.0.1

View File

@ -1,3 +1,4 @@
[client] [client]
user=root user=root
password='{{ mariadb_root_password }}' password='{{ mariadb_root_password }}'
login_unix_socket='{{ mariadb_login_unix_socket }}'