Bake
Appliance prepared beforehand
Advantages:
Disavantages:
Fry
A generic appliance is configured at boot-time
Advantages:
Disadvantages:
Finish configuration at boot-time (updates, config files, etc.)
An AMI: appliance + meta-data
EBS backed
Instance-store
curl http://169.254.169.254/latest/meta-data/user-data
Create a KVM appliance
boxgrinder-build centos.appl
Create an appliance and deploy run it in VirtualBox
boxgrinder-build centos.appl -p virtualbox -d local
boxgrinder-build definition.appl \
-d libvirt --delivery-config \
connection_uri:qemu:///system,\
image_delivery_uri:/var/lib/libvirt/images
2 sections in $HOME/.boxgrinder/config
S3
access_key: <ACCESS_KEY>
secret_access_key: <SECRET_ACCESS_KEY>
bucket: <BUCKET>
account_number: <ACCOUNT_ID> # see security credentials page
path: /
cert_file: /home/me/.boxgrinder/cert-2GDSYWYSIVXTZIDBLYZTAOX4KW.pem
key_file: /home/me/.boxgrinder/pk-2GFVVWYSIVXTZIDBLYZTAOX4KW.pem
region: eu-west-1
EBS
access_key: <ACCESS_KEY>
secret_access_key: <SECRET_ACCESS_KEY>
account_number: <ACCOUNT_ID>
delete_on_termination: true
region: eu-west-1
availability_zone: eu-west-1a
boxgrinder-build centos58.appl -p ec2 -d ami
boxgrinder-build centos63.appl \
-p ec2 -d ebs \
--delivery-config overwrite:true,\
destroy_instances:true
name: "centos58-#BASE_ARCH#-jeos"
summary: CentOS 5 Core
version: 1
release: 0
os:
name: centos
version: 5
password: centos
hardware:
partitions:
"/":
size: 8
packages:
- @core
- cloud-init
- httpd
- mysql-server
- php-mysql
- openssh-server
repos:
- name: "EPEL"
baseurl: "http://download.fedoraproject.org/pub/epel/5/#BASE_ARCH#/"
post:
base:
- /sbin/chkconfig httpd on
- /sbin/chkconfig mysqld on
- /sbin/chkconfig cloud-init on
Create Ubuntu-based appliances
apt-get install ubuntu-vm-builder python-vm-builder-ec2
General syntax:
vmbuilder <hypervisor> <distribution>
Generate and deploy an appliance
vmbuilder kvm ubuntu --suite lucid \
--arch amd64 \
--libvirt qemu://system
With a pre-configured user
vmbuilder kvm ubuntu --user bob --password toto
With installed packets
vmbuilder kvm ubuntu --addpkg apache2 \
--addpkg libapache2-mod-php5 \
--addpkg php5-mysql
sudo vmbuilder xen ubuntu --suite=karmic --ec2 \
--ec2-cert=<ec2 cert> \
--ec2-key=<ec2 key> \
--ec2-access-key=<aws access key> \
--ec2-secret-key=<aws secret key> \
--ec2-user=<aws # number> \
--ec2-bucket=<ec2 bucket name> \
--ec2-prefix=<image prefix> \
--ec2-version="Description of your EC2 image" \
--firstboot=/usr/share/doc/python-vm-builder-ec2/examples/ec2-firstboot.sh \
--part=/usr/share/doc/python-vm-builder-ec2/examples/ec2-<arch>-part-file.txt
$HOME/.ssh/authorized_keys
#!
or Content-Type: text/x-shellscript
#cloud-config
ou Content-Type: text/cloud-config
#include
ou
Content-Type: text/x-include-script
#cloud-config
package_update : true
package_upgrade : true
packages :
- apache2
apt_sources :
- source :deb http://archive.ubuntu.com/ubuntu karmic main …
ssh_authorized_keys :
- ssh-rsa "<ssh public key>"
locale : fr_FR.UTF-8
runcmd :
- echo "hello world !" > /home/ubuntu/message
#include
http://emn.fr/download/ec2-config.txt
ftp://emn.fr/download/vhost.conf
Using the write-mime-multipart
utility (package with cloud-init):
write-mime-multipart –output=combined-userdata.txt \
my-include.txt:text/x-include-url \
my-user-script.txt:text/x-shellscript \
my-cloudconfig.txt
euca-create-image -n <name> <instance-id>
euca-modify-image-attribute <ami-id> -l -a all
euca-modify-image-attribute <ami-id> -l -r all
euca-deregister <ami-id>
euca-bundle-instance <id> --bucket <bucket> --prefix <bundle-name>
euca-register <bucket>/image.manifest.xml -n <ami-name>