Search code examples
vagrantvirtualboxpacker

Packer with vagrant post-processor "ovf file couldn't be found"


I'm new to packer. I've heard that you can add a vagrant post processor to get you an easy VM to test your new image in. Based on the examples and such I thought the code below would work. However, I get this error.

* Post-processor failed: ovf file couldn't be found

Here's my packer config/code.

source "digitalocean" "test" {
  image         = "ubuntu-20-10-x64"
  region        = "nyc1"
  size          = "s-1vcpu-1gb"
  snapshot_name = "me-image-{{isotime \"2006-01-02T15:04\"}}"

  snapshot_regions = [
    "nyc1", "sgp1", "lon1", "nyc3", "ams3", "fra1", "tor1", "sfo2", "blr1",
    "sfo3"
  ]
  tags         = ["delete"]
  ssh_username = "root"
}

# a build block invokes sources and runs provisioning steps on them.
build {
  sources = ["source.digitalocean.test"]

  provisioner "file" {
    source      = "jump_host"
    destination = "/tmp"
  }

  post-processor "vagrant" {
    keep_input_artifact = true
    provider_override   = "virtualbox"
    output = "out.box"
  }
}

My packer version is 1.6.6
My vagrant version is 2.2.10


Solution

  • Tl;dr it's not possible

    What I wanted packer to do was build something for digitalocean then give me a copy so I could test it without paying for a vm from digitalocean and without needing internet. That isn't possible and after some reflection it makes sense why.

    Digitalocean isn't just downloading the Ubuntu 20 ISO and throwing it on their servers. They configure and change the image so its optimized on their hardware. To expect their special images to run on some standard VM running on consumer hardware isn't realistic. Plus I'm not sure there's even a way to download a snapshot from DO.

    But also in trying to do this I kind of missed the entire point of vagrant. If I'm testing a digitalocean image I will always need to connect for and pay for digitalocean. Vagrant is designed to make it easy for me to do that without having to click through the interface every single time. So I shouldn't even be trying to get this on my home computer.

    PS: Thank you so much @RedGrin-Grumble for taking the time to add to this months old post.