From 9716a4d58861d6c1d81d10e0b75f3fb458ea061b Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Tue, 21 Jun 2022 16:17:53 +0200 Subject: [PATCH] Fix sh not seeing errors for command before the pipe sh is missing the pipefail flag. We must use bash for this. --- plugins/modules/mysql_db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/mysql_db.py b/plugins/modules/mysql_db.py index 5acdb65..355b19f 100644 --- a/plugins/modules/mysql_db.py +++ b/plugins/modules/mysql_db.py @@ -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