5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/ami/ami_builder/ubuntu_precise.rb', line 5
def self.create(image_name, ssh, config, include_files = [])
include_files << '/etc/apt/trusted.gpg'
include_files << '/etc/apt/trustdb.gpg'
ssh.upload(config.cert_path, '/tmp/cert.pem')
ssh.upload(config.pk_path, '/tmp/pk.pem')
ssh.run 'sudo sed -i -e "s/# deb\(.*\)multiverse/deb\1multiverse/g" /etc/apt/sources.list'
ssh.run 'sudo apt-get update'
ssh.run 'sudo apt-get -y install ec2-api-tools ec2-ami-tools'
ssh.run 'mkdir /tmp/ami'
ssh.run "sudo ec2-bundle-vol -r x86_64 -d /tmp/ami -k /tmp/pk.pem -c /tmp/cert.pem -u #{config.account_id} -i #{include_files.join(',')}"
ssh.run "ec2-upload-bundle -b '#{config.s3_bucket}' -m '/tmp/ami/image.manifest.xml' -a #{config.access_key} -s #{config.secret_key}"
ssh.run "ec2-register -K /tmp/pk.pem -C /tmp/cert.pem '#{config.s3_bucket}/image.manifest.xml' -n #{image_name}"
end
|