diff --git a/examples/playbooks/transform-no-free-form.transformed.yml b/examples/playbooks/transform-no-free-form.transformed.yml index d7666259bc..d9e238e249 100644 --- a/examples/playbooks/transform-no-free-form.transformed.yml +++ b/examples/playbooks/transform-no-free-form.transformed.yml @@ -13,3 +13,7 @@ args: executable: /bin/bash changed_when: false + + - name: Example task with usage for '=' as module params + ansible.builtin.debug: + msg: "'Hello there world'" diff --git a/examples/playbooks/transform-no-free-form.yml b/examples/playbooks/transform-no-free-form.yml index 1a706e9ed1..54cb266b12 100644 --- a/examples/playbooks/transform-no-free-form.yml +++ b/examples/playbooks/transform-no-free-form.yml @@ -9,3 +9,6 @@ - name: Use raw to echo ansible.builtin.raw: executable=/bin/bash echo foo # <-- don't use executable= changed_when: false + + - name: Example task with usage for '=' as module params + ansible.builtin.debug: msg='Hello there world' diff --git a/src/ansiblelint/rules/no_free_form.py b/src/ansiblelint/rules/no_free_form.py index 7d6faa8cee..60cb1e9f99 100644 --- a/src/ansiblelint/rules/no_free_form.py +++ b/src/ansiblelint/rules/no_free_form.py @@ -111,7 +111,7 @@ def filter_values( if filter_key not in val: return True - [k, v] = val.split("=") + [k, v] = val.split(filter_key) filter_dict[k] = v return False @@ -121,14 +121,18 @@ def filter_values( k, v = task.popitem(False) # identify module as key and process its value if len(k.split(".")) == 3 and isinstance(v, str): - # Filter the module options and command - module_opts["cmd"] = " ".join( - [ - item - for item in v.split(" ") - if filter_values(item, "=", module_opts) - ], - ) + # if it is a message + if "msg" in v: + filter_values(v, "=", module_opts) + else: + # Filter the module options and command + module_opts["cmd"] = " ".join( + [ + item + for item in v.split(" ") + if filter_values(item, "=", module_opts) + ], + ) sorted_module_opts = {} for key in sorted( @@ -152,7 +156,7 @@ def filter_values( [ item for item in v.split(" ") - if filter_values(item, "executable=", exec_key_val) + if filter_values(item, "=", exec_key_val) ], ) task["args"] = exec_key_val diff --git a/test/test_transformer.py b/test/test_transformer.py index 2be1c09073..1dd5b47b37 100644 --- a/test/test_transformer.py +++ b/test/test_transformer.py @@ -136,7 +136,7 @@ def fixture_runner_result( ), pytest.param( "examples/playbooks/transform-no-free-form.yml", - 2, + 3, True, True, id="no_free_form_transform",