Skip to content

Commit

Permalink
implemented pdns_mysql_query_use_socket
Browse files Browse the repository at this point in the history
  • Loading branch information
zerwes committed Sep 19, 2023
1 parent 91332e2 commit 1416769
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tasks/database-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
- name: Check if the MySQL databases are empty
command: >
mysql --user="{{ item['value']['user'] }}" --password="{{ item['value']['password'] }}"
--host="{{ item['value']['host'] }}" --port "{{ item['value']['port'] | default('3306') }}" --batch --skip-column-names
{% if not (pdns_mysql_query_use_socket | default(false)) %} --host="{{ item['value']['host'] }}" --port "{{ item['value']['port'] | default('3306') }}"{% endif %}
--batch --skip-column-names
--execute="SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '{{ item['value']['dbname'] }}'"
when: item.key.split(':')[0] == 'gmysql'
with_dict: "{{ pdns_backends }}"
Expand Down Expand Up @@ -68,8 +69,9 @@
mysql_db:
login_user: "{{ item['item']['value']['user'] }}"
login_password: "{{ item['item']['value']['password'] }}"
login_host: "{{ item['item']['value']['host'] }}"
login_port: "{{ item['item']['port'] | default('3306') }}"
login_host: "{{ item['item']['value']['host'] if not (pdns_mysql_query_use_socket | default(false)) else omit }}"
login_port: "{{ item['item']['port'] | default('3306') if not (pdns_mysql_query_use_socket | default(false)) else omit }}"
login_unix_socket: "{{ '/var/run/mysqld/mysqld.sock' if (pdns_mysql_query_use_socket | default(false)) else omit }}"
name: "{{ item.item['value']['dbname'] }}"
state: import
target: "{{ pdns_mysql_schema_file_to_use }}"
Expand Down
3 changes: 3 additions & 0 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ default_pdns_backends_packages:

# The directory where the PowerDNS Authoritative Server configuration is located
default_pdns_config_dir: "/etc/powerdns"

# Do not use --host --port for mysql connections
pdns_mysql_query_use_socket: true

0 comments on commit 1416769

Please sign in to comment.