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 one of Amazon data centres for use with the Elastic Bamboo feature. An elastic image is used to create elastic instances, which in turn create elastic agents. Conceptually, an elastic image is equivalent to an operating system running on a computer's boot hard drive and elastic instances would be the software that runs on this operation system.

Each elastic image registered with the Amazon Web Services (AWS) has its own unique identifier, known as an AMI ID.

You can associate multiple elastic images with a Bamboo server. One default shared image is maintained by Atlassian in AWS, 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 Amazon Machine Images (AMIs) 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.

始める前に

  • This is not a trivial procedure. Instead of creating a custom elastic image, you may want to consider customising an existing Bamboo image by using Amazon's Elastic Block Store (EBS), as described in Configuring Elastic Instances to use the EBS. This is a much simpler option. If you are having problems, please don't hesitate to contact us for further help.
  • Please note, Atlassian does not support custom elastic images. Consider customising the elastic agents started from your existing image instead.
  • 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. Note: you need Java Runtime Environment to run these tools. You can install the EC2 API tools by executing the following commands:

    wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip
    unzip ec2-api-tools.zip
  • 環境変数 — カスタム エラスティック イメージを作成する前に、ローカル マシンで次の環境変数を設定する必要があります。
    • EC2_HOME — インストール済みの EC2 API ツールのパスに設定します
    • EC2_CERT — EC2 アカウントに割り当てられた証明書のパスに設定します。
    • EC2_PRIVATE_KEY — AWS アカウントに割り当てられた非公開キーのパスに設定します。
  • 登録済みキー ペア — AMI インスタンスで EC2 API ツールを使用するには、非公開キー ファイルと証明書ファイルで構成される登録済み EC2 キー ペアが必要です。以前に EC2 キー ペアを生成して登録したことがある場合は (EC2 API ツールを使用するためなど)、それを再利用できます。新しいキー ペアを生成する必要がある場合は、次のコマンドを使用して生成できます。

    ec2-add-keypair <key_pair_name>

    The content of the private key will be displayed in the command-line output on your console. Save this content in a file, starting with the line:

    "--BEGIN RSA PRIVATE KEY--"

    末尾には次の行を追加します。

    "--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-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 (in order of preference):

  • Atlassian's AMI — this AMI is the default image provided by Atlassian. It is an Amazon Linux image updated and prepared for Bamboo, i.e. you will not have to install any Bamboo prerequisites.
  • Amazon's AMI — this is the base CentOS-based image provided by Amazon. It does not have any Bamboo prerequisites installed. Typically, you will be better off using the Atlassian AMI.
  • Canonical's AMI — this is an Ubuntu image provided by Canonical. It does not have any Bamboo prerequisites installed. You can find AMI ids for Ubuntu images on the Canonical's site.

The names of Atlassian's and Amazon's AMIs (and hence, their IDs) may change with each release of Bamboo, including both major and minor (or point) releases. To quickly access Atlassian's AMI ID for a currently-running version of Bamboo, open that Bamboo site in a web browser and access its 'Image Configurations' page (see Managing your Elastic Image Configurations for more information). The AMI IDs of Atlassian's AMIs are labelled with "(stock image)".

If you want to find out the AMI IDs for a version of Bamboo you don't have running or you're starting an image from scratch and you need the image baseline, the procedure is more complicated:

  1. URL https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/bamboo/atlassian-bamboo/ を Web ブラウザーで開きます。
  2. On the resulting directory page, click the link that represents the version of Bamboo you are currently running. For example, if you are running Bamboo 3.4.4, click on the 3.4.4 link. Another directory page opens, listing a .pom and some additional checksum files.
    (warning) Do not click on a version number link that contains 'mX', 'rcX' or 'betaX' (where 'X' is a number), since these relate to publicly available developmental releases of Bamboo.
  3. atlassian-bamboo-x.x.x.pom ファイル (x.x.x は Bamboo のバージョン) を開きます。イメージのバージョン / ベースラインは elastic-image.version タグに保存されています。たとえば、バージョン 3.4.4 の場合、ベースラインは 1.7 でした。
  4. Open the following URL: https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/bamboo/atlassian-bamboo-elastic-image/ in a web browser.
  5. elastic-image.version タグで確認したイメージ ベースライン バージョンをクリックします。
  6. 表示されたディレクトリ ページでは、ami 拡張子の付いたファイルにすべてのストック イメージ AMI ID が含まれています。

3. Starting an Instance

After you have selected an existing AMI to customise, the next step is to start an instance of the AMI.

3.1 アトラシアンの既定の AMI のインスタンスを起動する

If you chose to customise Atlassian's default AMI, you must start the instance from the admin section of Bamboo. See Starting an Elastic Instance.

アトラシアンの既定の AMI は、コマンド ラインの ec2 ツールでは起動できません。これは、起動時に、アトラシアンの AMI の Bamboo エージェントによって、それが Bamboo Server から起動されたかどうかが確認され、そうでない場合はすぐにシャットダウンされるためです。

Once started, see Accessing an Elastic Instance for details on how to access the running instance.

3.2 コマンド ラインからインスタンスを起動する

次のように、ec2-run-instances コマンドを使用してインスタンスを起動します。

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-run-instances ami-e55bbd8c -k my-keypair

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

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

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

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

Please note that 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.

