Failed to execute command on return code 1

Hi,

I’ve been trying to bootstrap a windows node using WinRm, but I keep getting the following error.

root@ubuntu01:~/chef-repo/roles# knife bootstrap windows winrm 10.44.120.19 --winrm-user administrator --winrm-password ‘Redhat#10’ --node-name Win_Node
Creating new client for Win_Node
Creating new node for Win_Node

Waiting for remote response before bootstrap.10.44.120.19 .
10.44.120.19 Response received.
Remote node responded after 0.0 minutes.
10.44.120.19 AMD64
Bootstrapping Chef on 10.44.120.19
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 1
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 2
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 3
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 4
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 5
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 6
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 7
10.44.120.19 Rendering “C:\Users\ADMINI~1\AppData\Local\Temp\bootstrap-24877-1471330698.bat” chunk 8
10.44.120.19 Checking for existing directory “C:\chef”…
10.44.120.19 Existing directory not found, creating.



10.44.120.19 echo.8FHrSvOhpZfHm1MwIy1wZ9TeAReGrz2puvKxyj6KGB9E8KYJRXecfIoLgJTMIdpe
10.44.120.19 echo.speqZLJiNFBeiyhIGETEobreBhIjdfwpS/xbWJBkwRLNWruUDExTbawvOG72h8e9
10.44.120.19 echo.nyDnani0Hfha68JjAQ==
10.44.120.19 echo.-----END CERTIFICATE-----
10.44.120.19 ) 1>C:\chef/trusted_certs/wildcard_opscode_com.crt
10.44.120.19 ‘chef-client’ is not recognized as an internal or external command,
10.44.120.19 operable program or batch file.
10.44.120.19
10.44.120.19 C:\Users\Administrator>(
10.44.120.19 echo.-----BEGIN CERTIFICATE-----
10.44.120.19 echo.MIIElDCCA3ygAwIBAgIQAf2j627KdciIQ4tyS8+8kTANBgkqhkiG9w0BAQsFADBh
10.44.120.19 echo.MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3


10.44.120.19 C:\Users\Administrator>SET "PATH=C:\Program Files\Microsoft SQL Server\100\Tools\Binn;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;;C:\Program Files (x86)\Microsoft Azure Site Recovery\home\svsystems\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib;C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin;C:\thirdparty\rrdtool-1.2.15-win32-perl58\rrdtool\Release;C:\thirdparty\rrdtool-1.2.15-win32-perl58\rrdtool\bindings\perl-shared;C:\thirdparty\php5nts;C:\thirdparty\php5nts\ext;C:\windows;C:\strawberry\perl\bin;C:\strawberry\c\bin;C:\thirdparty\Cygwin\bin;C:\Program Files\Oracle\VirtualBox;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\Redist;C:\opscode\chef\bin;C:\ruby\bin;C:\opscode\chef\bin;C:\opscode\chef\embedded\bin"
10.44.120.19
10.44.120.19 C:\Users\Administrator>chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json
ERROR: Failed to execute command on 10.44.120.19 return code 1

Can somebody help me with this??

Tried again, ended with this-

10.44.120.19 C:\Users\Administrator>SET
10.44.120.19 "PATH=C:\Program Files\Microsoft SQL Server\100\Tools\Binn;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;;C:\Program Files (x86)\Microsoft Azure Site Recovery\home\svsystems\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib;C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin;C:\thirdparty\rrdtool-1.2.15-win32-perl58\rrdtool\Release;C:\thirdparty\rrdtool-1.2.15-win32-perl58\rrdtool\bindings\perl-shared;C:\thirdparty\php5nts;C:\thirdparty\php5nts\ext;C:\windows;C:\strawberry\perl\bin;C:\strawberry\c\bin;C:\thirdparty\Cygwin\bin;C:\Program Files\Oracle\VirtualBox;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\Redist;C:\opscode\chef\bin;C:\ruby\bin;C:\opscode\chef\bin;C:\opscode\chef\embedded\bin"
10.44.120.19
10.44.120.19
10.44.120.19 C:\Users\Administrator>chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json
10.44.120.19 [2016-08-15T22:28:39-07:00] INFO: *** Chef 12.13.37 ***
10.44.120.19 [2016-08-15T22:28:39-07:00] INFO: Platform: x64-mingw32
10.44.120.19 [2016-08-15T22:28:39-07:00] INFO: Chef-client pid: 3736
10.44.120.19 [2016-08-15T22:29:08-07:00] INFO: HTTP Request Returned 401 Unauthorized: error
10.44.120.19
10.44.120.19 ================================================================================
10.44.120.19 Chef encountered an error attempting to load the node data for "Win_Node"
10.44.120.19 ================================================================================
10.44.120.19
10.44.120.19 Authentication Error:
10.44.120.19 ---------------------
10.44.120.19 Failed to authenticate to the chef server (http 401).
10.44.120.19 The request failed because your clock has drifted by more than 15 minutes.
10.44.120.19 Syncing your clock to an NTP Time source should resolve the issue.
10.44.120.19
10.44.120.19 Platform:
10.44.120.19 ---------
10.44.120.19 x64-mingw32
10.44.120.19
10.44.120.19 [2016-08-15T22:29:08-07:00] ERROR: Running exception handlers
10.44.120.19 [2016-08-15T22:29:08-07:00] ERROR: Exception handlers complete
10.44.120.19 [2016-08-15T22:29:08-07:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
10.44.120.19 [2016-08-15T22:29:08-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
10.44.120.19 [2016-08-15T22:29:08-07:00] FATAL: Net::HTTPServerException: 401 "Unauthorized"
ERROR: Failed to execute command on 10.44.120.19 return code 1

Hello @waseemahammed

The second error you have is because of a time difference between your node and the Chef server.

10.44.120.19 Authentication Error:
10.44.120.19 ---------------------
10.44.120.19 Failed to authenticate to the chef server (http 401).
10.44.120.19 The request failed because your clock has drifted by more than 15 minutes.
10.44.120.19 Syncing your clock to an NTP Time source should resolve the issue.
10.44.120.19 

I’ve found a lot of the Chef errors are quite well documented

https://docs.chef.io/errors.html#synchronize-the-clock-on-your-host

With the first error can you run the

chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json 

With debug on ( -l debug on the command line)

1 Like

Tried both and worked :slight_smile: Thank you @chris_sullivan :smile: