This documentation relates to an earlier version of Bamboo.
View

Unknown macro: {spacejump}

or visit the current documentation home.

An elastic image is an Amazon Machine Image (AMI) that is stored in the Amazon Simple Storage Service (S3) for use with the Elastic Bamboo feature. An elastic image is used to create elastic instances, which in turn create elastic agents. Conceptually, the elastic image can be considered to be the boot hard disk that contains the operating system and software run on your elastic instances.

You can associate multiple elastic images with a Bamboo server. One default shared image is maintained by Atlassian in the Amazon S3, and is available to all Elastic Bamboo users. You also create your own custom elastic images.

At a high level, the process for creating a custom elastic image consists of taking one of the existing AMIs (Amazon Machine Images) available on Amazon EC2, starting an instance of the AMI, customising the instance and then creating an image from the customised instance. This image can then be used as an elastic image in your Bamboo installation.

Please note, this is not a trivial process. You may wish to consider customising the elastic agents started from your existing image instead, by using Amazon's Elastic Block Store (EBS), as described in Configuring Elastic Instances to use EBS. This is a much simpler option. If you are having problems, please don't hesitate to contact us for further help.

Important Information

Please note the following important information:

  • These instructions are written for Unix/Linux operating systems.
  • A number of the EC2 commands in the steps below can be completed using the AWS console rather than command line tools (e.g. registering an image). However, we recommend that you follow the steps below unless you are an experienced AWS user.

On this page:

1. 要件

Before you begin, you need to ensure that you have set up the following:

  • Amazon Web Services (AWS) account with EC2 — if you are already using Elastic Bamboo, you should already have an AWS account with EC2 set up. If not, please read Getting Started with Elastic Bamboo.
  • Amazon EC2 API Tools — you must install the EC2 API tools on your local machine, otherwise you will not be able to start and access your AMI instance. You can install the EC2 API tools by executing the following commands:
    wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools-1.3-30349.zip
    unzip ec2-api-tools-1.3-30349.zip
  • Environment Variables — you must set up the following environment variables on your local machine before creating a custom elastic image:
    • EC2_HOME — インストール済みの EC2 API ツールのパスに設定します
    • EC2_CERT — EC2 アカウントに割り当てられた証明書のパスに設定します。
    • EC2_PRIVATE_KEY — AWS アカウントに割り当てられた非公開キーのパスに設定します。
  • Registered Key Pair — you need a registered EC2 key pair, which consists of a private key file and certificate file, to use the EC2 API tools with your AMI instance. If you have previously generated and registered an EC2 key pair (e.g. to use the EC2 API tools), you can re-use it. If you need to generate a new key pair, you can use the following command to do so:
    $EC2_HOME/bin/ec2_add_keypair <key_pair_name>
    The content of the private key will display in the command-line output on your console. Save this content in a file , starting with the line "-----BEGIN RSA PRIVATE KEY-----" and ending with the line "-----END RSA PRIVATE KEY-----". This private key file will be used to access your AMI instance. Set up the appropriate permissions on the private key file by executing the following command.
    chmod 600 <private_key_file>

2. Selecting an Existing AMI

We strongly recommend that you select an existing Linux/UNIX AMI to customise, rather than starting with a blank AMI. You can get the list of available AMIs by executing the following command:

$EC2_HOME/bin/ec2-describe-images -a

(warning) Please check whether you want to launch 32-bit or 64-bit instances from your custom elastic image before selecting an existing AMI. Elastic Bamboo creates"High-CPU Medium" instances (32-bit) by default.

We recommend the following existing Linux/UNIX AMIs for customisation:

  • ami-e55bbd8c — this AMI is the default image provided by Atlassian. It is a Fedora 8 image updated and prepared for Bamboo, i.e. you will not have to install any Bamboo prerequisites.
  • ami-2b5fba42 — this is the base Fedora 8 image provided by Amazon. It does not have any Bamboo prerequisites installed.
  • ami-0d729464 — this is an Ubuntu 9.04 image provided by Alestic. It does not have any Bamboo prerequisites installed. You can find more Ubuntu images on the Alestic site. Please note, these images are not maintained by Atlassian.

3. Starting an Instance

After you have selected an existing AMI to customise, the next step is to start an instance of the AMI. Use the ec2-run-instances command to start your instance, as follows:

$EC2_HOME/bin/ec2-run-instances <image_name> -k <key_pair_name>

where <image_name> is the name of the AMI selected in the previous step and <key_pair_name> is the name of the registered key pair generated in '1. Requirements' (the public certificate of this key will be injected into your instance).

たとえば、キー ペア my-keypair を使用してイメージ ami-e55bbd8c のインスタンスを起動する場合は、次のコマンドを実行します。

