Strip spaces in module names in explicit actions (#71040)

* Strip spaces in module names in explicit actions

Change:
- When an action is called like "action: copy foo=bar", strip spaces
  around the action name.
- This allows "action: copy        foo=bar" to work as expected.

Test Plan:
- New integration tests

Tickets:
- Fixes #62136

Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
Rick Elrod 2020-08-03 10:30:45 -05:00 committed by GitHub
parent 701c638757
commit 74c14c6743
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- "task parsing - strip spaces from action name when using ``action: foo bar=baz`` form. (https://github.com/ansible/ansible/issues/62136)"

View file

@ -131,9 +131,9 @@ class ModuleArgsParser:
tokens = split_args(module_string)
if len(tokens) > 1:
return (tokens[0], " ".join(tokens[1:]))
return (tokens[0].strip(), " ".join(tokens[1:]))
else:
return (tokens[0], "")
return (tokens[0].strip(), "")
def _normalize_parameters(self, thing, action=None, additional_args=None):
'''

View file

@ -202,3 +202,16 @@
- should_not_omit_1 is defined
- should_not_omit_2 is defined
- should_not_omit_3 == "__omit_place_holder__afb6b9bc3d20bfeaa00a1b23a5930f89"
- name: Ensure module names are stripped of extra spaces (local_action)
local_action: set_fact b="b"
register: la_set_fact_b
- name: Ensure module names are stripped of extra spaces (action)
action: set_fact c="c"
register: la_set_fact_c
- assert:
that:
- b == "b"
- c == "c"