Repository navigation
Open
Labels
Execution-ModuleWindowsbugbroken, incorrect, or confusing behaviorseverity-high2nd top severity, seen by most users, causes major problems
Milestone
Description
Description
Due to #56199 I changed some states using cmd.run from
- env:
- PATH: ...
to
- prepend_path: ...
but that also led to failures on (Windows) minions running Salt Minion 3000.3.
I even get two different error outputs for the same kind of thing (running in a loop):
----------
ID: something_one
Function: cmd.run
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "c:\salt\bin\lib\site-packages\salt-3000.3-py3.5.egg\salt\state.py", line 1981, in call
**cdata['kwargs'])
File "c:\salt\bin\lib\site-packages\salt-3000.3-py3.5.egg\salt\loader.py", line 1977, in wrapper
return f(*args, **kwargs)
File "c:\salt\bin\lib\site-packages\salt-3000.3-py3.5.egg\salt\states\cmd.py", line 892, in run
cret = mod_run_check(cmd_kwargs, onlyif, unless, creates)
File "c:\salt\bin\lib\site-packages\salt-3000.3-py3.5.egg\salt\states\cmd.py", line 366, in mod_run_check
cmd = __salt__['cmd.retcode'](unless, ignore_retcode=True, python_shell=True, **cmd_kwargs)
File "c:\salt\bin\lib\site-packages\salt-3000.3-py3.5.egg\salt\modules\cmdmod.py", line 2277, in retcode
**kwargs)
File "c:\salt\bin\lib\site-packages\salt-3000.3-py3.5.egg\salt\modules\cmdmod.py", line 598, in _run
run_env['PATH'] = ':'.join((prepend_path, run_env['PATH']))
KeyError: 'PATH'
Started: 14:23:09.012359
Duration: 62.504 ms
Changes:
and
----------
ID: something_two
Function: cmd.run
Result: False
Comment: 'PATH'
Started: 14:24:12.652165
Duration: 15.624 ms
Changes:
The reason for this seems to be the code for prepend_path in cmdmod.py, which looks like being Linux/Unix only (https://github.com/saltstack/salt/blob/master/salt/modules/cmdmod.py#L619). It
- uses a variable name of "PATH", but all Windows systems I looked at use "Path" and the environment variable code seems to be case-sensitive (now?)
- always uses ":" as path separator, but Windows requires ";"
Setup
Salt Minion 3000.3
Steps to Reproduce the behavior
Execute any cmd.run: state containing - prepend_path: on a Windows Minion running 3000.3
Expected behavior
It should not fail.
Metadata
Metadata
Assignees
Labels
Execution-ModuleWindowsbugbroken, incorrect, or confusing behaviorseverity-high2nd top severity, seen by most users, causes major problems
Activity
xeacott commentedon Feb 2, 2021
Ah yes... debugging this now. Question about
prepend_pathfor Windows here. Is that something that should change the system path permanently or the current shell'senv:$Path?Effectively implementing either here:
xeacott commentedon Feb 2, 2021
I'm guessing though that we wouldn't want to change the system path, unless the user specifically requested it. In either case...im thinking this is enough to add the
prepend_pathpath to.. path. lol.