Skip to content

Templates for creating vagrant boxes

License

Notifications You must be signed in to change notification settings

HardBoiledSmith/packer-templates

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

packer-templates

A Packer template that simplifies the creation of minimally-sized, fully patched Windows Vagrant boxes.

This repo and much of its content are covered in detail from this blog post. Also see this post specifically for the Nano Server template.

this repo fix to build window server 2016

Prerequisites

You need the following to run the template:

  1. Packer installed with a minimum version of 0.12.3.
  2. VirtualBox - Tested with 5.1.12
  3. Berkshelf - Used to find and vendor Chef cookbook dependencies. This is easist installing via the ChefDK

Vendoring the cookbooks

The Windows 2016 templates use the packer-templates Chef cookbook to provision the image. The cookbook located in cookbooks/packer-templates has dependencies on a few community cookbooks. These cookbooks need to be downloaded. To do this:

  1. cd to cookbooks/packer-templates
  2. Run berks vendor ../../vendor/cookbooks

This downloads all dependencies and saves them in vendor/cookbooks. From here packer will upload them to the image being built.

Invoking the template

Invoke packer to run a template like this:

packer build -force -only virtualbox-iso .\vbox-2016.json

Hyper-V templates

The Hyper-V templates now use the official Hyper-V builder available in the latest versions of packer. I no longer convert Virtual Box images to Hyper-V.

Converting to Hyper-V

As stated above, I no longer convert VirtualBox images to Hyper-V. However that can be useful if you are limited to mac or linux hardware for creating images. This repo includes PowerShell scripts that can create a Hyper-V Vagrant box from the output VirtualBox .vmdk file. This repo leverages psake and Chocolatey to ensure that all prerequisites are installed and then runs the above packer command followed by the scripts needed to produce a Vagrant .box file that can create a Hyper-V file.

See this blog post for more detail on converting VirtualBox disks to Hyper-V.

Troubleshooting Boxstarter package run

Boxstarter is used by some templates for initial provisioning. Due to the fact that provisioning takes place in the builder and not a provisioner, it can be difficult to gain visibility into why things go wrong from the same console where packer is run.

Boxstarter will log all package activity output to $env:LocalAppData\Boxstarter\boxstarter.log on the guest.

How to Use in HBsmith

  • we use this repo for build windows server 2016
  • run under command, you can get windws server 2016 box file
cd cookbooks/packer-template
sed -i  '.back' '/depends.*windows/d' metadata.rb
rm Berksfile.lock
berks vendor ../../vendor/cookbooks
cd ../..
$ packer build -force -only virtualbox-iso vbox-2016.json

How to Add Vagrant Box Locally

vagrant box add [new box name] [box file]

ex)

vagrant box add  win2016-test ./windows2016min-virtualbox.box

How to Upload Vagrant Box to Vagrant Cloud

https://blog.ycshao.com/2017/09/16/how-to-upload-vagrant-box-to-vagrant-cloud/

  1. login to https://app.vagrantup.com/
  2. click New Vagrant Box at Dashboard
  3. enter name (visibility, description is optional) and click Create box.
  4. enter version ex) 0.0.1 and click Create version.
  5. click Add a proviser
  6. enter the provider name, such as virtualbox, select Upload to Vagrant Cloud, and click Continue to upload
  7. upload file (should be .box file, the file you generated at packer-templates repository, not the folder or .vmdk file you made by vagrant box add command)
  8. go back to your repository and click Release...
  9. click Release version

About

Templates for creating vagrant boxes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PowerShell 52.6%
  • Ruby 29.8%
  • HTML 11.2%
  • Batchfile 3.9%
  • Shell 2.5%