diff --git a/examples/playbooks/transform-no-free-form.transformed.yml b/examples/playbooks/transform-no-free-form.transformed.yml index 7cc5f0ad77..e947c345af 100644 --- a/examples/playbooks/transform-no-free-form.transformed.yml +++ b/examples/playbooks/transform-no-free-form.transformed.yml @@ -8,6 +8,12 @@ cmd: touch foo changed_when: false + - name: Create a placefolder file + ansible.builtin.command: # <-- command can also go first + chdir: /tmp + cmd: touch bar + changed_when: false + - name: Use raw to echo ansible.builtin.raw: echo foo # <-- don't use executable= args: diff --git a/examples/playbooks/transform-no-free-form.yml b/examples/playbooks/transform-no-free-form.yml index b651609dd2..c57da0ce3e 100644 --- a/examples/playbooks/transform-no-free-form.yml +++ b/examples/playbooks/transform-no-free-form.yml @@ -6,6 +6,10 @@ ansible.builtin.command: chdir=/tmp touch foo # <-- don't use shorthand changed_when: false + - name: Create a placefolder file + ansible.builtin.command: touch bar chdir=/tmp # <-- command can also go first + changed_when: false + - name: Use raw to echo ansible.builtin.raw: executable=/bin/bash echo foo # <-- don't use executable= changed_when: false diff --git a/src/ansiblelint/rules/no_free_form.py b/src/ansiblelint/rules/no_free_form.py index a0322d9bba..13489efa3d 100644 --- a/src/ansiblelint/rules/no_free_form.py +++ b/src/ansiblelint/rules/no_free_form.py @@ -80,7 +80,7 @@ def matchtask( "win_command", "win_shell", ): - if self.cmd_shell_re.match(action_value): + if self.cmd_shell_re.search(action_value): fail = True else: fail = True diff --git a/test/test_transformer.py b/test/test_transformer.py index 6d11d0a7f1..51e97d5f4a 100644 --- a/test/test_transformer.py +++ b/test/test_transformer.py @@ -143,7 +143,7 @@ def fixture_runner_result( ), pytest.param( "examples/playbooks/transform-no-free-form.yml", - 4, + 5, True, True, id="no_free_form_transform",