From d68c6c3de08fea9a5145b0aeed9a84696cfcec20 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 --- database/mysql/mysql_user.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/database/mysql/mysql_user.py b/database/mysql/mysql_user.py index df6b35857c7..c00770d7579 100644 --- a/database/mysql/mysql_user.py +++ b/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] @@ -479,6 +489,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), @@ -502,6 +513,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: @@ -520,6 +532,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)