mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
BUGFIX 7811: Adding file existence check when performing mysql import on a .gz or .bz2 file, otherwise Ansible will not notice that the underlying *nix command silently died.
This commit is contained in:
parent
9c7ea82ad2
commit
b09a144724
1 changed files with 2 additions and 2 deletions
|
@ -148,9 +148,9 @@ def db_import(module, host, user, password, db_name, target, port, socket=None):
|
||||||
cmd += " --host=%s --port=%s" % (pipes.quote(host), pipes.quote(port))
|
cmd += " --host=%s --port=%s" % (pipes.quote(host), pipes.quote(port))
|
||||||
cmd += " -D %s" % pipes.quote(db_name)
|
cmd += " -D %s" % pipes.quote(db_name)
|
||||||
if os.path.splitext(target)[-1] == '.gz':
|
if os.path.splitext(target)[-1] == '.gz':
|
||||||
cmd = 'gunzip < ' + pipes.quote(target) + ' | ' + cmd
|
cmd = 'test -e ' + pipes.quote(target) + ' && gunzip < ' + pipes.quote(target) + ' | ' + cmd
|
||||||
elif os.path.splitext(target)[-1] == '.bz2':
|
elif os.path.splitext(target)[-1] == '.bz2':
|
||||||
cmd = 'bunzip2 < ' + pipes.quote(target) + ' | ' + cmd
|
cmd = 'test -e ' + pipes.quote(target) + ' && bunzip2 < ' + pipes.quote(target) + ' | ' + cmd
|
||||||
else:
|
else:
|
||||||
cmd += " < %s" % pipes.quote(target)
|
cmd += " < %s" % pipes.quote(target)
|
||||||
rc, stdout, stderr = module.run_command(cmd, use_unsafe_shell=True)
|
rc, stdout, stderr = module.run_command(cmd, use_unsafe_shell=True)
|
||||||
|
|
Loading…
Reference in a new issue