$EC2_HOME/bin/ec2-run-instances ami-e55bbd8c -k my-keypair

このコマンドのコマンド ライン出力は次のとおりです。

INSTANCE        i-25b86743   ami-e55bbd8c     running   my-keypair

i-25b86743 is the name of your new instance, in the above example. Note this down, as you will need the instance name to access your instance in the next step.

使用されていないインスタンスをシャットダウンすることを忘れないでください。

Please note, once you start an instance, you will be billed by Amazon for instance uptime. If you decide to abandon the setup of a custom elastic image after this step, please ensure that you shut down your instance via the AWS console.

4. Accessing your Instance

インスタンスが実行されていれば、インスタンスにアクセスできるようにインスタンスのアドレスを取得する必要があります。そのためには、次のコマンドを使用します。

ec2-describe-instances <instance_name>

たとえば、インスタンス i-25b86743 のアドレスを調べるには、次のように入力します。

ec2-describe-instances i-25b86743

このコマンドのコマンド ライン出力は次のようになります。

RESERVATION	r-790f7210	121852097033	default
INSTANCE	i-25b86743	ami-e55bbd8c 	ec2-174-129-94-241.compute-1.amazonaws.com
domU-12-31-39-04-38-87.compute-1.internal	running	elasticbamboo	0		m1.small
2009-06-24T12:36:20+0000	us-east-1c	aki-a71cf9ce	ari-a51cf9cc
monitoring-disabled

The address of your instance in the above example is ec2-174-129-94-241.compute-1.amazonaws.com

You can then use this address to access the instance via SSH. See Accessing an Elastic Instance for instructions. If you are using the example command text from that document, you will need to adjust it as follows:

  • replace /opt/bamboo/home/xml-data/configuration/elasticbamboo.pk in the example command text with the private key file you generated in '1. Requirements'.
  • サンプル コマンド テキスト内の ec2-68-111-185-197.compute-1.amazonaws.com を対象のインスタンスのアドレスに置き換えます。

5. Customising your Instance

