chef-partners/packman

Name: packman

Owner: Chef Partners

Description: Packer Manager cookbook

Created: 2016-02-11 22:20:50.0

Updated: 2018-02-15 23:11:28.0

Pushed: 2017-10-11 23:08:33.0

Homepage: null

Size: 14

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Packer Manager Cookbook

The packman cookbook provide resources for building a packer template comprised of one or many packer variables, builders, provisioners or post processors. The primary motivation behind this is support for dynamic provisioners. If you're managing several different images it can quickly become cumbersome to manage all of the provisioner files and scripts.

An example recipe that uses the resources to build a single image on azure would look something like

er_variable 'azure_publish_settings' do
lue '{{env `AZURE_PUBLISH_SETTINGS`}}'

tion :create


er_builder 'azure_example' do
tions(
'name' => 'azure_example',
'type' => 'azure',
'ssh_username' => 'azure',
'publish_settings_path' =>  '{{user `azure_publish_settings`}}',
'subscription_name' =>  'Example Subscription',
'storage_account' =>  'myimages',
'storage_account_container' =>  'vhds',
'os_type' =>  'Linux',
'os_image_label' => 'Ubuntu Server 14.04 LTS',
'location' => 'East US',
'instance_size' =>  'Large',
'user_image_label' => "Packman_Example_{{timestamp}}"


tion :create


er_provisioner '/etc/my.cfg' do
pe 'file'
urce 'my.cfg.erb'
stination '/etc/my.cfg'
riables(
something: 25,
another_thing: 'fixed'

ly %w(azure_example)

tion :create


er_provisioner 'example_setup.sh' do
pe 'shell'
urce 'example_setup.sh.erb'

tion :create


er_template 'azure-example' do
tion [:create, :run]

Resources
packer_template

The packer_template resource is responsible for building the packer JSON template and running packer. It will compose the template from data in the node.run_state that is populated by the preceeding packer resources.

Since it is uses previously defined packer resources it should be last in the run_list.

packer_variable

packer_variable just create a key/value pair in the packer template.

er_variable 'foo' do
lue 'bar'

=>


ariables": {
"foo": "bar"


packer_builder

packer_builder takes a hash of options that correspond to a packer builder.

er_builder 'azureExample' do
tions(
'name' => name,
'type' => 'azure',
'ssh_username' => 'azure',
'publish_settings_path' =>  '{{user `azure_publish_settings`}}',
'subscription_name' =>  'Partner Engineering',
'storage_account' =>  'ampimages',
'storage_account_container' =>  'images',
'os_type' =>  'Linux',
'os_image_label' => 'Ubuntu Server 14.04 LTS',
'location' => 'East US',
'instance_size' =>  'Large',
'user_image_label' => "Chef_AIO_Example_{{timestamp}}"


tion :create

=>


uilders": [

"name": "azureExample",
"type": "azure",
"ssh_username": "azure",
"publish_settings_path":  "{{user `azure_publish_settings`}}",
"subscription_name":  "Partner Engineering",
"storage_account":  "ampimages",
"storage_account_container":  "images",
"os_type":  "Linux",
"os_image_label": "Ubuntu Server 14.04 LTS",
"location": "East US",
"instance_size":  "Large",
"user_image_label": "Chef_AIO_Example_{{timestamp}}"



packer_provisioner

packer_provisioner is the resource that makes using chef as an abstraction worth while. It allows us to dynamically create provisioner resources so that we don't have to maintain several versions of almost identical files. We get to use templates!

I propose that we limit provisioner type support to file and script in the beginning. Each provisioner file/script that is rendered will use a system temporary file and will be reaped after the packer_template resource has finished running packer.

er_provisioner '/etc/chef-marketplace/marketplace.rb'
pe 'file'
urce 'marketplace.rb.erb'
riables(
license_count: 25,
license_type: 'fixed'

ly %w(azureExample)

tion :create

=>


rovisioners": [

"type": "file",
"source": "/var/folders/x2/t63_5xr50dn5j32nwn0wjb2w0000gp/T/d20160208-5303-1xqdxzf/marketplace.rb",
"destination": "/etc/marketplace.rb",
"only": [ "azureExample" ]



packer_post_processor

We won't initially require any post processors as far as I know. Theoretical support would look something like:

er_post_processor 'compress' do
tions(
'output' => 'archive.tar.lz4'


tion :create

=>


ostprocessor": [

"type": "compress",
"output": "archive.tar.lz4",




This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.