Packer – Create VM Images Quicker and Easier

Packer is a tool for creating identical images for multiple platforms from a single source configuration.

Packer supports multiple providers including Rackspace, AWS, Digital Ocean, VMWARE, Virtual Box and others.  Let’s look at how we can use Packer to make images on Rackspace.

First step is to download packer on to your Windows or Linux system

Packer uses JSON templates to define an image. Packer takes this JSON and runs the builds defined, producing a machine image.

To provison a Ubuntu 64bit VM on Virtualbox.  The JSON file will look similar to

“variables”: {
“ssh_name”: “trevor”,
“ssh_pass”: “trevor123″,
“hostname”: “packertest”
“builders”: [{
“type”: “virtualbox-iso”,
“guest_os_type”: “Ubuntu_64″,
“vboxmanage”: [
[“modifyvm”, “{{.Name}}”, “–vram”, “32”]
“disk_size” : 10000,
“iso_url”: “./ubuntu-14.04.1-server-amd64.iso”,
“iso_checksum”: “2cbe868812a871242cdcdd8f2fd6feb9″,
“iso_checksum_type”: “none”,
“http_directory” : “ubuntu_64″,
“http_port_min” : 9001,
“http_port_max” : 9001,
“ssh_username”: “{{user `ssh_name`}}”,
“ssh_password”: “{{user `ssh_pass`}}”,
“ssh_wait_timeout”: “20m”,
“shutdown_command”: “echo {{user `ssh_pass`}} | sudo -S shutdown -P now”,
“boot_command” : [
“/install/vmlinuz noapic “,
“preseed/url= “,
“debian-installer=en_US auto locale=en_US kbd-chooser/method=us “,
“hostname={{user `hostname`}} “,
“fb=false debconf/frontend=noninteractive “,
“keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA “,
“keyboard-configuration/variant=USA console-setup/ask_detect=false “,
“initrd=/install/initrd.gz — <enter>”

To build the VM from the command line run packer build ubuntu64.json

Below is a sample screen shot of a live packer environment with Virtual Box running a Ubuntu VM


Popular posts from this blog

Basic Send Message to MQ with Java and IBM MQ JMS

Basic Receive Message to MQ with Java and IBM MQ JMS

Creating a simple Alert / Success Message with ASP.NET/VB using Bootstrap