3.3 Bamboo からインスタンスを起動する

You can also start a fresh, uncustomised image from Bamboo and begin customisation. The drawback of this approach is that you have only 40 minutes before Bamboo shuts down your instance. The advantage is that you can customise the agent in a single step (as opposed to having to customise/create image/start from Bamboo/save image again).

4. Accessing your Instance

If you started the instance from Bamboo, see Accessing an Elastic Instance for details on how to access the running 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 for the instance in the above example is ec2-174-129-94-241.compute-1.amazonaws.com

You can use the 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 Atlassian's AMI as your base AMI in '2. Selecting an Existing AMI', you can skip this step and go to '5.2 Adding Customisations' as this imagehas 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.zip
    unzip ec2-api-tools.zip
    mv ec2-api-tools-* /opt/ec2-api-tools
    

    注: ディストリビューションにすでに ec2-api-tools パッケージが含まれている場合は、代わりにそれをインストールできます。

  2. Java JRE

    You need to install JRE (or JDK) on your instance to be able to run the agent. The preferred way of doing this is to install a package that came with your distribution. For a list of supported JREs, see supported platforms .

     

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 elastic bootstrap files onto your instance.

5.3.1

最初に、次のコマンドを実行してインスタンス上に「bamboo」ユーザーを作成する必要があります。

useradd -m bamboo

5.3.2

Then, install Bamboo Agent binaries as described below. In this case we're using image version 1.8, you can find out which version you need by following the steps in section "Selecting an Existing AMI". Bamboo 3.4 is a special case, you should use image version 1.8 with it.

imageVer=1.8
wget https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/bamboo/atlassian-bamboo-elastic-image/${imageVer}/atlassian-bamboo-elastic-image-${imageVer}.zip
mkdir -p /opt/bamboo-elastic-agent
unzip atlassian-bamboo-elastic-image-${imageVer}.zip -d /opt/bamboo-elastic-agent

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 setting up an EC2 environment on your instance. Carry out the following steps to set this up:

  1. インスタンス上で次のコマンドを実行して、bamboo ユーザー ディレクトリの権限を設定します。

    chown -R bamboo:bamboo /home/bamboo/
    
  2. パス変数を設定する
    インスタンスの /mnt ディレクトリに profile.sh ファイルを作成します。このファイルには、以下に示すように、Elastic Bamboo の既定のパス設定が含まれています。

    export JAVA_HOME=<path to JRE used to start the agent>
    export EC2_HOME=<location of your EC2 tools installation>
    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
    
  3. 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/etc/rc.local >> /etc/rc.d/rc.local
  4. Final settings and cleanup
    Finally, create a Bamboo welcome screen and clean up keys on your instance by running the following command:

    cp /opt/bamboo-elastic-agent/etc/motd /etc/motd
    echo bamboo-<x.x.x>  >> /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. 3.4.4).

  5. Now, follow the instructions from section "Creating an image of your Customised Instance" to create an AMI.
  6. Bamboo からイメージを起動します。エージェントが起動し、必要なすべてのデータを EC2 インスタンスにダウンロードします。
  7. Run /opt/bamboo-elastic-agent/bin/prepareInstanceForSaving.sh .
  8. Now, follow the instructions from section "Creating an image of your Customised Instance" to create an AMI. That's it, the newly created AMI contains everything you need to start Bamboo Agents.

注: 最初に Bamboo からインスタンスを起動した場合は、ステップ 5 と 6 の代わりに以下を実行するだけで済みます。

su -c bamboo-elastic-agent - bamboo

6. Creating an Image of your Customised Instance

新しいイメージを作成するプロセスは、イメージがインスタンス ストアと EBS ルート イメージのどちらに基づいているかによって異なります。イメージのタイプは、AWS コンソールまたは ec2-describe-images を使用して確認できます。

EBS ルート インスタンスからイメージを作成する

See here for instructions: Amazon Tutorial

インスタンス ストア (S3) インスタンスからイメージを作成する

 

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

  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=<location of your EC2 tools installation>
    export EC2_PRIVATE_KEY=/mnt/<ec2_private_key_file>
    export EC2_CERT=/mnt/<ec2_certificate_file>
    export JAVA_HOME=<path to JRE used to start the agent>
    
  3. You can create an image of your customised instance by using the ec2-bundle-vol command, as follows:

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

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

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

    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')

  5. 次に、ec2-register コマンドを使用して、Amazon EC2 にイメージを登録する必要があります。

    ec2-register <s3_bucket_name>/<elastic_image_name>.manifest.xml

    ここで、<s3_bucket_name> は、前述の Amazon S3 バケット名です。<elastic_image_name> は、カスタム イメージに割り当てる名前です (「CustomImage1」)。このコマンドの出力には、カスタム イメージの AMI ID が表示されます。

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.
  • Bamboo Developer Forums — please feel free to discuss any useful tips or issues regarding this process in the Bamboo Developer Forums.

 

To quickly access Atlassian's AMI ID for a currently-running version of Bamboo, open that Bamboo site in a web browser and access its 'Image Configurations' page (see Managing your Elastic Image Configurations for more information). The AMI ID of Atlassian's AMI is listed in the table row with the name 'Default Image'.

  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'.

     

Now, follow the instructions from section "Creating an image of your Customised Instance" to create an AMI.