Fix sh not seeing errors for command before the pipe

sh is missing the pipefail flag. We must use bash for this.
This commit is contained in:
Laurent Indermuehle 2022-06-21 16:17:53 +02:00
commit 9716a4d588
No known key found for this signature in database
GPG key ID: 93FA944C9F34DD09

View file

@ -423,12 +423,12 @@ def db_dump(module, host, user, password, db_name, target, all_databases, port,
path = module.get_bin_path('xz', True)
if path:
cmd = '%s | %s > %s' % (cmd, path, shlex_quote(target))
cmd = 'set -o pipefail && %s | %s > %s' % (cmd, path, shlex_quote(target))
else:
cmd += " > %s" % shlex_quote(target)
executed_commands.append(cmd)
rc, stdout, stderr = module.run_command(cmd, use_unsafe_shell=True)
rc, stdout, stderr = module.run_command(cmd, use_unsafe_shell=True, executable='bash')
return rc, stdout, stderr