Ram Krishna
Ram Krishna

Reputation: 301

Knife bootstrap failing

I am working on VM automation on windows and have created a cookbook for the same, once the VM is created I am trying to bootstrap the node with chef server running the following command (written under powershell resource).

"knife bootstrap windows winrm $myip -x $myusername -P $mypassword -N $VMName"

If I execute this command directly on my powershell window it runs properly, plus when execute a test.ps1 file on CMD it runs properly:

"C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:\Users\test.ps1

The error which I get when running cookbook is :

Recipe: vmauto::default
  * powershell_script[vmcreate] action run[2017-05-08T16:59:35+05:30] INFO: Processing powershell_script[vmcreate] action run (vmauto::default line 9)

[execute] Bootstrap the VM created to chef server
          knife bootstrap windows winrm 172.xx.xx.xx -x 'admin' -P 'password' -N TestVM32
          WARNING: No knife configuration file foundWARN: Failed to read the private key C:\chef\client.pem: #
          ERROR: Your private key could not be loaded from C:\chef\client.pem
          Check your configuration file and ensure that your private key is readable
          Bootstrap completed

[2017-05-08T16:59:45+05:30] INFO: powershell_script[vmcreate] ran successfully
    - execute "C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:/Users/xxxx.xxxx/AppData/Local/Temp/chef-script20170508-14000-18hpixg.ps1"
[2017-05-08T16:59:45+05:30] WARN: Skipping final node save because override_runlist was given
[2017-05-08T16:59:45+05:30] INFO: Chef Run complete in 10.046277 seconds
[2017-05-08T16:59:45+05:30] INFO: Skipping removal of unused files from the cache

Upvotes: 0

Views: 484

Answers (1)

coderanger
coderanger

Reputation: 54251

It sounds like there is no knife config being found so it doesn't have the parameters for the bootstrap. I would pass it in explicitly via --config rather than trying to sort out various user and home dir issues for locating the .chef/knife.rb.

Upvotes: 0

Related Questions