mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
New module mysql_info - Gather information about MySQL servers (#55434)
* New module mysql_info: collect info about MySQL server instance * mysql_info - CI tests * mysql_info: fixes * mysql_info: fixes Decimal * mysql_info: fixes Decimal converters.py * mysql_info: fixed err conn message and check_mode * mysql_info: added decimal.Decimal to lib/ansible/parsing/ajson.py * mysql_info: convert Decimal to float * mysql_info: fix * mysql_info: fix * mysql_info: returned the args list as it was * mysql_info: fix typo * mysql_info: fixes * mysql_info: removed aliases for login_db * mysql_info: changed RETURN condition info * mysql_info: fixed doc * mysql_info: fixed role's parsing * mysql_info: fixed role's parsing * mysql_info: fixes * mysql_info: fixed integration tests
This commit is contained in:
parent
f137527201
commit
baac1df935
7 changed files with 605 additions and 1 deletions
|
@ -40,6 +40,8 @@ except ImportError:
|
|||
except ImportError:
|
||||
mysql_driver = None
|
||||
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
mysql_driver_fail_msg = 'The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required.'
|
||||
|
||||
|
||||
|
@ -76,8 +78,28 @@ def mysql_connect(module, login_user=None, login_password=None, config_file='',
|
|||
if connect_timeout is not None:
|
||||
config['connect_timeout'] = connect_timeout
|
||||
|
||||
db_connection = mysql_driver.connect(**config)
|
||||
try:
|
||||
db_connection = mysql_driver.connect(**config)
|
||||
|
||||
except Exception as e:
|
||||
module.fail_json(msg="unable to connect to database: %s" % to_native(e))
|
||||
|
||||
if cursor_class is not None:
|
||||
return db_connection.cursor(**{_mysql_cursor_param: mysql_driver.cursors.DictCursor})
|
||||
else:
|
||||
return db_connection.cursor()
|
||||
|
||||
|
||||
def mysql_common_argument_spec():
|
||||
return dict(
|
||||
login_user=dict(type='str', default=None),
|
||||
login_password=dict(type='str', no_log=True),
|
||||
login_host=dict(type='str', default='localhost'),
|
||||
login_port=dict(type='int', default=3306),
|
||||
login_unix_socket=dict(type='str'),
|
||||
config_file=dict(type='path', default='~/.my.cnf'),
|
||||
connect_timeout=dict(type='int', default=30),
|
||||
client_cert=dict(type='path', aliases=['ssl_cert']),
|
||||
client_key=dict(type='path', aliases=['ssl_key']),
|
||||
ca_cert=dict(type='path', aliases=['ssl_ca']),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue