diff options
author | Andrew Klychkov <aaklychkov@mail.ru> | 2020-02-27 16:51:23 +0300 |
---|---|---|
committer | Matt Clay <matt@mystile.com> | 2020-03-02 15:25:14 -0800 |
commit | f90c7411e81734aa37844c618829aa736d47854f (patch) | |
tree | 21243f7c0c82c10f95fb36ad89ec19829e0881bd | |
parent | cddecf8c056436292a5c62df790db03808666471 (diff) | |
download | ansible-f90c7411e81734aa37844c618829aa736d47854f.tar.gz |
Bugfix of 65351: mysql_db create dump with CREATE DATABASE and USE instruction
-rw-r--r-- | changelogs/fragments/67767-mysql_db_fix_bug_introduced_by_56721.yml | 2 | ||||
-rw-r--r-- | lib/ansible/modules/database/mysql/mysql_db.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/changelogs/fragments/67767-mysql_db_fix_bug_introduced_by_56721.yml b/changelogs/fragments/67767-mysql_db_fix_bug_introduced_by_56721.yml new file mode 100644 index 0000000000..e09a54c179 --- /dev/null +++ b/changelogs/fragments/67767-mysql_db_fix_bug_introduced_by_56721.yml @@ -0,0 +1,2 @@ +bugfixes: +- mysql_db - fix bug in the ``db_import`` function introduced by https://github.com/ansible/ansible/pull/56721 (https://github.com/ansible/ansible/issues/65351). diff --git a/lib/ansible/modules/database/mysql/mysql_db.py b/lib/ansible/modules/database/mysql/mysql_db.py index 132783bbd2..e7b260e9e1 100644 --- a/lib/ansible/modules/database/mysql/mysql_db.py +++ b/lib/ansible/modules/database/mysql/mysql_db.py @@ -203,10 +203,14 @@ def db_dump(module, host, user, password, db_name, target, all_databases, port, cmd += " --socket=%s" % shlex_quote(socket) else: cmd += " --host=%s --port=%i" % (shlex_quote(host), port) + if all_databases: cmd += " --all-databases" - else: + elif len(db_name) > 1: cmd += " --databases {0} --skip-lock-tables".format(' '.join(db_name)) + else: + cmd += " %s" % shlex_quote(' '.join(db_name)) + if single_transaction: cmd += " --single-transaction=true" if quick: |