saltstack-formulas / docker-formula

Install and set up Docker
http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
136 stars 330 forks source link

[Question] Windows support id command not found #274

Closed dangerousplay closed 3 years ago

dangerousplay commented 3 years ago

Executing this formula on Windows 10 Vagrant Box peru/windows-10-enterprise-x64-eval causes the execution to fail due to not found the id -un command. Does Windows have id command distribution? I'm using this formula to configure a workstation, Kubernetes formula also uses this command to look up the root user.

Error log:

Rendering SLS 'base:docker.compose.software.alternatives.install' failed: Problem running salt function in Jinja template: Unable to run command 'id -un' with the context '{'cwd': 'C:\\Users\\vagrant', 'shell': False, 'env': {'ALLUSERSPROFILE': 'C:\\ProgramData', 'APPDATA': 'C:\\Users\\vagrant\\AppData\\Roaming', 'CommonProgramFiles': 'C:\\Program Files\\Common Files', 'CommonProgramFiles(x86)': 'C:\\Program Files (x86)\\Common Files', 'CommonProgramW6432': 'C:\\Program Files\\Common Files', 'COMPUTERNAME': 'VAGRANTVM', 'ComSpec': 'C:\\Windows\\system32\\cmd.exe', 'DriverData': 'C:\\Windows\\System32\\Drivers\\DriverData', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Users\\vagrant', 'LOCALAPPDATA': 'C:\\Users\\vagrant\\AppData\\Local', 'LOGONSERVER': '\\\\VAGRANTVM', 'NUMBER_OF_PROCESSORS': '1', 'OneDrive': 'C:\\Users\\vagrant\\OneDrive', 'OS': 'Windows_NT', 'Path': 'C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;c:\\salt;C:\\Users\\vagrant\\AppData\\Local\\Microsoft\\WindowsApps', 'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL', 'PROCESSOR_ARCHITECTURE': 'AMD64', 'PROCESSOR_IDENTIFIER': 'AMD64 Family 23 Model 49 Stepping 0, AuthenticAMD', 'PROCESSOR_LEVEL': '23', 'PROCESSOR_REVISION': '3100', 'ProgramData': 'C:\\ProgramData', 'ProgramFiles': 'C:\\Program Files', 'ProgramFiles(x86)': 'C:\\Program Files (x86)', 'ProgramW6432': 'C:\\Program Files', 'PROMPT': '$P$G', 'PSModulePath': 'C:\\Users\\vagrant\\Documents\\WindowsPowerShell\\Modules;C:\\Program Files\\WindowsPowerShell\\Modules;C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules', 'PUBLIC': 'C:\\Users\\Public', 'Python': 'C:\\salt\\bin\\python.exe', 'SaltDir': 'C:\\salt', 'Script': 'C:\\salt\\bin\\Scripts\\salt-call', 'SystemDrive': 'C:', 'SystemRoot': 'C:\\Windows', 'TEMP': 'C:\\Users\\vagrant\\AppData\\Local\\Temp', 'TMP': 'C:\\Users\\vagrant\\AppData\\Local\\Temp', 'USERDOMAIN': 'VAGRANTVM', 'USERDOMAIN_ROAMINGPROFILE': 'VAGRANTVM', 'USERNAME': 'vagrant', 'USERPROFILE': 'C:\\Users\\vagrant', '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
       C:\Users\vagrant\AppData\Local\Temp\kitchen\var\cache\salt\minion\files\base\docker/osfamilymap.yaml(17):
       ---
       [...]
       ---
       {%- if grains.os == 'MacOS' %}
           {%- set rootuser = salt['cmd.run']("stat -f '%Su' /dev/console") %}
           {%- set rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
       {%- elif grains.os == 'Windows' %}
           {%- set rootuser = salt['cmd.run']("id -un") %}    <======================
       {%- endif %}
myii commented 3 years ago

@dangerousplay Thanks for the report. We've encountered this before in another formula. Can you try this workaround and let me know if it works out for you?

dangerousplay commented 3 years ago

Sorry for the late response. This seems to work out however, the installation step is hanging on using archive mode as upstream.

noelmcloughlin commented 3 years ago

299