From d59d09fb98aa7d7256347c09b216cd3bb05893e8 Mon Sep 17 00:00:00 2001 From: Wim Jeantine-Glenn Date: Wed, 13 Nov 2024 19:33:49 -0600 Subject: [PATCH] include ! as a shell word. closes #4386 --- examples/playbooks/rule-command-instead-of-shell-pass.yml | 5 +++++ src/ansiblelint/rules/command_instead_of_shell.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/playbooks/rule-command-instead-of-shell-pass.yml b/examples/playbooks/rule-command-instead-of-shell-pass.yml index 8bbaef3070..4e44f080d8 100644 --- a/examples/playbooks/rule-command-instead-of-shell-pass.yml +++ b/examples/playbooks/rule-command-instead-of-shell-pass.yml @@ -58,3 +58,8 @@ set -x ls foo? changed_when: false + + - name: Use ! for negation + ansible.builtin.shell: + cmd: "! crontab -l" + changed_when: false diff --git a/src/ansiblelint/rules/command_instead_of_shell.py b/src/ansiblelint/rules/command_instead_of_shell.py index d62e80bc54..03e9ef9b74 100644 --- a/src/ansiblelint/rules/command_instead_of_shell.py +++ b/src/ansiblelint/rules/command_instead_of_shell.py @@ -69,7 +69,7 @@ def matchtask( return False jinja_stripped_cmd = self.unjinja(get_cmd_args(task)) - return not any(ch in jinja_stripped_cmd for ch in "&|<>;$\n*[]{}?`") + return not any(ch in jinja_stripped_cmd for ch in "&|<>;$\n*[]{}?`!") return False def transform(