2

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

FailureGod
  • 332
  • 1
  • 12
  • Seems like you can remove `provider_override = "virtualbox"` part and Packer will create a box which has `aws` provider, than you must create a plugin for aws provider and that might work. Vagrant file must include: Vagrant.configure("2") do |config| config.vm.provider :aws do |aws| aws.ami = "ami-7747d01e" end end – Narek Hambardzumyan Mar 29 '21 at 11:51

2 Answers2

2

Had the Same(ish) Issue - Found the answer by bruteforce/chance

So I'm in the same boat as you, but I managed to find the hint for my solution here

Caveat: I'm working with an exported .vmdk, so this may not be a solution for you since you're looking for a way to get it straight from digital ocean?

The Hint

build {
  sources = ["source.null.autogenerated_1"]

  post-processor "shell-local" {
    inline = ["echo Doing stuff..."]
  }
  post-processors {
    post-processor "vagrant" {
-->   include              = ["image.iso"]
      output               = "proxycore_{{.Provider}}.box"
      vagrantfile_template = "vagrantfile.tpl"
    }
    post-processor "vagrant-cloud" {
      access_token = "${var.cloud_token}"
      box_tag      = "hashicorp/precise64"
      version      = "${local.version}"
    }
  }
}

This isn't listed on the Vagrant Post-Processor page, but it is on Vagrant Cloud Post-Processor. I just decided to try my luck and it worked.

Working Example

source "null" "example" {
  communicator = "none"
}


build {
  sources = ["source.null.example"]

  post-processor "artifice" {
    files               = ["example-disk001.vmdk", "example.ovf"]
    keep_input_artifact = true
  }

  post-processor "vagrant" {
    include             = ["example-disk001.vmdk", "example.ovf"]
    keep_input_artifact = true
    provider_override   = "virtualbox"
  }
}
aRustyDev
  • 101
  • 1
  • 11
1

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.

FailureGod
  • 332
  • 1
  • 12