Skip to content

Latest commit

 

History

History
162 lines (111 loc) · 4.6 KB

README.md

File metadata and controls

162 lines (111 loc) · 4.6 KB

Table of Contents generated with DocToc

packer-templates

Purpose

This repository is for maintaining my personal Vagrant Box Templates using Packer.

Information

All builds are based on the following providers:

NOTE: All builds are base builds and follow the Vagrant guidelines of how a Vagrant box should be built.

Requirements

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 }}"
}

Software

Usage

Building a box

To build a Vagrant box with Packer for Virtualbox:

Select distro

Choose which distro you are interested in building.

Build distro

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.

Testing a box

Once your build has completed you are ready to test it out.

Add box to Vagrant

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

Create Vagrantfile

cd ~
mkdir -p packer/vagrant/xenial64-server
cd packer/vagrant/xenial64-server
vagrant init xenial64-server-packer-template-virtualbox-1542509766

Spin it up

vagrant up

Test it out

vagrant ssh

Now do some basic tests to validate all is good.

Tear it down

vagrant destroy -f

Cleaning up

When you need to clean up any of the lingering files/folers generated during building, you can execute the cleanup_builds.sh script.

Using pre-built and ready for consumption Vagrant templates

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.

License

MIT

Author Information

Larry Smith Jr.

Buy Me A Coffee