mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-08 19:50:31 -07:00
tmp
This commit is contained in:
parent
915d125d70
commit
83b76a4804
3 changed files with 22 additions and 4 deletions
|
@ -100,6 +100,8 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
|
||||||
if charset is not None:
|
if charset is not None:
|
||||||
config['charset'] = charset
|
config['charset'] = charset
|
||||||
|
|
||||||
|
module.warn('%s' % config)
|
||||||
|
|
||||||
if _mysql_cursor_param == 'cursor':
|
if _mysql_cursor_param == 'cursor':
|
||||||
# In case of PyMySQL driver:
|
# In case of PyMySQL driver:
|
||||||
db_connection = mysql_driver.connect(autocommit=autocommit, **config)
|
db_connection = mysql_driver.connect(autocommit=autocommit, **config)
|
||||||
|
@ -134,7 +136,7 @@ def mysql_common_argument_spec():
|
||||||
client_key=dict(type='path', aliases=['ssl_key']),
|
client_key=dict(type='path', aliases=['ssl_key']),
|
||||||
ca_cert=dict(type='path', aliases=['ssl_ca']),
|
ca_cert=dict(type='path', aliases=['ssl_ca']),
|
||||||
check_hostname=dict(type='bool', default=None),
|
check_hostname=dict(type='bool', default=None),
|
||||||
charset=dict(type='str'),
|
charset=dict(type='str', default=None),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1177,13 +1177,15 @@ def main():
|
||||||
if check_implicit_admin:
|
if check_implicit_admin:
|
||||||
try:
|
try:
|
||||||
cursor, db_conn = mysql_connect(module, "root", "", config_file, ssl_cert, ssl_key, ssl_ca, db,
|
cursor, db_conn = mysql_connect(module, "root", "", config_file, ssl_cert, ssl_key, ssl_ca, db,
|
||||||
connect_timeout=connect_timeout, check_hostname=check_hostname, charset=charset)
|
connect_timeout=connect_timeout, check_hostname=check_hostname,
|
||||||
|
charset=charset)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not cursor:
|
if not cursor:
|
||||||
cursor, db_conn = mysql_connect(module, login_user, login_password, config_file, ssl_cert, ssl_key, ssl_ca, db,
|
cursor, db_conn = mysql_connect(module, login_user, login_password, config_file, ssl_cert, ssl_key, ssl_ca, db,
|
||||||
connect_timeout=connect_timeout, check_hostname=check_hostname)
|
connect_timeout=connect_timeout, check_hostname=check_hostname,
|
||||||
|
charset=charset)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
module.fail_json(msg="unable to connect to database, check login_user and login_password are correct or %s has the credentials. "
|
module.fail_json(msg="unable to connect to database, check login_user and login_password are correct or %s has the credentials. "
|
||||||
"Exception message: %s" % (config_file, to_native(e)))
|
"Exception message: %s" % (config_file, to_native(e)))
|
||||||
|
|
|
@ -49,8 +49,21 @@
|
||||||
<<: *mysql_params
|
<<: *mysql_params
|
||||||
name: '{{ user_name_5 }}'
|
name: '{{ user_name_5 }}'
|
||||||
password: '{{ user_password_5 }}'
|
password: '{{ user_password_5 }}'
|
||||||
|
priv: '*.*:SELECT'
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
- name: Create user with default charset again
|
||||||
|
mysql_user:
|
||||||
|
<<: *mysql_params
|
||||||
|
name: '{{ user_name_5 }}'
|
||||||
|
password: '{{ user_password_5 }}'
|
||||||
|
state: present
|
||||||
|
priv: '*.*:SELECT'
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: result is not changed
|
||||||
|
|
||||||
- name: Try to get connect and get info, must fail
|
- name: Try to get connect and get info, must fail
|
||||||
mysql_query:
|
mysql_query:
|
||||||
login_host: 127.0.0.1
|
login_host: 127.0.0.1
|
||||||
|
@ -79,9 +92,10 @@
|
||||||
name: '{{ user_name_5 }}'
|
name: '{{ user_name_5 }}'
|
||||||
password: '{{ user_password_5 }}'
|
password: '{{ user_password_5 }}'
|
||||||
state: present
|
state: present
|
||||||
|
priv: '*.*:SELECT'
|
||||||
charset: utf8mb4
|
charset: utf8mb4
|
||||||
|
|
||||||
- name: Try to get connect and get info, must succeed
|
- name: Try to connect and get info, must succeed
|
||||||
mysql_query:
|
mysql_query:
|
||||||
login_host: 127.0.0.1
|
login_host: 127.0.0.1
|
||||||
login_port: '{{ mysql_primary_port }}'
|
login_port: '{{ mysql_primary_port }}'
|
||||||
|
|
Loading…
Add table
Reference in a new issue