saltstack / saltstack/salt

Trying to pass cwd to unless fails on windows

Open
#58,790 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Confirmed severity-medium Windows
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

I am trying to run cmd.run on windows, which relies on cwd, setting it under cmd.run works just fine, however i can't pass it to unless or onlyif no matter what i try.

  cmd.run:
   - cwd: {{cwd}}
   - unless:
     - fun: cmd.run
       args:
         - keytool -list -keystore "{{cacertspath}}" -storepass {{salt['pillar.get']('java_cacert_pass', 'changeit')}} -alias {{cert_alias}}
         - {{cwd}}

The error i get is

salt.exceptions.CommandExecutionError: Unable to run command 'keytool -list -keystore "C:\Program Files\Java\jre1.8.0_251\lib\security\cacerts" -storepass changeit -alias eyn3nhupzs' with the context '{'cwd': 'C:\\Program Files\\Java\\jre1.8.0_251\\bin\', 'shell': False, 'env': {'ALLUSERSPROFILE': 'C:\ProgramData', 'APPDATA': 'C:\windows\system32\config\systemprofile\AppData\Roaming', 'CommonProgramFiles': 'C:\Program Files\Common Files', 'CommonProgramFiles(x86)': 'C:\Program Files (x86)\Common Files', 'CommonProgramW6432': 'C:\Program Files\Common Files', 'COMPUTERNAME': 'java-test', 'ComSpec': 'C:\windows\system32\cmd.exe', 'FP_NO_HOST_CHECK': 'NO', 'LOCALAPPDATA': 'C:\windows\system32\config\systemprofile\AppData\Local', 'NUMBER_OF_PROCESSORS': '1', 'OS': 'Windows_NT', 'Path': 'C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\salt;', 'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC', 'PROCESSOR_ARCHITECTURE': 'AMD64', 'PROCESSOR_IDENTIFIER': 'Intel64 Family 6 Model 79 Stepping 1, GenuineIntel', 'PROCESSOR_LEVEL': '6', 'PROCESSOR_REVISION': '4f01', 'ProgramData': 'C:\ProgramData', 'ProgramFiles': 'C:\Program Files', 'ProgramFiles(x86)': 'C:\Program Files (x86)', 'ProgramW6432': 'C:\Program Files', 'PSModulePath': 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\', 'PUBLIC': 'C:\Users\Public', 'SystemDrive': 'C:', 'SystemRoot': 'C:\windows', 'TEMP': 'C:\windows\TEMP', 'TMP': 'C:\windows\TEMP', 'USERDOMAIN': 'WORKGROUP', 'USERNAME': 'java-test$', 'USERPROFILE': 'C:\windows\system32\config\systemprofile', 'windir': 'C:\windows'}, 'stdin': None, 'stdout': -1, 'stderr': -2, 'with_communicate': True, 'timeout': None, 'bg': False}', reason: [WinError 2] The system cannot find the file specified

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Salt's cmd.run handling and how nested unless/onlyif commands are executed on Windows, using the supplied reproduction and error context. Done means cwd is honored for the conditional command without producing the reported WinError 2, with coverage for the Windows case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.