Ignore check_hostname when using MySQLdb

This commit is contained in:
Jorge-Rodriguez 2020-10-04 10:37:38 +03:00
parent 3aed674194
commit 5d9469831b
No known key found for this signature in database
GPG key ID: 43153D1EFD8F7D90
8 changed files with 38 additions and 9 deletions

View file

@ -66,7 +66,8 @@ options:
description:
- Whether to validate the server host name when an SSL connection is required.
- Setting this to False disables hostname verification. Use with caution.
- Requires pymysql >= 0.7.11. MySQLdb does not support this option.
- Requires pymysql >= 0.7.11.
- This optoin has no effect on MySQLdb.
type: bool
requirements:
- PyMySQL (Python 2.7 and Python 3.X), or

View file

@ -87,8 +87,6 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
config['ssl']['check_hostname'] = check_hostname
else:
module.fail_json(msg='To use check_hostname, pymysql >= 0.7.11 is required on the target host')
else:
module.fail_json(msg='Connector %s does not support the check_hostname option' % mysql_driver.__name__)
if _mysql_cursor_param == 'cursor':
# In case of PyMySQL driver:

View file

@ -51,6 +51,11 @@
- result is failed
when: pymysql_version.stdout != ""
- assert:
that:
- result is succeeded
when: pymysql_version.stdout == ""
- name: attempt connection with newly created user ignoring hostname
mysql_db:
name: '{{ db_name }}'
@ -66,7 +71,7 @@
- assert:
that:
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg or 'MySQLdb does not support' in result.msg
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg
- name: Drop mysql user
mysql_user:

View file

@ -49,6 +49,11 @@
- result is failed
when: pymysql_version.stdout != ""
- assert:
that:
- result is succeeded
when: pymysql_version.stdout == ""
- name: attempt connection with newly created user ignoring hostname
mysql_info:
filter: version
@ -63,7 +68,7 @@
- assert:
that:
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg or 'MySQLdb does not support' in result.msg
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg
- name: Drop mysql user
mysql_user:

View file

@ -49,6 +49,11 @@
- result is failed
when: pymysql_version.stdout != ""
- assert:
that:
- result is succeeded
when: pymysql_version.stdout == ""
- name: attempt connection with newly created user ignoring hostname
mysql_query:
query: 'SHOW DATABASES'
@ -63,7 +68,7 @@
- assert:
that:
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg or 'MySQLdb does not support' in result.msg
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg
- name: Drop mysql user
mysql_user:

View file

@ -50,6 +50,11 @@
- result is failed
when: pymysql_version.stdout != ""
- assert:
that:
- result is succeeded
when: pymysql_version.stdout == ""
- name: attempt connection with newly created user ignoring hostname
mysql_replication:
mode: getmaster
@ -64,7 +69,7 @@
- assert:
that:
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg or 'MySQLdb does not support' in result.msg
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg
- name: Drop mysql user
mysql_user:

View file

@ -52,6 +52,11 @@
- result is failed
when: pymysql_version.stdout != ""
- assert:
that:
- result is succeeded
when: pymysql_version.stdout == ""
- name: attempt connection with newly created user ignoring hostname
mysql_user:
name: "{{ user_name_2 }}"
@ -68,7 +73,7 @@
- assert:
that:
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg or 'MySQLdb does not support' in result.msg
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg
- name: Drop mysql user
mysql_user:

View file

@ -50,6 +50,11 @@
- result is failed
when: pymysql_version.stdout != ""
- assert:
that:
- result is succeeded
when: pymysql_version.stdout == ""
- name: attempt connection with newly created user ignoring hostname
mysql_variables:
variable: '{{ set_name }}'
@ -64,7 +69,7 @@
- assert:
that:
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg or 'MySQLdb does not support' in result.msg
- result is succeeded or 'pymysql >= 0.7.11 is required' in result.msg
- name: Drop mysql user
mysql_user: