Table of Contents generated with DocToc
This repository is for maintaining my personal Vagrant Box Templates using Packer.
All builds are based on the following providers:
-
You can find my collection of builds here
NOTE: All builds are base builds and follow the Vagrant guidelines of how a Vagrant box should be built.
All of my Packer templates are configured to upload to Vagrant Cloud after a successful build has been executed. In order to upload a box version to Vagrant Cloud, you will need to create a private_vars.json
file in the root of this repo with the following info:
{
"vagrant_cloud_token": "Your Vagrant Cloud private API token",
"vagrant_cloud_username": "Your Vagrant Cloud username"
}
If you do not want this functionality, you will need to edit the respective template within the distro folder and remove the following:
{
"type": "vagrant-cloud",
"box_tag": "{{ user `box_tag` }}",
"access_token": "{{ user `vagrant_cloud_token` }}",
"version": "{{ timestamp }}"
}
To build a Vagrant box with Packer for Virtualbox:
Choose which distro you are interested in building.
NOTE: This example we will have chosen Ubuntu Xenial
cd Ubuntu/xenial64/server
packer build -var-file=../../../private_vars.json -var-file=ubuntu1604.json ../../ubuntu-server.json
Now watch your build kick off and run through the building process. Once it has completed you will be ready to test it out.
Once your build has completed you are ready to test it out.
Note: The number at the end is the epoch time of the build. Replace this accordingly.
cd Ubuntu/xenial64/server
vagrant box add xenial64-server-packer-template-virtualbox-1542509766 xenial64-server-packer-template-virtualbox-1542509766.box
cd ~
mkdir -p packer/vagrant/xenial64-server
cd packer/vagrant/xenial64-server
vagrant init xenial64-server-packer-template-virtualbox-1542509766
vagrant up
vagrant ssh
Now do some basic tests to validate all is good.
vagrant destroy -f
When you need to clean up any of the lingering files/folers generated during building, you can execute the cleanup_builds.sh script.
The majority of these templates are used to populate my vagrant-box-templates repo. I would highly recommend leveraging this repo for testing and etc.
MIT
Larry Smith Jr.