chef: knife bootstrap winrm script fails

Description

bootstrap fails with “The system cannot find the batch label specified - key_create”

Chef Version

Workstation 20.5.6 Infra Client 16.0.287

Platform Version

Ubuntu 18.04 workstation Windows 10.0 18363 bootstrap target

Replication Case

knife bootstrap -o winrm -U username -P password ip.ip.ip.ip -N win10_azure -V

Client Output

 [ip.ip.ip.ip] )
 [ip.ip.ip.ip] Detected Windows Version 10.0 Build 18363
 [ip.ip.ip.ip] 
 [ip.ip.ip.ip] C:\Users\btm\Documents>goto Version10.0
 [ip.ip.ip.ip] 
 [ip.ip.ip.ip] C:\Users\btm\Documents>goto architecture_select
 [ip.ip.ip.ip]
 [ip.ip.ip.ip] C:\Users\btm\Documents>IF "AMD64" == "x86" IF not defined PROCESSOR_ARCHITEW6432
 [ip.ip.ip.ip] 
 [ip.ip.ip.ip] C:\Users\btm\Documents>goto chef_installed
 [ip.ip.ip.ip] Checking for existing Chef Infra Client installation
 [ip.ip.ip.ip] 
 [ip.ip.ip.ip] C:\Users\btm\Documents>WHERE chef-client  1>nul 2>nul
 [ip.ip.ip.ip] 
 [ip.ip.ip.ip] C:\Users\btm\Documents>If !ERRORLEVEL! == 0 (
 [ip.ip.ip.ip]  
 [ip.ip.ip.ip]  goto key_create
 [ip.ip.ip.ip] )  else (
 [ip.ip.ip.ip]
 [ip.ip.ip.ip]  goto install 
 [ip.ip.ip.ip] ) 
 [ip.ip.ip.ip] Existing Chef Infra Client installation detected, skipping download
ERROR: The following error occurred on ip.ip.ip.ip:
ERROR: cmd.exe : The system cannot find the batch label specified - key_create
         + CategoryInfo          : NotSpecified: (The system cann...ed - key_create:String) [], RemoteException
         + FullyQualifiedErrorId : NativeCommandError

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 29 (11 by maintainers)

Commits related to this issue

Most upvoted comments

We ran into something similar to this on knife version 16.0.287.

We discovered, what we think, is a mistake in this section. https://github.com/chef/chef/blob/d657a69f13d97f2ae89f39b6632f576b13822c7d/chef-config/lib/chef-config/config.rb#L95

This is used in the bootstrap.bat-file for windows and results in:

Command created for If (Test-Path “C:/Users/Administrator/AppData/Local/Temp/d1713d29-b931-4a0b-8872-1a23ca7e4e10/bootstrap.bat”) { Remove-Item -Force -Path “C:/Users/Administrator/AppData/Local/Temp/d1713d29-b931-4a0b-8872-1a23ca7e4e10/bootstrap.bat” }

@10.163.110.167<{:transport=>:negotiate, :disable_sspi=>false, :basic_auth_only=>false, :endpoint=>“http://10.163.110.167:5985/wsman”, :user=>“administrator”, :password=>“<hidden>”, :no_ssl_peer_verification=>false, :realm=>nil, :service=>nil, :ca_trust_file=>nil, :ssl_peer_fingerprint=>nil}> (If (Test-Path “C:/Users/Administrator/AppData/Local/Temp/d1713d29-b931-4a0b-8872-1a23ca7e4e10/bootstrap.bat”) { Remove-Item -Force -Path “C:/Users/Administrator/AppData/Local/Temp/d1713d29-b931-4a0b-8872-1a23ca7e4e10/bootstrap.bat” }) Exiting without bootstrapping due to download failure. Failed to download “https://www.chef.io/chef/download?p=windows&pv=2016&m=x86_64&DownloadContext=PowerShell&channel=stable&v=14.14.29” with status code 1. Failed download: download completed, but downloaded file not found The argument 'C:/chef\wget.ps1’ to the -File parameter does not exist. Provide the path to an existing ‘.ps1’ file as an argument to the -File parameter. The system cannot find the path specified. The system cannot find the path specified. + FullyQualifiedErrorId : NativeCommandError + CategoryInfo : NotSpecified: (The syntax of the command is incorrect.:String) [], RemoteException ERROR: cmd.exe : The syntax of the command is incorrect.

This is because “mkdir” does not accept paths with forward slash. so “mkdir c:/chef” will cause the syntax error.

We worked around it and hardcoded the correct path in our ‘–bootstrap-template’, ‘/data/app/chef/bootstrap/windows-chef-client-msi.erb’ hoping it would make things work again.

BUT

We hit yet another error.

[10.163.110.166] Starting chef-client to bootstrap the node… [10.163.110.166] [10.163.110.166] C:\Users\Administrator\Documents>SET “PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\ruby\bin;C:/opscode/chef\chef\bin;C:/opscode/chef\chef\embedded\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps” [10.163.110.166] [10.163.110.166] C:\Users\Administrator\Documents>chef-client -c C:/chef/client.rb -j C:/chef/first-boot.json -E win2016prod DEBUG: [WinRM] cleaning up command_id: 9BE5E690-F973-45E8-BAD8-81E94F5AA9E8 on shell_id DE4D401D-7EF1-4D0C-9037-C01CC926AB51 ERROR: The following error occurred on 10.163.110.166: ERROR: cmd.exe : ‘chef-client’ is not recognized as an internal or external command, + CategoryInfo : NotSpecified: (‘chef-client’ i…ternal command,:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError operable program or batch file.

Now chef is installing, but failed when trying to run the chef-client:

The paths added to %PATH% have similar wrong syntax (mix of forward slash and backward slash), that might make the command prompt not able to recognized the command ‘chef-client’ or the SET “PATH=”-command is run and the chef-client command is run in the same shell, so the paths are not updated before a new shell is launched.

Hope this is helpful resolving the issues.

/Martin