![](/img/trans.png)
[英]Having problems with Packer: amazon-ebs: Timeout waiting for SSH
[英]Packer Timeout waiting for SSH error with VirtualBox
盡管我可以在VirtualBox中手動ssh,但Packer不知道是否已建立ssh連接。
我見過同樣的問題,但是我找不到任何解決方案。
使用打包程序的目的是將現有的ovf文件轉換為Digital Ocean Droplet,以便可以在Digital Ocean服務器中使用它。
template.json
{
"builders": [
{
"type": "virtualbox-ovf",
"source_path": "/Users/seoyoochan/Desktop/work/G4M_3.1.2_OVF_demo/G4M_centos6_demo.ovf",
"ssh_username": "root",
"ssh_password": "g4mg4m$$",
"boot_command":[
"root<return>",
"g4mg4m$$<return>"
],
"headless": true,
"boot_wait": "30s",
"ssh_wait_timeout": "10000s",
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
}
],
"post-processors": ["vagrant"]
}
運行沒有調試選項的打包程序生成
➜ G4M_3.1.2_OVF_demo packer build template.json
virtualbox-ovf output will be in this color.
==> virtualbox-ovf: Downloading or copying Guest additions
virtualbox-ovf: Downloading or copying: file:///Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-ovf: Importing VM: /Users/seoyoochan/Desktop/work/G4M_3.1.2_OVF_demo/G4M_centos6_demo.ovf
==> virtualbox-ovf: Creating forwarded port mapping for SSH (host port 3249)
==> virtualbox-ovf: Starting the virtual machine...
==> virtualbox-ovf: Waiting 10s for boot...
==> virtualbox-ovf: Typing the boot command...
==> virtualbox-ovf: Waiting for SSH to become available...
==> virtualbox-ovf: Timeout waiting for SSH.
==> virtualbox-ovf: Unregistering and deleting imported VM...
==> virtualbox-ovf: Error deleting VM: VBoxManage error: VBoxManage: error: Cannot unregister the machine 'packer-virtualbox-ovf-1451547904' while it is locked
==> virtualbox-ovf: VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports
==> virtualbox-ovf: VBoxManage: error: Context: "Unregister(CleanupMode_DetachAllReturnHardDisksOnly, ComSafeArrayAsOutParam(aMedia))" at line 155 of file VBoxManageMisc.cpp
==> virtualbox-ovf: Deleting output directory...
Build 'virtualbox-ovf' errored: Timeout waiting for SSH.
==> Some builds didn't complete successfully and had errors:
--> virtualbox-ovf: Timeout waiting for SSH.
==> Builds finished but no artifacts were created.
當我在調試模式下運行時
==> virtualbox-ovf: Waiting for SSH to become available...
2015/12/31 17:43:48 packer-builder-virtualbox-ovf: 2015/12/31 17:43:48 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 127.0.0.1:3581: getsockopt: connection refused
2015/12/31 17:43:53 packer-builder-virtualbox-ovf: 2015/12/31 17:43:53 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 127.0.0.1:3581: getsockopt: connection refused
2015/12/31 17:43:58 packer-builder-virtualbox-ovf: 2015/12/31 17:43:58 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 127.0.0.1:3581: getsockopt: connection refused
發生此錯誤的原因是因為eth0設備不存在,這是因為新的MAC地址沒有被覆蓋。
有兩種解決方案:
1)刪除/etc/udev/rules.d/70-persistent-net.rules
以獲取新的MAC地址或
2)像eth1
, eth2
, eth3
一樣將eth0
名稱更改為eth1
按照上述兩種方法中的任意一種之后,通過鍵入reboot
來reboot
來賓系統。
檢查ifconfig -a
您將看到eth0
或您選擇的其他以太網名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.