Created
February 11, 2014 18:43
-
-
Save coderanger/8941308 to your computer and use it in GitHub Desktop.
Balanced packer config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"variables": { | |
"aws_access_key_id": "{{env `AWS_ACCESS_KEY_ID`}}", | |
"aws_secret_access_key": "{{env `AWS_SECRET_ACCESS_KEY`}}", | |
"aws_account_id": "4819-1673-9571", | |
"s3_bucket": "balanced-amis", | |
"x509_cert_path": "{{pwd}}/balanced-aws.crt", | |
"x509_key_path": "{{pwd}}/balanced-aws.key" | |
}, | |
"builders": [ | |
{ | |
"type": "amazon-instance", | |
"access_key": "{{user `aws_access_key_id`}}", | |
"secret_key": "{{user `aws_secret_access_key`}}", | |
"account_id": "{{user `aws_account_id`}}", | |
"s3_bucket": "{{user `s3_bucket`}}", | |
"region": "us-east-1", | |
"ami_regions": ["us-west-1", "us-west-2"], | |
"source_ami": "ami-23447f4a", | |
"instance_type": "m1.small", | |
"ssh_username": "ubuntu", | |
"ami_name": "Balanced Ubuntu 12.04 (instance store) {{isotime | clean_ami_name}}", | |
"x509_cert_path": "{{user `x509_cert_path`}}", | |
"x509_key_path": "{{user `x509_key_path`}}", | |
"bundle_upload_command": "sudo -n env PATH=/opt/chef/embedded/bin:$PATH EC2_AMITOOL_HOME=/opt/ec2-ami-tools /opt/ec2-ami-tools/bin/ec2-upload-bundle -b {{.BucketName}} -m {{.ManifestPath}} -a {{.AccessKey}} -s {{.SecretKey}} -d {{.BundleDirectory}} --batch --location {{.Region}} --retry", | |
"bundle_vol_command": "sudo -n env PATH=/opt/chef/embedded/bin:$PATH EC2_AMITOOL_HOME=/opt/ec2-ami-tools /opt/ec2-ami-tools/bin/ec2-bundle-vol -k {{.KeyPath}} -u {{.AccountId}} -c {{.CertPath}} -r {{.Architecture}} -e {{.PrivatePath}}/* -d {{.Destination}} -p {{.Prefix}} --batch --no-filter" | |
} | |
], | |
"provisioners": [ | |
{ | |
"type": "shell", | |
"inline": [ | |
"set -e -x", | |
"sleep 60 # Wait for init scripts et al to finish" | |
] | |
}, | |
{ | |
"type": "file", | |
"source": "validation.pem", | |
"destination": "/tmp/validation.pem" | |
}, | |
{ | |
"type": "file", | |
"source": "client.rb", | |
"destination": "/tmp/client.rb" | |
}, | |
{ | |
"type": "shell", | |
"script": "init.sh" | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -xe | |
# Install Chef | |
curl -L https://www.opscode.com/chef/install.sh | sudo bash | |
# Install ec2-ami-tools | |
sudo apt-get update -y | |
sudo apt-get install -y unzip | |
curl -o /tmp/ec2-ami-tools.zip http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip | |
# The Amazon zip file has recoverable errors | |
set +e | |
unzip -d /tmp /tmp/ec2-ami-tools.zip | |
RV="$?" | |
if [[ "$RV" -gt 1 ]]; then | |
exit "$RV" | |
fi | |
set -e | |
rm /tmp/ec2-ami-tools.zip | |
sudo mkdir /opt/ec2-ami-tools | |
sudo mv /tmp/ec2-ami-tools*/* /opt/ec2-ami-tools | |
rm -rf /tmp/ec2-ami-tools* | |
sudo chown -R root:root /opt/ec2-ami-tools | |
# Configure Chef | |
sudo mkdir /etc/chef | |
sudo mv /tmp/validation.pem /tmp/client.rb /etc/chef | |
sudo chown -R root:root /etc/chef | |
sudo chmod 700 /etc/chef | |
sudo chmod 600 /etc/chef/validation.pem /etc/chef/client.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment