View source | Discuss this page | Page history | Printable version   

Release Management/Rebundling Professional Appliance AMIs

Release Management/Internal

Index


Contents

Introduction

This document is intended to be a guide when is needed to rebuild a openbravo rpath ops AMI. This process can be done in two ways:

Process simple:

  1. Start an instance of the AMI that need to be modified
  2. Make the changes
  3. Make an ec2-rebundle-vol, this generates an AMI with the current state of the instance.

Process complex and clean (oriented to publish the AMI to customers):

  1. Start an instance of the AMI that need to be modified
  2. Make the changes
  3. Extract the modified files
  4. Apply the modified files into a clean instance of the same AMI
  5. Generate the AMI from there.

This document are only related to the second type of process, the one oriented to customers.


Prerequisites

Ami and Api tools of EC2

Follow this guide to setup ec2-tools and ec2-ami-tools: http://wiki.openbravo.com/wiki/Release_Management/Managing_Amazon_EC2#Installation_of_command_line_tools

Also is recommend to read this document: http://wiki.openbravo.com/wiki/ERP/2.50/Openbravo_ERP_Installation#Xen_appliance_2

Environment variables

Check that this variables are in you .bashrc (replace 'x' with your credentials)

export EC2_AMITOOL_HOME=/usr/local/ec2-ami-tools
export EC2_HOME=/usr/local/ec2-api-tools
export PATH=$PATH:/usr/local/ec2-ami-tools/bin:/usr/local/ec2-api-tools/bin
export EC2_PRIVATE_KEY=/home/openbravo/.ec2/pk-xxxxxxxxxxxxxx.pem
export EC2_CERT=/home/openbravo/.ec2/cert-xxxxxxxxxxxxx.pem
export EC2_URL='https://eu-west-1.ec2.amazonaws.com'
export EC2_USER_ID=xxxxxxxxxxxxx
export EC2_ACCESS_KEY=xxxxxxxxxxxxxxxxx
export EC2_SECRET_KEY=xxxxxxxxxxxxxxxxxxx

You should have an ".ec2" folder in your home with the certificates (pk-xxxx.pem, cert-xxxxx.pem and user-johndoe-eu.pem)

Disk space

Taking into account that each AMI can have about 10GB, in this process you will need more than 20 GB, but better if you have more disk space.

Internet connection

Some parts of the process need a really good Internet connection (be able of upload 0,5-1GB without interruptions), is highly recommended to execute the steps marked with "NET+++" in a temporally amazon instance. The steps that is enough with a normal Internet connection are marked with "NET+" and can be executed from the user computer.

Also is recommended for the high hdd usage to use a medium or large instance, because the hdd performance in small instances are very poor.

In the temporal amazon instance is necessary to install the ami-tools.

Process

Download the original

NET+++

You can download from on.openbravo.com the ops mountable image, is a file with extension ".fs.ext3".

And uncompress it:

tar xzvf ops-2.50-x86.fs.tar.gz -C original

Create an AMI with the original

NET+++

ec2-bundle-image -i original/ops-2.50-x86/ops-2.50-x86-root.ext3 -r i386 -k $EC2_PRIVATE_KEY -c $EC2_CERT -u $EC2_USER_ID
Bulbgraph.png   bucket name (-b option below) is unique across Amazon S3, so the below may throw error. Remember not to paste EC2_SECRET_KEY/EC2_ACCESS_KEY public
ec2-upload-bundle -b original -m /tmp/ops-2.50-x86-root.ext3.manifest.xml -a $EC2_ACCESS_KEY -s $EC2_SECRET_KEY --location EU
ec2-register original/ops-2.50-x86-root.ext3.manifest.xml

This command should return the AMI id: ami-xxxxxxx

Startup the original

NET+

Start an instance of the original AMI:

ec2-run-instances -g tmp -t c1.medium ami-xxxxxx -k user-johndoe-eu

Thi shoul return the instace id i-xxxxxx, check when is ready the instance and the IP (to see the ip needed to be the instance completely loaded).

watch -n 10 ec2-describe-instances i-xxxxxx

Save the ip of the machine for connect by ssh.

Make changes

NET+

Connect to the origianal instance:

ssh ip

Make the necessary changes

Clean

If you are distributing openbravo binaries is mandatory to delete the checksums file:

rm -r /opt/OpenbravoERP/config/checksums

If you have updated core, probably you don't want to package in the AMI the backup:

rm -r /opt/OpenbravoERP/backup_install

Compress the changes

Create a compress file with the changes in database, sources and tomcat (the specified folders correspond with a rpath linux)

tar czvf /tmp/a.tar.gz /srv/pgsql /opt/OpenbravoERP /var/lib/tomcat/webapps/openbravo

For make easy to download, you can copy the file to the web folder :)

cp /tmp/a.tar.gz /srv/www/html

Donwload the changes

NET+++

wget ip/a.tar.gz

Apply the changes

NET+++

Two bad options:

  1. Mount the image and uncompress the file with the changes from outside. Then the owner and group of the files are wrong and take any of the machine in which we are.
  2. Mount the image, copy the file inside and uncompress. The problem here is that we are adding the size of the file to the bundle, that after uncompress and delete the compress file, we don't free again. This is because a ext3 file that once is extended can't be compressed the same as before instead it has the same used space.

So the correct way is this:

Uncompress the original fs.ext3 in a new folder

mkdir modified
tar xzvf ops-2.50-x86.fs.tar.gz -C modified

Mount the files

mkdir ori
sudo mount -o loop original/ops-2.50-x86/ops-2.50-x86-root.ext3 ori
mkdir ori/mnt/mod
sudo mount -o loop modified/ops-2.50-x86/ops-2.50-x86-root.ext3 ori/mnt/mod

Uncompress

Copy the file with the changes to the original:

cp /tmp/a.tar.gz ori/

Chroot to original and extract the file in the modified. This peserve the file size of the modified ami and the file permissions in the extracted files

sudo chroot ori
tar xzpvf /a.tar.gz -C /mnt/mod/

Check

The files extracted are here if you want to check that the process is correct

ls -al /mnt/mod/srv/pgsql
ls -al /mnt/mod/opt/OpenbravoERP
ls -al /mnt/mod/var/lib/tomcat/webapps/openbravo

Umount files

Exit of the chroot and Unmount volumes

exit
umount ori/mnt/mod
umount ori

Generate the bundle

NET+++

Generate the bundle

ec2-bundle-image -i mod/ops-2.50-x86/ops-2.50-x86-root.ext3 -r i386 -k $EC2_PRIVATE_KEY -c $EC2_CERT -u $EC2_USER_ID

Upload the bundle

ec2-upload-bundle -b new-bucket -m /tmp/ops-2.50-x86-root.ext3.manifest.xml -a $EC2_ACCESS_KEY -s $EC2_SECRET_KEY --location EU

Register the AMI

NET+

ec2-register new-bucket/ops-2.50-x86-root.ext3.manifest.xml

Give permissions

NET+

By default the AMI is private you can make it public, or especified the users that can use it:

ec2-modify-image-attribute -a user_id(without '-') -l ami-xxxxx
Bulbgraph.png   If you don't need more, remember to shutdown the temporally instance that we have use for the process. Also the original AMI instance if is no needed it can be halted.

Retrieved from "http://wiki.openbravo.com/wiki/Release_Management/Rebundling_Professional_Appliance_AMIs"

This page has been accessed 5,058 times. This page was last modified on 2 February 2010, at 07:45. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.