From 951a8284b77c2602a18de73fef1ef2c9e36cc497 Mon Sep 17 00:00:00 2001 From: nkakouros Date: Wed, 25 May 2022 09:26:51 +0300 Subject: [PATCH] Accept `shell` when `executable` is set (#2176) Co-authored-by: Sorin Sbarnea --- src/ansiblelint/rules/command_instead_of_shell.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ansiblelint/rules/command_instead_of_shell.py b/src/ansiblelint/rules/command_instead_of_shell.py index 45b0aab6af..6015b0fbc6 100644 --- a/src/ansiblelint/rules/command_instead_of_shell.py +++ b/src/ansiblelint/rules/command_instead_of_shell.py @@ -116,6 +116,12 @@ def matchtask( # Use unjinja so that we don't match on jinja filters # rather than pipes if task["action"]["__ansible_module__"] in ["shell", "ansible.builtin.shell"]: + # Since Ansible 2.4, the `command` module does not accept setting + # the `executable`. If the user needs to set it, they have to use + # the `shell` module. + if "executable" in task["action"]: + return False + if "cmd" in task["action"]: jinja_stripped_cmd = self.unjinja(task["action"].get("cmd", [])) else: