A profile is a combination of Chef parameters, and Vagrant and Packer configurations. Profiles should provide
tags, type: hash
EC2 tags to apply to instances and AMIslog_level
Chef log-level. Default:info
An externally managed resource to push to VMs and image builds, e.g. bundle.tar.gz
from a Maven build.
path
The workspace-rooted path to the artifactdestination
The absolute path on the VM or image at which the artifact should be placed
run_list, type: list, singular: run_list_item, unique: true
The Chef runlist for this profileenvironment
The Chef environment to load for thisnode_attrs, type: hash
A hash of node attributes for this profilebinary_env
A space separated, KEY=VALUE formatted string to pass data into the provisioning process as environment variables. See the vagrant docs for more information.
Packer/Vagrant provisioner definitions. Currently only supports inline shell provisioners.
inline, type: list
A list of shell provisionersenvironment_vars, type: list
A list of environment vars (inKEY=VALUE
format) to pass to the shell script
Packer configurations for this profile
Add a Packer build
type
the build provider (e.g. amazon-ebs, virtualbox, docker)
Options for the docker
builder:
image
The base image for the Docker container that will be started
The Docker builder requires one, and only one, of the following options:
commit
The container will be committed to an image rather than exporteddiscard
Throw away the container when the build is completeexport_path
The path where the final container will be exported as a tar file
There are additional options specified in lib/builderator/config/file.rb
and
in the Packer documentation.
Options for the amazon-ebs
builder:
-
instance_type
the EC2 instance type to use -
source_ami
The source AMI ID for anamazon-ebs
-
ssh_username
Defaultubuntu
-
ami_virtualization_type
Defaulthvm
-
tagging_role
the name of an IAM role that exists in each remote account that allows the AMI to be retaggedExample usage:
profile bake: Config.profile(:default) do |bake| bake.packer do |packer| packer.build :default do |build| build.tagging_role 'CreateTagsOnAllImages' build.run_tags { 'Owner' => 'ops', 'Product' => 'packer' } build.run_volume_tags { 'Owner' => 'ops', 'Product' => 'packer' } end end end
Example IAM policy in remote account:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "StmtId", "Effect": "Allow", "Action": [ "ec2:CreateTags" ], "Resource": [ "*" ] } ] }
The above policy needs to be assigned to a role that enables a trust relationship with the account that builds the AMI:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::[ami_builder_account]:user/[ami_builder_user]" }, "Action": "sts:AssumeRole" } }
Add a packer post-processor to run after the provisioning steps. This is a free-form attribute as there is no validation of elements defined here. If invalid configuration is supplied, errors will only appear when Packer tries to execute them.
The post_processors
attribute supports simple, complex, and sequence definitions.
Example:
packer.post_processors [
[
# Complex
{
:type => 'docker-tag',
:repository => 'rapid7/builderator',
:tag => '1.2.2'
},
'docker-push' # Simple
],
# Sequence
[
{
:type => 'docker-tag',
:repository => 'rapid7/builderator',
:tag => 'latest'
},
'docker-push'
]
]
ami_name
Name for new AMIami_description
Description for the new AMI
Vagrant VM configurations
Parameters for a local VM build
-
provider
Defaultvirtualbox
-
box
Defaultubuntu-14.04-x86_64
-
box_url
Defaulthttps://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box
-
cpus
Default 2 -
memory
Default 1024 (MB)
Parameters for the provisioning EC2 nodes with Vagrant
provider
Defaultaws
box
Defaultdummy
box_url
Defaulthttps://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
instance_type
source_ami
ssh_username
virtualization_type
iam_instance_profile_arn
subnet_id
security_groups, type: list, singular: security_group, unique: true
public_ip
ssh_host_attribute
One of:[:public_ip_address, :dns_name, :private_ip_address]
, Default:private_ip_address