Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to pass cwd to unless fails on windows #58790

Open
markododa opened this issue Oct 22, 2020 · 3 comments
Open

Trying to pass cwd to unless fails on windows #58790

markododa opened this issue Oct 22, 2020 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around Windows
Milestone

Comments

@markododa
Copy link

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

@markododa markododa added the Bug broken, incorrect, or confusing behavior label Oct 22, 2020
@markododa
Copy link
Author

Seems like onlyif and unless always fail silently, using the - fun notation only sends the error to the master.
Here is salt version from the master:

Salt Version:
           Salt: 3000.3
 
Dependency Versions:
           cffi: 1.14.3
       cherrypy: Not Installed
       dateutil: 2.7.3
      docker-py: Not Installed
          gitdb: 2.0.5
      gitpython: 2.1.11
         Jinja2: 2.10
        libgit2: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: 2.20
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.16 (default, Oct 10 2019, 22:02:15)
   python-gnupg: Not Installed
         PyYAML: 3.13
          PyZMQ: 17.1.2
          smmap: 2.0.5
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.1
 
System Versions:
           dist: debian 10.6 
         locale: UTF-8
        machine: x86_64
        release: 4.19.0-11-cloud-amd64
         system: Linux
        version: debian 10.6 

Windows minion is installed from Salt-Minion-3001.1-Py3-AMD64-Setup.exe
Might be because of python versions difference.

Here is a sample state

just_cd:
  cmd.run:
    - cmd: cd
    - cwd: 'C:\Program Files'

only_if_args:
  cmd.run:
   - cmd: cd
   - cwd: 'C:\Program Files'
   - onlyif:
     - fun: cmd.run
       args:
         - cd 

only_if_short_cwd:
  cmd.run:
   - cmd: cd
   - cwd: 'C:\Program Files'
   - onlyif:
     - fun: cmd.run
       args:
         - cd
         - 'C:\'
cd:
  cmd.run:
   - cwd: 'C:\Program Files'
   - onlyif: cd

@cmcmarrow cmcmarrow added the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Nov 2, 2020
@cmcmarrow
Copy link
Contributor

I got onlyif and unless to fail silently too.

@cmcmarrow cmcmarrow added Confirmed Salt engineer has confirmed bug/feature - often including a MCVE and removed needs-triage Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged labels Nov 9, 2020
@max-arnold
Copy link
Contributor

I'm not 100% sure, but the cwd issue might be fixed in 3002: #57825

@cmcmarrow cmcmarrow removed their assignment Jan 8, 2021
@sagetherage sagetherage added this to the Approved milestone Jan 19, 2021
@sagetherage sagetherage added the severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around label Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around Windows
Projects
None yet
Development

No branches or pull requests

4 participants