hashicorp / packer-plugin-vagrant

Packer plugin for Vagrant
https://packer.io
Mozilla Public License 2.0
13 stars 24 forks source link

post-processor: create disk image without a backing file #44

Open rgl opened 2 years ago

rgl commented 2 years ago

Description

When using a backing file like:

source "qemu" "packer-qemu-ansible-debian-example" {
  ...
  disk_image = true
  use_backing_file = true
  iso_url = "/home/rgl/.vagrant.d/boxes/debian-11-amd64/0/libvirt/box.img"
}

build {
  ...
  post-processor "vagrant" {
    output = "packer-qemu-ansible-debian-example.box"
  }
}

The disk image inside the generated vagrant box is using a backing file:

$ qemu-img info ~/.vagrant.d/boxes/packer-qemu-ansible-debian-example/0/libvirt/box.img 
image: /home/rgl/.vagrant.d/boxes/packer-qemu-ansible-debian-example/0/libvirt/box.img
file format: qcow2
virtual size: 60 GiB (64424509440 bytes)
disk size: 139 MiB
cluster_size: 65536
backing file: /home/rgl/.vagrant.d/boxes/debian-11-amd64/0/libvirt/box.img
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

This makes the box depend on that backing file, which is not what I would expect. I was expecting an stand-alone disk inside the box file.

Creating a stand-alone disk is a matter of executing qemu-img (instead of just copying the img) with something alike:

qemu-img convert -O qcow2 with-backing-file.img standalone.img

What do you think? Would a PR with this be acceptable?