我正在开发Windows上的虚拟机自动化并创建了相同的食谱,一旦创建了虚拟机,我正在尝试使用运行以下命令的厨师服务器来引导节点(在powershell资源下编写) .
"knife bootstrap windows winrm $myip -x $myusername -P $mypassword -N $VMName"
如果我直接在我的powershell窗口上执行此命令,它可以正常运行,另外当在CMD上执行 test.ps1
文件时,它正常运行:
"C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None -File "C:\Users\test.ps1
运行cookbook时出现的错误是:
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
1 回答
听起来好像没有找到刀配置,所以它没有引导程序的参数 . 我会通过
--config
显式传递它,而不是试图找出用于定位.chef/knife.rb
的各种用户和主目录问题 .