Add --protocol=TCP {TCP|SOCKET|PIPE|MEMORY} support

- Hopefully it works "as is", otherwise I will enhance until PR get ready to be merged let discuss it
This commit is contained in:
Richard Vézina 2022-01-25 16:50:57 -05:00
commit 4786a40f9d
6 changed files with 75 additions and 26 deletions

View file

@ -175,6 +175,7 @@ def main():
variable=dict(type='str'),
value=dict(type='str'),
mode=dict(type='str', choices=['global', 'persist', 'persist_only'], default='global'),
protocol=dict(type='str', default=None, choices=['tcp', 'socket', 'pipe', 'memory']),
)
module = AnsibleModule(
@ -193,6 +194,7 @@ def main():
mysqlvar = module.params["variable"]
value = module.params["value"]
mode = module.params["mode"]
protocol = module.params["protocol"]
if mysqlvar is None:
module.fail_json(msg="Cannot run without variable to operate with")
@ -204,8 +206,10 @@ def main():
warnings.filterwarnings('error', category=mysql_driver.Warning)
try:
cursor, db_conn = mysql_connect(module, user, password, config_file, ssl_cert, ssl_key, ssl_ca, db,
connect_timeout=connect_timeout, check_hostname=check_hostname)
cursor, db_conn = mysql_connect(
module, user, password, config_file, ssl_cert, ssl_key, ssl_ca, db, protocol,
connect_timeout=connect_timeout, check_hostname=check_hostname
)
except Exception as e:
if os.path.exists(config_file):
module.fail_json(msg=("unable to connect to database, check login_user and "