Skip to content

Instantly share code, notes, and snippets.

@rnaveiras
Created November 10, 2014 13:54
Show Gist options
  • Save rnaveiras/6729dd7a935fca2d0631 to your computer and use it in GitHub Desktop.
Save rnaveiras/6729dd7a935fca2d0631 to your computer and use it in GitHub Desktop.
{
"variables": {
"aws_access_key": "",
"aws_secret_key": "",
"region": "eu-west-1",
"source_ami": "",
"version": "1.0.0",
"chef_server": ""
"validation_key": "",
"environment": "",
"role": "base",
"created_at": "{{isotime \"2006-01-02\"}}",
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "{{user `region`}}",
"source_ami": "{{user `source_ami`}}",
"instance_type": "m1.small",
"ssh_username": "ubuntu",
"ami_name": "packer {{user `role`}} {{user `version` | clean_ami_name}} {{user `created_at`}}",
"ami_description": "BeBanjo packer role {{user `role`}}",
"ami_block_device_mappings": [
{
"device_name": "/dev/sda1",
"volume_type": "gp2",
"delete_on_termination": true,
"encrypted": false
},
{
"device_name": "/dev/sdb",
"virtual_name": "ephemeral0"
}
],
"tags": {
"Name": "{{user `role`}}-{{user `version`}}"
}
}],
"provisioners": [
{
"type": "shell",
"inline": [
"set -x",
"sleep 30",
"sudo apt-get update",
"sudo apt-get upgrade -y",
"sudo mkdir /tmp/packer-chef-client",
"sudo chmod 0777 /tmp/packer-chef-client",
"sudo mkdir /etc/chef",
"sudo chmod 0777 /etc/chef",
"sudo mkdir -p /etc/chef/ohai/hints",
"sudo touch /etc/chef/ohai/hints/ec2.json"
]
},
{
"type": "chef-client",
"server_url": "{{user `chef_server`}}",
"validation_client_name": "chef-validator",
"validation_key_path": "{{user `validation_key`}}",
"chef_environment": "{{user `environment`}}",
"run_list": "role[{{user `role`}}]",
"node_name": "packer-{{timestamp}}",
"skip_clean_client": true,
"skip_clean_node": true,
"prevent_sudo": false
},
{
"type": "shell",
"inline": [
"set -x",
"sudo rm /etc/chef/client*",
"sudo rm /etc/init.d/chef-client",
"sudo update-rc.d -f chef-client remove",
"sudo apt-get clean -y",
"sudo apt-get autoclean -y",
"sudo apt-get autoremove -y"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment