From 69b07aaf9d3615b492fb5370dbddf938513c71c4 Mon Sep 17 00:00:00 2001 From: Kenny Gryp Date: Wed, 24 Feb 2016 15:31:35 -0500 Subject: [PATCH] added sql_log_bin setting to disable binary logging as option --- lib/ansible/modules/database/mysql/mysql_user.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/ansible/modules/database/mysql/mysql_user.py b/lib/ansible/modules/database/mysql/mysql_user.py index d188022b50d..c28c1ed1f43 100644 --- a/lib/ansible/modules/database/mysql/mysql_user.py +++ b/lib/ansible/modules/database/mysql/mysql_user.py @@ -69,6 +69,13 @@ options: choices: [ "yes", "no" ] default: "no" version_added: "1.4" + sql_log_bin: + description: + - Whether binary logging should be enabled or disabled for the connection. + required: false + choices: ["yes", "no" ] + default: "yes" + version_added: "2.1" state: description: - Whether the user should exist. When C(absent), removes @@ -139,6 +146,9 @@ mydb.*:INSERT,UPDATE/anotherdb.*:SELECT/yetanotherdb.*:ALL # Example using login_unix_socket to connect to server - mysql_user: name=root password=abc123 login_unix_socket=/var/run/mysqld/mysqld.sock +# Example of skipping binary logging while adding user 'bob' +- mysql_user: name=bob password=12345 priv=*.*:USAGE state=present sql_log_bin=no + # Example .my.cnf file for setting the root password [client] @@ -486,6 +496,7 @@ def main(): check_implicit_admin=dict(default=False, type='bool'), update_password=dict(default="always", choices=["always", "on_create"]), config_file=dict(default="~/.my.cnf"), + sql_log_bin=dict(default=True, type='bool'), ssl_cert=dict(default=None), ssl_key=dict(default=None), ssl_ca=dict(default=None), @@ -509,6 +520,7 @@ def main(): ssl_key = module.params["ssl_key"] ssl_ca = module.params["ssl_ca"] db = 'mysql' + sql_log_bin = module.params["sql_log_bin"] config_file = os.path.expanduser(os.path.expandvars(config_file)) if not mysqldb_found: @@ -527,6 +539,9 @@ def main(): except Exception, e: 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, e)) + if not sql_log_bin: + cursor.execute("SET SQL_LOG_BIN=0;") + if priv is not None: try: mode = get_mode(cursor)