Skip to content

Commit

Permalink
args in free-form syntax can come before or after implicit cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
Qalthos committed Jun 10, 2024
1 parent c2f0510 commit 190942f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions examples/playbooks/transform-no-free-form.transformed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions examples/playbooks/transform-no-free-form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/no_free_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 190942f

Please sign in to comment.