Packer, Virtualbox, Vagrant, local file system .box HOWTO version Vagrant box?

191 views
Skip to first unread message

Bob Tanner

unread,
Jul 12, 2016, 1:27:14 PM7/12/16
to Packer, Bob Tanner
Creating a Virtualbox (5.0.24 r108355) .box with Packer (0.10.0) for use in Vagrant (1.8.4).

The .box is stored on my local file system.

I cannot figure out how to version the .box when it's added to Vagrant. Below real-time/xenial64 is the box.

$ vagrant box list
opensuse/openSUSE-42.1-x86_64 (virtualbox, 1.0.0)
real-time/xenial64            (virtualbox, 0)
ubuntu/precise64              (virtualbox, 20160627.0.0)
ubuntu/trusty64               (virtualbox, 20160627.0.0)
ubuntu/trusty64               (virtualbox, 20160708.1.0)

Now the .box file itself is versioned

packer.git/build/virtualbox/base-xenial64-20160712.0.0.box

And the ubuntu boxes I'm getting from atlas (online) and they are versioned.

I'm guessing "post-processors" of "type": "vagrant" cannot be versioned? At least when I try the "version": I cannot validate.

$ packer validate ubuntu/xenial/base-xenial64.json
Template validation failed. Errors are shown below.

Errors validating build 'virtualbox'. 1 error(s) occurred:

* unknown configuration key: "version"


Any help on how to version a Virtualbox gotten from a local file system for use in Vagrant would be helpful.

Thanks.

Virtualbox-5.0.24 r108355
Packer-0.10.0
Vagrant-1.8.4

Bernd Naumann

unread,
Jul 13, 2016, 5:45:28 AM7/13/16
to packe...@googlegroups.com
Hi,

never heard that packer has that feature. But you can craft the "vagrant
version" by yourself. Its just a json.

An example for illustration, from our setup:

>
http://vagrant.sprd.net/sprd_ubuntu_16_04_vagrant/sprd_ubuntu_16_04_vagrant.json

{
"name": "sprd_ubuntu_16_04_vagrant",
"description": "sprd_ubuntu_16_04_vagrant",
"versions": [
{
"providers": [
{
"checksum": "f4cb81f1179b13e01ff288cec87f0d0305005317",
"name": "virtualbox",
"url":
"http://vagrant.sprd.net/sprd_ubuntu_16_04_vagrant/boxes/sprd_ubuntu_16_04_vagrant--201606.28.0.box",
"checksum_type": "sha1"
}
],
"version": "201606.28.0"
},
{
"providers": [
{
"checksum": "c4c7bbca2d51d02911c3133fd8c2f6adbbaa179b",
"name": "virtualbox",
"url":
"http://vagrant.sprd.net/sprd_ubuntu_16_04_vagrant/boxes/sprd_ubuntu_16_04_vagrant--201607.06.0.box",
"checksum_type": "sha1"
}
],
"version": "201607.06.0"
},
{
"providers": [
{
"checksum": "b70d0f69a0061c8786330ccb2f2349a55a99ebd2",
"name": "virtualbox",
"url":
"http://vagrant.sprd.net/sprd_ubuntu_16_04_vagrant/boxes/sprd_ubuntu_16_04_vagrant--201607.11.0.box",
"checksum_type": "sha1"
}
],
"version": "201607.11.0"
}
]
}

I do this as a post-build script with python. Just pump everything in a
python object/dictionary, and use json.dumps(obj) to stream it in a file...

Hope that helps.
Greetings,
Bernd
signature.asc

Alvaro Miranda Aguilera

unread,
Jul 13, 2016, 1:21:57 PM7/13/16
to packe...@googlegroups.com, Bob Tanner
Hello,

As Bernd said, packer will generate a box file (tar file with vm and metadata on it)

the version is an extra bit, if you upload to atlas, it will automatically do it for you, however you can create a json file and store it on a server locally and use this versioning feature.

check this json file for example:

Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/a4d4b7bf-3909-4d5d-aeae-2f795d844478%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bob Tanner

unread,
Jul 14, 2016, 12:40:33 AM7/14/16
to Packer, b...@tanners.org
I didn't know what question to ask, so adding this url for people who stumble on this post:


Bob Tanner

unread,
Jul 14, 2016, 3:03:09 AM7/14/16
to Packer
How do you execute a python script in post-build?

Wrap it in a shell script?

Thanks.
Reply all
Reply to author
Forward
0 new messages