Garrett Honeycutt
gh@learnpuppet.com
learnpuppet.com
@learnpuppet
Packer:
Make Multi-Platform Images
Hands up
Who uses multiple platforms?
Dev == Prod
Developers
Spend a bunch of time just
getting the environment
setup?
Lower entry barrier
If you write software, it needs
to be easy to get others
involved.
Demos
Quickly allow someone to try
out your software on the
platform of their choice.
Packer is
Software to create
machine images
What?! You've been
complaining about
golden images for
years!
Golden Images
No idea how they were created
Golden Images
No idea what's changed since
the last version.
Golden Images
How many versions are we
even running?
Golden Images
Matrix of images that work
together
Packer
Know your inputs
PXE
Who uses images that they did
not create themselves?
Who uses config mgmt?
single
build
system
multiple
platform
images
Dev == Prod
Installation
Terminology
Artifacts
Artifacts
Results of a build
Builds
Builds
Single task that produces an
image for a single platform
Builders
Builders
Packer components that can
create an image for a single
platform.
Builders
Amazon EC2 (AMI)
Azure Resource Manager
DigitalOcean
Docker
Google Compute Engine
OpenStack
Parallels
QEMU
VirtualBox
VMWare
Custom
Post-processors
take the result of a builder or
another post-processor and
process that to create a new
artifact
Post-processors
amazon-import
Artifice
Atlas
compress
docker-import
docker-push
docker-save
docker-tag
Local Shell
Vagrant
Vagrant Cloud
vSphere
Provisioners
Configure a running system
Provisioners
Remote Shell
Local Shell
File Uploads
PowerShell
Chef
Puppet
Ansible
Salt
Windows Restart (lulz :)
Custom
Commands
$ packer validate template.json
Commands
$ packer build template.json
Commands
$ PACKER_LOG=1 
PACKER_LOG_PATH=debug.txt 
packer build template.json
desc 'Validate files'
task :validate do
sh 'packer validate template.json'
sh 'puppet parser validate site.pp'
end
desc 'Run packer build'
task :build do
sh 'PACKER_LOG=1 
PACKER_LOG_PATH=debug.txt 
packer build template.json'
end
Rakefile
{
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami": "ami-6d1c2007",
"instance_type": "t2.micro",
"ssh_username": "centos",
"ssh_pty": true,
"ami_name": "packer-example {{timestamp}}"
}],
}
Template
{
"builders": [...],
"provisioners": [{
"type": "shell",
"inline": [
"sleep 30",
"sudo rpm -vhi https://path.to/epel.rpm",
"sudo yum -y install perl",
"sudo rpm -vhi http://path.to/cowsay.rpm",
"sudo cowsay Fun with Packer > /etc/motd"
]
}]
}
Template
single
build
system
multiple
platform
images
Multiple Builders
AWS -> AWS && Virtualbox
Config mgmt
Using Puppet
{
"type": "file",
"source": "hieradata",
"destination": "/tmp"
},
{
"type": "file",
"source": "ghoneycutt-modules",
"destination": "/tmp"
},
Provisioner - file
{
"type": "puppet-masterless",
"manifest_file": "site.pp",
"execute_command": "cd
{{.WorkingDir}} && {{.FacterVars}}
{{if .Sudo}} sudo -E {{end}}/opt/
puppetlabs/bin/puppet apply --verbose
--detailed-exitcodes {{.ManifestFile}}"
}
Provisioner - Puppet masterless
Why have config mgmt?
Continuous Delivery
Determinism
Same inputs lead to
same outputs
Increase velocity.
Verify config mgmt
and provisioning
steps
App Artifacts
Dev vs. Ops
or
DevOps
The system
IS
the artifact
Garrett Honeycutt
gh@learnpuppet.com
learnpuppet.com
@learnpuppet
Packer:
Make Multi-Platform Images

(2016-06-11) Packer: Make Multi-Platform Images