Files
@ f0ffcf83f46a
Branch filter:
Location: majic-ansible-roles/roles/database_server/module_utils/mysql.py - annotation
f0ffcf83f46a
4.5 KiB
text/x-python
MAR-155: Make the ansible_key parameter in the bootstrap role mandatory:
- Updated the preseed role.
- Removed default value for the parameter.
- Updated tests.
- Updated role reference documentation.
- Updated release notes.
- Updated the preseed role.
- Removed default value for the parameter.
- Updated tests.
- Updated role reference documentation.
- Updated release notes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | bf5f072d9072 bf5f072d9072 bf5f072d9072 bf5f072d9072 bf5f072d9072 bf5f072d9072 bf5f072d9072 bf5f072d9072 bf5f072d9072 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 2381ba93d089 | # @TODO: This is a patched file used as workaround for issues around
# the use check_implicit_admin parameter for the mysql_user
# module. Once the fix has landed in official Ansible release, this
# file should be dropped. For more details see:
#
# - https://github.com/ansible/ansible/commit/47aea84924
# - https://github.com/ansible/ansible/issues/64560
# This code is part of Ansible, but is an independent component.
# This particular file snippet, and this file snippet only, is BSD licensed.
# Modules you write using this snippet, which is embedded dynamically by Ansible
# still belong to the author of the module, and may assign their own license
# to the complete work.
#
# Copyright (c), Jonathan Mainguy <jon@soh.re>, 2015
# Most of this was originally added by Sven Schliesing @muffl0n in the mysql_user.py module
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
try:
import pymysql as mysql_driver
_mysql_cursor_param = 'cursor'
except ImportError:
try:
import MySQLdb as mysql_driver
import MySQLdb.cursors
_mysql_cursor_param = 'cursorclass'
except ImportError:
mysql_driver = None
mysql_driver_fail_msg = 'The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required.'
def mysql_connect(module, login_user=None, login_password=None, config_file='', ssl_cert=None, ssl_key=None, ssl_ca=None, db=None, cursor_class=None,
connect_timeout=30):
config = {}
if ssl_ca is not None or ssl_key is not None or ssl_cert is not None:
config['ssl'] = {}
if module.params['login_unix_socket']:
config['unix_socket'] = module.params['login_unix_socket']
else:
config['host'] = module.params['login_host']
config['port'] = module.params['login_port']
if os.path.exists(config_file):
config['read_default_file'] = config_file
# If login_user or login_password are given, they should override the
# config file
if login_user is not None:
config['user'] = login_user
if login_password is not None:
config['passwd'] = login_password
if ssl_cert is not None:
config['ssl']['cert'] = ssl_cert
if ssl_key is not None:
config['ssl']['key'] = ssl_key
if ssl_ca is not None:
config['ssl']['ca'] = ssl_ca
if db is not None:
config['db'] = db
if connect_timeout is not None:
config['connect_timeout'] = connect_timeout
db_connection = mysql_driver.connect(**config)
if cursor_class == 'DictCursor':
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']),
)
|