- Packer
- QEMU
- Docker
$ docker run -it -v `pwd`:/tmp/host --rm ubuntu:16.04
# apt update
# apt install -y vim cloud-utils
# cloud-localds /tmp/host/cloud.img /tmp/host/cloud.cfg
$ packer build template.json
$ docker run -it -v `pwd`:/tmp/host --rm ubuntu:16.04
# apt update
# apt install -y vim cloud-utils
# cloud-localds /tmp/host/cloud.img /tmp/host/cloud.cfg
$ packer build template.json
#cloud-config | |
password: ubuntu | |
ssh_pwauth: true | |
chpasswd: | |
expire: false |
{ | |
"builders": | |
[ | |
{ | |
"type": "qemu", | |
"iso_url": "ubuntu-16.04-server-cloudimg-amd64-disk1.img", | |
"iso_checksum": "3a4b7f6115ca074c4728e4628ca73160e6b7ef6995db3c382015545940568939", | |
"iso_checksum_type": "sha256", | |
"disk_image": true, | |
"output_directory": "image", | |
"disk_size": 5000, | |
"format": "qcow2", | |
"disk_compression": true, | |
"headless": true, | |
"accelerator": "none", | |
"ssh_username": "ubuntu", | |
"ssh_password": "ubuntu", | |
"ssh_port": 22, | |
"ssh_wait_timeout": "300s", | |
"vm_name": "ubuntu", | |
"use_default_display": true, | |
"qemuargs": [ | |
["-m", "2048M"], | |
["-smp", "2"], | |
["-fda", "cloud.img"], | |
["-serial", "mon:stdio"] | |
] | |
} | |
] | |
} |
This is working for me, in case someone like me hit this
{
"builders": [
{
"type": "qemu",
"iso_url": "ubuntu-22.04-server-cloudimg-amd64.img",
"iso_checksum": "md5:9688fc9011dcd4d960620d2ebb98a639",
"ssh_username": "ubuntu",
"ssh_password": "a",
"ssh_timeout": "1m",
"ssh_port": 2222,
"skip_nat_mapping": true,
"disk_size": "40G",
"disk_image": true,
"disk_compression": true,
"format": "qcow2",
"headless": true,
"accelerator": "kvm",
"output_directory": "images",
"qemuargs": [
[ "-machine", "accel=kvm,type=q35" ],
[ "-cpu", "host" ],
[ "-m", "2G" ],
[ "-smp", "2" ],
[ "-nographic" ],
[ "-device", "virtio-net-pci,netdev=net0" ],
[ "-netdev", "user,id=net0,", "hostfwd=tcp::2222-:22" ],
[ "-cdrom", "seed.img" ]
],
"shutdown_command": "echo a |sudo -S shutdown -P now",
"boot_command": [],
"vm_name": "jammy"
}
]
}
keypoint is
Have you by chance been successful with this setup? The boot runs but packer is unable to ssh into the box.