Merge pull request #3112 from Jmainguy/mysql_user_binlog
added sql_log_bin setting to disable binary logging as option
This commit is contained in:
commit
e26e3bc201
1 changed files with 15 additions and 0 deletions
|
@ -69,6 +69,13 @@ options:
|
||||||
choices: [ "yes", "no" ]
|
choices: [ "yes", "no" ]
|
||||||
default: "no"
|
default: "no"
|
||||||
version_added: "1.4"
|
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:
|
state:
|
||||||
description:
|
description:
|
||||||
- Whether the user should exist. When C(absent), removes
|
- 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
|
# Example using login_unix_socket to connect to server
|
||||||
- mysql_user: name=root password=abc123 login_unix_socket=/var/run/mysqld/mysqld.sock
|
- 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
|
# Example .my.cnf file for setting the root password
|
||||||
|
|
||||||
[client]
|
[client]
|
||||||
|
@ -480,6 +490,7 @@ def main():
|
||||||
update_password=dict(default="always", choices=["always", "on_create"]),
|
update_password=dict(default="always", choices=["always", "on_create"]),
|
||||||
connect_timeout=dict(default=30, type='int'),
|
connect_timeout=dict(default=30, type='int'),
|
||||||
config_file=dict(default="~/.my.cnf"),
|
config_file=dict(default="~/.my.cnf"),
|
||||||
|
sql_log_bin=dict(default=True, type='bool'),
|
||||||
ssl_cert=dict(default=None),
|
ssl_cert=dict(default=None),
|
||||||
ssl_key=dict(default=None),
|
ssl_key=dict(default=None),
|
||||||
ssl_ca=dict(default=None),
|
ssl_ca=dict(default=None),
|
||||||
|
@ -504,6 +515,7 @@ def main():
|
||||||
ssl_key = module.params["ssl_key"]
|
ssl_key = module.params["ssl_key"]
|
||||||
ssl_ca = module.params["ssl_ca"]
|
ssl_ca = module.params["ssl_ca"]
|
||||||
db = 'mysql'
|
db = 'mysql'
|
||||||
|
sql_log_bin = module.params["sql_log_bin"]
|
||||||
|
|
||||||
config_file = os.path.expanduser(os.path.expandvars(config_file))
|
config_file = os.path.expanduser(os.path.expandvars(config_file))
|
||||||
if not mysqldb_found:
|
if not mysqldb_found:
|
||||||
|
@ -524,6 +536,9 @@ def main():
|
||||||
except Exception, e:
|
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))
|
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:
|
if priv is not None:
|
||||||
try:
|
try:
|
||||||
mode = get_mode(cursor)
|
mode = get_mode(cursor)
|
||||||
|
|
Loading…
Reference in a new issue