|
|
@ -104,6 +104,13 @@ options:
|
|
|
|
choices: [0, 1, 2]
|
|
|
|
choices: [0, 1, 2]
|
|
|
|
default: 0
|
|
|
|
default: 0
|
|
|
|
version_added: '2.10'
|
|
|
|
version_added: '2.10'
|
|
|
|
|
|
|
|
skip_lock_tables:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Skip locking tables for read. Used when I(state=dump), ignored otherwise.
|
|
|
|
|
|
|
|
required: no
|
|
|
|
|
|
|
|
type: bool
|
|
|
|
|
|
|
|
default: no
|
|
|
|
|
|
|
|
version_added: '2.10'
|
|
|
|
seealso:
|
|
|
|
seealso:
|
|
|
|
- module: mysql_info
|
|
|
|
- module: mysql_info
|
|
|
|
- module: mysql_variables
|
|
|
|
- module: mysql_variables
|
|
|
@ -281,7 +288,7 @@ def db_delete(cursor, db):
|
|
|
|
def db_dump(module, host, user, password, db_name, target, all_databases, port,
|
|
|
|
def db_dump(module, host, user, password, db_name, target, all_databases, port,
|
|
|
|
config_file, socket=None, ssl_cert=None, ssl_key=None, ssl_ca=None,
|
|
|
|
config_file, socket=None, ssl_cert=None, ssl_key=None, ssl_ca=None,
|
|
|
|
single_transaction=None, quick=None, ignore_tables=None, hex_blob=None,
|
|
|
|
single_transaction=None, quick=None, ignore_tables=None, hex_blob=None,
|
|
|
|
encoding=None, force=False, master_data=0):
|
|
|
|
encoding=None, force=False, master_data=0, skip_lock_tables=False):
|
|
|
|
cmd = module.get_bin_path('mysqldump', True)
|
|
|
|
cmd = module.get_bin_path('mysqldump', True)
|
|
|
|
# If defined, mysqldump demands --defaults-extra-file be the first option
|
|
|
|
# If defined, mysqldump demands --defaults-extra-file be the first option
|
|
|
|
if config_file:
|
|
|
|
if config_file:
|
|
|
@ -305,7 +312,9 @@ def db_dump(module, host, user, password, db_name, target, all_databases, port,
|
|
|
|
if all_databases:
|
|
|
|
if all_databases:
|
|
|
|
cmd += " --all-databases"
|
|
|
|
cmd += " --all-databases"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
cmd += " --databases {0} --skip-lock-tables".format(' '.join(db_name))
|
|
|
|
cmd += " --databases {0}".format(' '.join(db_name))
|
|
|
|
|
|
|
|
if skip_lock_tables:
|
|
|
|
|
|
|
|
cmd += " --skip-lock-tables"
|
|
|
|
if (encoding is not None) and (encoding != ""):
|
|
|
|
if (encoding is not None) and (encoding != ""):
|
|
|
|
cmd += " --default-character-set=%s" % shlex_quote(encoding)
|
|
|
|
cmd += " --default-character-set=%s" % shlex_quote(encoding)
|
|
|
|
if single_transaction:
|
|
|
|
if single_transaction:
|
|
|
@ -449,6 +458,7 @@ def main():
|
|
|
|
hex_blob=dict(default=False, type='bool'),
|
|
|
|
hex_blob=dict(default=False, type='bool'),
|
|
|
|
force=dict(type='bool', default=False),
|
|
|
|
force=dict(type='bool', default=False),
|
|
|
|
master_data=dict(type='int', default=0, choices=[0, 1, 2]),
|
|
|
|
master_data=dict(type='int', default=0, choices=[0, 1, 2]),
|
|
|
|
|
|
|
|
skip_lock_tables=dict(type='bool', default=False),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
supports_check_mode=True,
|
|
|
|
supports_check_mode=True,
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -486,6 +496,7 @@ def main():
|
|
|
|
hex_blob = module.params["hex_blob"]
|
|
|
|
hex_blob = module.params["hex_blob"]
|
|
|
|
force = module.params["force"]
|
|
|
|
force = module.params["force"]
|
|
|
|
master_data = module.params["master_data"]
|
|
|
|
master_data = module.params["master_data"]
|
|
|
|
|
|
|
|
skip_lock_tables = module.params["skip_lock_tables"]
|
|
|
|
|
|
|
|
|
|
|
|
if len(db) > 1 and state == 'import':
|
|
|
|
if len(db) > 1 and state == 'import':
|
|
|
|
module.fail_json(msg="Multiple databases are not supported with state=import")
|
|
|
|
module.fail_json(msg="Multiple databases are not supported with state=import")
|
|
|
@ -552,7 +563,7 @@ def main():
|
|
|
|
login_password, db, target, all_databases,
|
|
|
|
login_password, db, target, all_databases,
|
|
|
|
login_port, config_file, socket, ssl_cert, ssl_key,
|
|
|
|
login_port, config_file, socket, ssl_cert, ssl_key,
|
|
|
|
ssl_ca, single_transaction, quick, ignore_tables,
|
|
|
|
ssl_ca, single_transaction, quick, ignore_tables,
|
|
|
|
hex_blob, encoding, force, master_data)
|
|
|
|
hex_blob, encoding, force, master_data, skip_lock_tables)
|
|
|
|
if rc != 0:
|
|
|
|
if rc != 0:
|
|
|
|
module.fail_json(msg="%s" % stderr)
|
|
|
|
module.fail_json(msg="%s" % stderr)
|
|
|
|
module.exit_json(changed=True, db=db_name, db_list=db, msg=stdout,
|
|
|
|
module.exit_json(changed=True, db=db_name, db_list=db, msg=stdout,
|
|
|
|