diff --git a/src/ansiblelint/rules/ShellWithoutPipefail.py b/src/ansiblelint/rules/ShellWithoutPipefail.py index 89b572b01a..ebd0771d15 100644 --- a/src/ansiblelint/rules/ShellWithoutPipefail.py +++ b/src/ansiblelint/rules/ShellWithoutPipefail.py @@ -2,6 +2,7 @@ from typing import Any, Dict, Union from ansiblelint.rules import AnsibleLintRule +from ansiblelint.utils import convert_to_boolean class ShellWithoutPipefail(AnsibleLintRule): @@ -39,4 +40,5 @@ def matchtask(self, task: Dict[str, Any]) -> Union[bool, str]: return bool( self._pipe_re.search(unjinjad_cmd) and not self._pipefail_re.match(unjinjad_cmd) + and not convert_to_boolean(task['action'].get('ignore_errors', False)) ) diff --git a/test/TestShellWithoutPipefail.py b/test/TestShellWithoutPipefail.py index c0c85457e6..f724dd876d 100644 --- a/test/TestShellWithoutPipefail.py +++ b/test/TestShellWithoutPipefail.py @@ -65,6 +65,10 @@ - shell: | set -o pipefail df | grep '/dev' + + - name: should not fail due to ignore_errors being true + shell: false | cat + ignore_errors: true '''