我是一名新手,正在学习使用Packer。我已经详细研究了上面提到的问题。我目前正在尝试创建一个Ubuntu 32位虚拟机,在Windows 10操作系统上运行Packer。当安装完成并且虚拟机重启后,在我的虚拟机上出现GUI登录提示时,Packer仍在运行,而我的主机Windows显示正在等待SSH可用。如何最好地启用ssh以供Packer用于连接我的虚拟机。以下是我的json.template:
{
"builders": [
{
"type": "virtualbox-iso",
"vm_name": "{{ user `alias` }}",
"vboxmanage": [
[ "modifyvm", "{{.Name}}", "--cpus", "1" ],
[ "modifyvm", "{{.Name}}", "--memory", "{{user `ram`}}" ],
[ "modifyvm", "{{.Name}}", "--clipboard", "bidirectional" ],
[ "modifyvm", "{{.Name}}", "--draganddrop", "bidirectional" ],
[ "modifyvm", "{{.Name}}", "--audio", "none" ],
[ "modifyvm", "{{.Name}}", "--nic1", "intnet"],
[ "modifyvm", "{{.Name}}","--nic2", "null"],
[ "modifyvm", "{{.Name}}","--vram", "16"],
[ "modifyvm", "{{.Name}}","--mouse", "usbtablet"]
],
"guest_os_type": "Ubuntu",
"iso_url": "{{ user `iso_url` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_checksum_type": "md5",
"disk_size": "{{ user `disk_size` }}",
"ssh_username": "{{ user `ssh_username` }}",
"ssh_password": "{{ user `ssh_password` }}",
"ssh_timeout": "{{ user `ssh_timeout` }}",
"guest_additions_mode": "attach",
"headless": "{{ user `headless` }}",
"boot_wait": "3s",
"boot_command": [
"<enter><wait><esc><enter><wait>",
"/install/vmlinuz<wait>",
" {{user `preseed_path`}}",
" debian-installer/locale=en_US console-setup/ask_detect=false<wait>",
" console-setup/layoutcode=us<wait>",
" keyboard-configuration/layoutcode=us<wait>",
" passwd/user-password={{ user `ssh_password` }}<wait>",
" passwd/user-password-again={{ user `ssh_password` }}<wait>",
" finish-install/reboot_in_progress=note<wait>",
" netcfg/use_autoconfig=false<wait>",
" cdrom-detect/eject boolean=false<wait>",
" initrd=/install/initrd.gz<wait>",
"<enter><wait>"
],
"shutdown_command": "sudo shutdown -h now"
}
],
"post-processors": [
{
"type": "vagrant",
"output": "C://{{ user `box_name` }}.box"
}
],
"variables": {
"headless": "false",
"iso_checksum": "7",
"iso_url": "{{file path}}",
"disk_size": "256000",
"alias": "packervm",
"box_name": "ubuntu_custom",
"ssh_timeout": "20m",
"ssh_username": "{{username}}",
"ssh_password": "{{password}}",
"preseed_path":"file=/cdrom/preseed/preseed.cfg",
"ram": "2048"
}
}
附言:是的,在来这里问问题之前,我已经查看过模板了。