Skip to content

Commit

Permalink
archlinux: skip ssl cert validation for mysql tests
Browse files Browse the repository at this point in the history
  • Loading branch information
romeroalx committed Oct 8, 2024
1 parent 4902220 commit 80e3f4b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
8 changes: 5 additions & 3 deletions molecule/resources/tests/backend-mysql/test_backend_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ def test_config(host):
def test_database_tables(host):
dbname = host.check_output('hostname -s').replace('.', '_')

cmd = host.run("mysql --user=\"pdns\" --password=\"pdns\" --host=\"mysql\" " +
"--batch --skip-column-names " +
"--execute=\"SELECT DISTINCT table_name FROM information_schema.columns WHERE table_schema = '%s'\"" % dbname)
mysql_cmd = 'mariadb --skip-ssl-verify-server-cert' if host.system_info.distribution.lower() in archlinux_os else 'mysql'

cmd = host.run(f'{mysql_cmd} --user="pdns" --password="pdns" --host="mysql" ' +
'--batch --skip-column-names ' +
'--execute="SELECT DISTINCT table_name FROM information_schema.columns WHERE table_schema = {dbname}"')

for table in [ 'domains', 'records', 'supermasters', 'comments',
'domainmetadata', 'cryptokeys', 'tsigkeys' ]:
Expand Down
20 changes: 8 additions & 12 deletions tasks/database-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
- skip_missing: yes

- 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
--execute="SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = '{{ item['value']['dbname'] }}'"
shell: |-
{{ pdns_backends_mysql_cmd | default('mysql') }} --user="{{ item['value']['user'] }}" --password="{{ item['value']['password'] }}" \
--host="{{ item['value']['host'] }}" --port "{{ item['value']['port'] | default('3306') }}" --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 }}"
register: _pdns_check_mysql_db
Expand All @@ -64,15 +64,11 @@
set_fact:
pdns_mysql_schema_file_to_use: "{% if pdns_mysql_schema_file | length == 0 %}{{ pdns_mysql_schema_file_detected.stdout }}{% else %}{{ pdns_mysql_schema_file }}{% endif %}"


- name: Import the PowerDNS MySQL schema
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') }}"
name: "{{ item.item['value']['dbname'] }}"
state: import
target: "{{ pdns_mysql_schema_file_to_use }}"
shell: |-
{{ pdns_backends_mysql_cmd | default('mysql') }} --user="{{ item['item']['value']['user'] }}" --password="{{ item['item']['value']['password'] }}" --host="{{ item['item']['value']['host'] }}" \
--port="{{ item['item']['port'] | default('3306') }}" "{{ item.item['value']['dbname'] }}" < "{{ pdns_mysql_schema_file_to_use }}"
no_log: True
when: "item['item']['key'].split(':')[0] == 'gmysql' and item['stdout'] == '0'"
with_items: "{{ _pdns_check_mysql_db['results'] }}"
3 changes: 3 additions & 0 deletions vars/Archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ default_pdns_backends_packages: {}
# The directory where the PowerDNS configuration is located
default_pdns_config_dir: '/etc/powerdns'

# Change the default mysql client to mariabd "--skip-ssl-verify-server-cert"
pdns_backends_mysql_cmd: 'mariadb --skip-ssl-verify-server-cert'

# Packages to install for MySQL support
pdns_mysql_packages:
- python-pymysql
Expand Down

0 comments on commit 80e3f4b

Please sign in to comment.