Customising your instance is the most complicated part of creating a custom elastic image. You need to install the packages that are prerequisites for Bamboo onto your instance (if you didn't choose the Elastic Bamboo default image as your base AMI), add your customisations, deploy Bamboo onto your instance and set up an EC2 environment on your instance.

5.1 Installing Bamboo Prerequisite Packages

If you selected ami-e55bbd8c as your base AMI in '2. Selecting an Existing AMI', you can skip this step and go to '5.2 Adding Customisations' as image ami-e55bbd8c has been pre-configured for Bamboo. If you have selected a different AMI, you will need to install the following packages onto your instance using the commands shown below:

  1. Amazon EC2 API ツール
    wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools-1.3-30349.zip
    unzip ec2-api-tools-1.3-30349.zip
    mv ec2-api-tools-1.3-30349 /usr/local/ec2/ec2-api-tools
    
  2. Java 6 and Java 5
    # get Java 6
    wget "http://download.java.net/dlj/binaries/jdk-6u11-dlj-linux-i586.bin"
    mkdir unbundle-jdk-6
    cd unbundle-jdk-6
    sh ../jdk-6u11-dlj-linux-i586.bin --accept-license
    cd ..
    
    # get Java 5
    wget "http://download.java.net/dlj/binaries/jdk-5.0u17-dlj-linux-i586.bin"
    mkdir unbundle-jdk-5
    cd unbundle-jdk-5
    sh ../jdk-5.0u17-dlj-linux-i586.bin --accept-license
    cd ..
    
    # Build the JDKs
    curl "https://jdk-distros.dev.java.net/source/browse/jdk-distros/trunk/utils/construct.sh?content-type=text/plain&rev=148" > construct.sh
    chmod +x construct.sh
    ./construct.sh unbundle-jdk-6 /opt/jdk-6 /opt/jre-6
    ./construct.sh unbundle-jdk-5 /opt/jdk-5 /opt/jre-5
    
  3. ant
    wget "http://www.apache.org/dist/ant/binaries/apache-ant-1.7.1-bin.tar.bz2"
    tar xjC /opt -f apache-ant-1.7.1-bin.tar.bz2
    
  4. Maven 2
    wget "http://www.apache.org/dist/maven/binaries/apache-maven-2.0.10-bin.tar.bz2"
    tar xjC /opt -f apache-maven-2.0.10-bin.tar.bz2
    mv /opt/apache-maven-2.0.10 /opt/maven-2.0
    ln -fs /opt/maven-2.0 /opt/apache-maven-2.0.10
    
  5. (optional) Maven 1.1
    wget "http://archive.apache.org/dist/maven/binaries/maven-1.1.tar.bz2"
    tar xjC /opt -f maven-1.1.tar.bz2
    

5.2 Adding User Customisations to your Instance

Adding your own customisations is quite a simple process, once you have made it this far.

To add user customisations to your instance,

  1. Log into your elastic instance (as previously described in '4. Accessing your Instance').
  2. Once you have logged into your elastic instance, you can treat it as a standalone machine and install anything you want. For example, if you want to install Tomcat on an Ubuntu instance you would run 'sudo apt-get install tomcat6', configure it, ensure that your startup scripts are in place, etc, just as you would when installing Tomcat on a standalone machine.
    (warning) Please note however, you cannot customise the operating system of a running instance. If you want to create an instance with a customised operating system (e.g. Ubuntu), you will need to select an AMI with that operating system installed (as previously described in '2. Selecting an Existing AMI').
  3. Everything that you install will be saved in snapshot image created at the end of these instructions (see '6. Creating an Image of your Customised Instance'). Any instances started from this image will have all of your user customisations automatically installed.

5.3 Deploying Bamboo onto your Instance

Once you have installed the Bamboo pre-requisites on you instance and added your customisations, you can deploy Bamboo onto your instance.
Before you deploy anything however, you need to create a 'bamboo' user on your instance by running the following command:

useradd -m bamboo

After you have created the 'bamboo' user, you need to copy the Elastic Bamboo artifacts from your local bamboo installation onto your instance by using the following commands:

cd <LOCAL_BAMBOO_INSTALLATION_DIRECTORY>/webapp
scp -i <private_key_file> atlassian-bamboo-agent-elastic-assembly-<x.x.x>.tar.gz root@<instance_address>:/mnt

where <private_key_file> is the private key file generated in '1. Requirements', <instance_address> is the address of your instance from '4. Accessing your Instance' and <BAMBOO_STANDALONE_DIRECTORY> is your Bamboo Installation directory

Navigate to the /mnt directory on your instance and install the artifacts, as described below:

Unknown macro: {htmlcomment}
  1. Maven 1.0.2 (patched version)
    tar xzC /opt -f maven-1.0.2.tar.gz

  1. Bamboo Agent binaries
    tar xzC /opt -f atlassian-bamboo-agent-elastic-assembly-<x.x.x>.tar.gz
    ln -s /opt/bamboo-elastic-agent-<x.x.x> /opt/bamboo-elastic-agent
    
    where <x.x.x> is the Bamboo version you are running (e.g. 2.4.1)
    (info) atlassian-bamboo-agent-elastic-assembly-2.3.tar.gz is available in the webapp sub-directory of the Bamboo installation directory.
  2. Bamboo Agent default capabilities definition file
    mv bamboo-elastic-agent/bamboo-capabilities.properties /home/bamboo/

5.4 Instance Configuration

At this stage, you should have a customised instance with Bamboo deployed onto it. The last step in creating a customised instance is to set up an EC2 environment on your instance. Carry out the following steps to set this up:

  1. Transfer Amazon private key file and certificate to your instance
    Transfer the key files to your instance by running these commands on your local machine:
    scp -i <private_key_file> $EC2_PRIVATE_KEY root@<instance_address>:/mnt
    scp -i <private_key_file> $EC2_CERT root@<instance_address>:/mnt
    
    where <private_key_file> is the private key file from your local machine created in step 'Registered Key Pair' of 1. Requirements and the <instance_address> is the address of your instance from '4. Accessing your Instance'
  2. Set up EC2_HOME and JAVA_HOME environment variables
    Set up these environment variables by running the following commands on your instance:
    export EC2_HOME=/usr/local/ec2/ec2-api-tools
    export EC2_PRIVATE_KEY=/mnt/<ec2_private_key_file>
    export EC2_CERT=/mnt/<ec2_certificate_file>
    export JAVA_HOME=/opt/jdk-5
    
  3. Set appropriate permissions for the bamboo user directory
    Run the following command on your instance to set permissions on the bamboo user directory:
    chown -R bamboo:bamboo /home/bamboo/
    
  4. パス変数を設定する
    インスタンスの /mnt ディレクトリに profile.sh ファイルを作成します。このファイルには、以下に示すように、Elastic Bamboo の既定のパス設定が含まれています。
    export JAVA_HOME=/opt/jdk-5
    export M2_HOME=/opt/maven-2.0
    export MAVEN_HOME=/opt/maven-1.0.2
    export ANT_HOME=/opt/apache-ant-1.7.1
    export EC2_HOME=/usr/local/ec2/ec2-api-tools
    export EC2_PRIVATE_KEY=/root/pk.pem
    export EC2_CERT=/root/cert.pem
    export PATH=/opt/bamboo-elastic-agent/bin:$EC2_HOME/bin:$JAVA_HOME/bin:$M2_HOME/bin:$MAVEN_HOME/bin:$ANT_HOME/bin:$PATH
    
    If all of the tools on this page were installed in recommended locations, no changes are required. Otherwise, you can update the file as required.
    Once profile.sh is correctly customised for your instance, you need to copy it to the /etc/profile.d directory by running the following command on your instance in the /mnt directory:
    mv profile.sh /etc/profile.d/bamboo.sh
    
  5. Configure automatic startup of the Bamboo agent
    You will need to configure your instance to start up the Bamboo agent automatically when the instance is started. You can do this by appending the rc.local file to the one that already exists on your instance, by running the following command on your instance in the mnt directory:
    cat /opt/bamboo-elastic-agent/rc.local >> /etc/rc.d/rc.local
  6. Final settings and cleanup
    Finally, create a Bamboo welcome screen and clean up keys on your instance by running the following command:
    echo bamboo-<x.x.x>  >> /opt/bamboo-elastic-agent/motd
    mv /opt/bamboo-elastic-agent/motd /etc/motd
    rm -f /root/firstlogin /etc/ssh/ssh_host_da_key /etc/ssh/ssh_host_dsa_key.pub
    /etc/ssh/ssh_host_key /etc/ssh/ssh_host_key.pub /etc/ssh/ssh_host_rsa_key
    /etc/ssh/ssh_host_rsa_key.pub /root/.ssh/authorized_keys
    touch /root/firstrun
    
    where <x.x.x> is the Bamboo version you are running (e.g. 2.4.1)

6. Creating an Image of your Customised Instance

The final step is to create an image from your customised instance. To do this, you will require the following information:

You can create an image of your customised instance by using the ec2-bundle-vol command, as follows:

/usr/local/bin/ec2-bundle-vol -c $EC2_CERT -k $EC2_PRIVATE_KEY -u <amazon_account_number> -p <elastic_image_name> --batch --debug

ここで、<elastic_image_name> は、カスタム イメージに割り当てる名前です (「CustomImage1」など)。

イメージが作成されたら、次のコマンドを実行して Amazon S3 にアップロードする必要があります。

/usr/local/bin/ec2-upload-bundle -b <s3_bucket_name> -m /tmp/<elastic_image_name>.manifest.xml -a <access_key_id> -s <secret_access_key> --retry --debug

where <s3_bucket_name>, <access_key_id> and <secret_access_key> are the Amazon S3 bucket name, Access Key ID and Secret Access Key described previously, and <elastic_image_name> is the name that you want to assign to your custom image (e.g. 'CustomImage1')

You will then need to register your image with Amazon EC2 by using the ec2-register command:

$EC2_HOME/bin/ec2-register <s3_bucket_name>/<elastic_image_name>.manifest.xml

where <s3_bucket_name> is the Amazon S3 bucket name described previously and <elastic_image_name> is the name that you want to assign to your custom image (e.g. 'CustomImage1')

The output of this command will show the AMI ID of your custom image.

Congratulations, you have successfully set up a custom elastic image!

7. 次のステップ

カスタム エラスティック イメージの作成が終了したら、それを使用できるようにするために、さらに 2 つのステップを完了する必要があります。

First, you will need to associate your custom elastic image with your Bamboo installation by creating an Elastic Image Configuration. Please note the AMI ID of your new custom image and read Managing your Elastic Image Configurations for further instructions.

Secondly, you will need to configure the capabilities of the elastic agents that will run on instances started from your image. This is done by adding the appropriate builder, JDK, Perforce and custom capabilities to your elastic image configuration, so that it reflects what your custom elastic image actually can do. For example, if you have created a custom elastic image with JDK 1.6 and Maven 2 installed, you will need to add capabilities for JDK 1.6 and Maven 2 to the elastic image configuration. Read Configuring Elastic Agent Capabilities for further instructions.

8. Need More Help?

さらに支援が必要な場合は、次のようなリソースを活用できます。

  • AWS Support Center — if you are having problems with any of your Amazon services, not specifically related to Bamboo, you can obtain basic support from the AWS Support Center. Note, you will need to sign up for Premium Support to get access to web/phone support.
  • AWS Resource Center — the AWS Resource Center has links to online documentation, code samples and tools for AWS services.
  • Atlassian Support — if you are having problems with any of the Bamboo-related steps of this process, please raise a ticket in the Bamboo project on our support system and our support team will respond as soon as possible.
  • Bamboo Developer Forums — please feel free to discuss any useful tips or issues regarding this process in the Bamboo Developer Forums.