summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
authorKenny Gryp <kenny.gryp@percona.com>2016-02-24 15:31:35 -0500
committerJonathan Mainguy <jon@soh.re>2016-03-02 14:38:00 -0500
commitd68c6c3de08fea9a5145b0aeed9a84696cfcec20 (patch)
tree60417b3661a2126867e82743deabba7f58036816 /database
parente9454fa44f5ff507c0dad3ed91a866854287e4dc (diff)
downloadansible-modules-core-d68c6c3de08fea9a5145b0aeed9a84696cfcec20.tar.gz
added sql_log_bin setting to disable binary logging as option
Diffstat (limited to 'database')
-rw-r--r--database/mysql/mysql_user.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/database/mysql/mysql_user.py b/database/mysql/mysql_user.py
index df6b3585..c00770d7 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)