Repository navigation
add a function for the centralised list of shell/command options - #81558
nama1arpit wants to merge 3 commits into
Conversation
|
Added the changelog fragment |
This comment was marked as resolved.
This comment was marked as resolved.
|
|
||
| # FIXME: make the retrieval of this list of shell/command options a function, so the list is centralized | ||
| if check_raw and k not in ('creates', 'removes', 'chdir', 'executable', 'warn', 'stdin', 'stdin_add_newline', 'strip_empty_ends'): | ||
| if check_raw and k not in get_command_args(): |
There was a problem hiding this comment.
Although the current list of key-value arguments is out-of-date, I don't think that's a good reason to move them into module_utils. The main reason is that the list of valid arguments varies by module. There are currently 6 different modules that make use of check_raw:
ansible/lib/ansible/constants.py
Lines 116 to 117 in 116948c
While there are arguments in common between those modules, they're not all the same. For example,
the win_command module does not accept strip_empty_ends.
It seems like we'd be better off checking the actual list of arguments accepted by the module we're parsing for, and use those when calling parse_kv, instead of using check_raw to activate a hard-coded list.
There was a problem hiding this comment.
It looks like the approach in this PR was suggested by @sivel in #73005 (comment) -- although that seems to have been based on a ~9 year old code comment that predates the split to collections:
ansible/lib/ansible/parsing/splitter.py
Lines 90 to 91 in 29aea9f
There was a problem hiding this comment.
I understand the concern and I would need some more guidance to resolve this as I am not very familiar with the codebase. I can see that parse_kv is used in a few places. Should I try to get the actual list of arguments accepted by the module here?
ansible/lib/ansible/cli/console.py
Lines 204 to 206 in 29aea9f
There was a problem hiding this comment.
Currently there isn't a good way to get the supported action/module args from the action name while parsing args.
Rather than implementing that (a non-trivial task), one option would be to add cmd to the existing hard-coded list used by the splitter when check_raw is enabled.
While that would allow resolving #73005, it would also have the unwanted affect of changing how the raw action is handled.
For example, a playbook with a task such as the following would be affected:
- raw: some_command -o cmd=something
Currently this results in running: some_command -o cmd=something
With cmd in the list of args used by check_raw, it would instead become: some_command -o
This should be discussed further before we commit to a solution.
|
Some planned features may make this more generically possible in the not-too-distant future. |
|
depends on #79720 |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
SUMMARY
Fixes #73005
This PR
cmdargument to theshell/commandoptionsshellmodule options to a centralized function for usage insplitter.pyISSUE TYPE
ADDITIONAL INFORMATION
Integration testing:
Sanity testing: