packer-plugin-qemu
packer-plugin-qemu copied to clipboard
vagrant post-processor does not export additional disks from qemu
This issue was originally opened by @rgl as hashicorp/packer#9160. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.
Overview of the Issue
#7791/#6139 introduced the disk_additional_size
property to add additional disks to a qemu vm and that works nicely, but the vagrant post-processor is not exporting the additional disks:
$ tar tvf esxi-7.0-amd64-libvirt.box
-rw-rw-r-- rgl/rgl 814 2020-05-03 22:31 Vagrantfile
-rw-rw-r-- rgl/rgl 561774592 2020-05-03 22:31 box.img
-rw-rw-r-- rgl/rgl 57 2020-05-03 22:31 metadata.json
Packer version
1.5.6
Simplified Packer Buildfile
"builders": [
{
"name": "esxi-{{user `version`}}-amd64-libvirt",
"type": "qemu",
"disk_size": "{{user `boot_disk_size`}}",
"disk_additional_size": ["{{user `datastore_disk_size`}}"],
...
The full template is at https://github.com/rgl/esxi-vagrant/blob/feature-upgrade-to-esxi-7/esxi.json
same issue here. At least I got the additional disk files over using the include directive. Now I need to keep them attached.
Edit: I'm using packer v1.7.7
I got a bit further.
- In my packer hcl I specify the additional disks using the include directive, like so:
post-processor "vagrant" {
output = "builds/virtualbox-ubuntu-2104-${var.version}-${var.build_number}-${var.branch_name}.box"
# keep vm around for analysis
keep_input_artifact = true
# hacky include to transfer additional disks into the vagrant .box
# format: "output-<source name>/<filename>"
include = [
"output-ubuntu_server_21_04_qemu/packer-ubuntu-2104-0.1.0-b04-master-1",
"output-ubuntu_server_21_04_qemu/packer-ubuntu-2104-0.1.0-b04-master-2",
"output-ubuntu_server_21_04_qemu/packer-ubuntu-2104-0.1.0-b04-master-3",
"output-ubuntu_server_21_04_qemu/packer-ubuntu-2104-0.1.0-b04-master-4",
]
}
- Then I import the box
- Edit the box's metadata.json like so: (the file is in ~/.vagrant.d/boxes/<nameOfBox>/0/libvirt/metadata.json)
{
"format" : "qcow2",
"provider" : "libvirt",
"disks" : [
{
"path" : "box.img"
},
{
"path" : "packer-ubuntu-2104-0.1.0-b04-master-1.img"
},
{
"path" : "packer-ubuntu-2104-0.1.0-b04-master-2.img"
},
{
"path" : "packer-ubuntu-2104-0.1.0-b04-master-3.img"
},
{
"path" : "packer-ubuntu-2104-0.1.0-b04-master-4.img"
}
]
}
Note I replaced the "virtualsize" entry with a "disks" array. With that the VM now loaded the disks, BUUUUT the UUIDs of the physical volumes I use for LVM were different. I had to manually adjust them :/