4

The version of the box that is added is always v0; how can I change this value? For example, when I do a vagrant box list, my box is always version v0.

I'm creating a VirtualBox Vagrant "box" using Packer, but I can't figure out how to set the version of the box output.

The Packer build command consumes a builder JSON file

$ packer build builder.json

...

==> virtualbox-iso (vagrant): Creating Vagrant box for 'virtualbox' provider
    virtualbox-iso (vagrant): Copying from artifact: dist-28/ion-disk001.vmdk
    virtualbox-iso (vagrant): Copying from artifact: dist-28/ion.ovf
    virtualbox-iso (vagrant): Renaming the OVF to box.ovf...
    virtualbox-iso (vagrant): Compressing: Vagrantfile
    virtualbox-iso (vagrant): Compressing: box.ovf
    virtualbox-iso (vagrant): Compressing: ion-disk001.vmdk
    virtualbox-iso (vagrant): Compressing: metadata.json

and the output of the Packer step above is Vagrant box called packer_virtualbox-iso_virtualbox.box, which I then add to Vagrant using

$ vagrant box add BOX_NAME packer_virtualbox-iso_virtualbox.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'BOX_NAME' (v0) for provider: 
    box: Unpacking necessary files from: file:///packer/packer_virtualbox-iso_virtualbox.box
==> box: Successfully added box 'BOX_NAME' (v0) for 'virtualbox'!

I want to change the value v0 to something else. This is the contents of builder.json

{
  "builders": [
    {
      "type": "virtualbox-iso",
      "vm_name": "ion-${ION_BUILD_NUMBER}",
      "output_directory": "dist-${ION_BUILD_NUMBER}",
      "iso_url": "${ISO_URL}",
      "iso_checksum": "${MD5}",
      ...
    }
  ],
  "post-processors": [
    "vagrant"
  ]
}
activedecay
  • 10,129
  • 5
  • 47
  • 71

2 Answers2

1

There was an issue fixed so you can now provide your own metadata.json file

see the content of the box metadata

{
  "name": "xxxx",
  "description": "xxxx",
  "versions": [
    {
      "version": "0.1.0",
      "providers": [
        {
          "name": "virtualbox",
        }
      ]
    }
  ]
}
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
1

I guess I could use the output filename as a version number

  "post-processors": [
    {
      "output": "box/vm-${ION_BUILD_NUMBER}.box",
      "type": "vagrant"
    }
  ]
activedecay
  • 10,129
  • 5
  • 47
  • 71
  • Did you find a better way? – another Apr 30 '18 at 13:13
  • 1
    no, the only way i could figure out how to do it was put the version number in the box build output. lame. it was too painful, and preventing forward progress, so i deal with the worts. – activedecay Apr 30 '18 at 20:03