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.
始める前に
On this page:
Before you begin, you need to ensure that you have set up the following:
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>
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
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):
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:
https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/bamboo/atlassian-bamboo/ を Web ブラウザーで開きます。.pom and some additional checksum files.atlassian-bamboo-x.x.x.pom ファイル (x.x.x は Bamboo のバージョン) を開きます。イメージのバージョン / ベースラインは elastic-image.version タグに保存されています。たとえば、バージョン 3.4.4 の場合、ベースラインは 1.7 でした。elastic-image.version タグで確認したイメージ ベースライン バージョンをクリックします。ami 拡張子の付いたファイルにすべてのストック イメージ AMI ID が含まれています。After you have selected an existing AMI to customise, the next step is to start an instance of the 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.
次のように、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.
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).
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:
/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 を対象のインスタンスのアドレスに置き換えます。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.
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:
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 パッケージが含まれている場合は、代わりにそれをインストールできます。
Java JRE
Adding your own customisations is quite a simple process, once you have made it this far.
To add user customisations to your instance:
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.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.
最初に、次のコマンドを実行してインスタンス上に「bamboo」ユーザーを作成する必要があります。
useradd -m bamboo
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
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:
インスタンス上で次のコマンドを実行して、bamboo ユーザー ディレクトリの権限を設定します。
chown -R bamboo:bamboo /home/bamboo/
パス変数を設定する
インスタンスの /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
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
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).
注: 最初に Bamboo からインスタンスを起動した場合は、ステップ 5 と 6 の代わりに以下を実行するだけで済みます。
su -c bamboo-elastic-agent - bamboo
新しいイメージを作成するプロセスは、イメージがインスタンス ストアと EBS ルート イメージのどちらに基づいているかによって異なります。イメージのタイプは、AWS コンソールまたは ec2-describe-images を使用して確認できます。
See here for instructions: Amazon Tutorial
The final step is to create an image from your customised instance. To do this, you will require the following information:
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'.
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>
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」など)。
イメージが作成されたら、次のコマンドを実行して 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')
次に、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 が表示されます。
カスタム エラスティック イメージの作成が終了したら、それを使用できるようにするために、さらに 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.
さらに支援が必要な場合は、次のようなリソースを活用できます。
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'.
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.