Skip to content

Instantly share code, notes, and snippets.

@nesquena
Created July 22, 2009 02:58
Show Gist options
  • Save nesquena/151769 to your computer and use it in GitHub Desktop.
Save nesquena/151769 to your computer and use it in GitHub Desktop.

Bundling Overview

l$ scp -i ~/.ec2/id_xxx ~/.ec2/cert-XXXXXXXXXXXXXX.pem ~/.ec2/pk-XXXXXXXXXXXXX.pem root@xxx.xxx.xx.xxx:/mnt
l$ ssh root@xxx.xxx.xx.xxx -i ~/.ec2/keys/id_xxx-keypair
r$ export RUBYLIB=/usr/lib/site_ruby/
r$ ec2-bundle-vol -p <BUNDLENAME> -d /mnt -k /mnt/pk-XXXXXXXXXXXXX.pem -c /mnt/cert-XXXXXXXXXXXXXX.pem -u <account_id> -r i386
r$ ls -l /mnt/<BUNDLENAME>.*
r$ ec2-upload-bundle -b <BUCKETNAME> -m /mnt/<BUNDLENAME>.manifest.xml -a <access_key> -s <secret_access_key>
r$ sudo rm /mnt/<BUNDLENAME>.*
r$ sudo rm /mnt/<BUNDLENAME>
r$ ec2-register <BUCKETNAME>/<BUNDLENAME>.manifest.xml
# ec2 capistrano recipe
role :web, "DOMAIN.com"
set :user, "xxxxx"
set :runner, "xxxxx"
set :password, "xxxxxx"
ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "id_rsa.pub")]
set :public_key, "id-KEYNAME" # the keypair to use for the instance
set :cert_code, "CERT_CODE" # the code for the private key and for the certificate
set :bundle_host, "DOMAIN.com" # the domain for the site
set :account_id, "ACCOUNTID" # your account_id without dashes
set :bundle_name, "BUNDLE" # the name of the bundle
set :store_bucket, "BUCKET" # the name of the bucket
set :access_key_id, "ACCESS KEY"
set :access_secret_key, "SECRET KEY"
namespace :ec2 do
desc "bundles up our innercalm image"
task :bundle do
utilities.with_credentials :user => 'root' do
system("scp -i ~/.ec2/#{public_key} ~/.ec2/pk-#{cert_code}.pem ~/.ec2/cert-#{cert_code}.pem root@#{bundle_host}:/mnt")
run "rm -f /mnt/#{bundle_name}"
run "export PATH=/usr/bin:$PATH; ec2-bundle-vol -d /mnt -k /mnt/pk-#{cert_code}.pem -c /mnt/cert-#{cert_code}.pem -u #{account_id} -r i386 -p #{bundle_name}"
run "ls -l /mnt/#{bundle_name}.*"
run "export PATH=/usr/bin:$PATH; ec2-upload-bundle -b #{store_bucket} -m /mnt/#{bundle_name}.manifest.xml -a #{access_key_id} -s #{access_secret_key}"
system("ec2-register #{store_bucket}/#{bundle_name}.manifest.xml")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment