Atlassian doesn't provide support for customized images. Bamboo provides flexibility to use customized machine images, but it's impossible for us to support all individual configurations.

Use Bamboo stock images as the base for all image customizations to ensure a minimal level of consistency of your Elastic Bamboo setup.

5.インスタンスをカスタマイズする

Customizing 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 stock images as your base AMI), add your customizations, deploy Bamboo onto your instance and set up an EC2 environment on your instance.

5.1 Bamboo 前提条件パッケージのインストール

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 Customizations' as this image 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:

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

You need to install a 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 ユーザー カスタマイズをインスタンスに追加する

ここまで完了したら、独自のカスタマイズを追加するプロセスは非常に簡単です。

ユーザー カスタマイズをインスタンスに追加するには:

  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 customize the operating system of a running instance. If you want to create an instance with a customized 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 Customized Instance'). Any instances started from this image will have all of your user customizations automatically installed.

5.3 Bamboo をインスタンスにデプロイする

Bamboo の前提条件をインスタンスにインストールしてカスタマイズを追加したら、Bamboo のエラスティック ブートストラップ ファイルをインスタンスにデプロイできます。

5.3.1 Bamboo ユーザーを作成する

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

useradd -m bamboo

5.3.2 エージェントのインストーラーをインスタンスにダウンロードする

Then, install Bamboo Agent binaries as described below. In this case we're using image version 2.2, you should use the latest version available at https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/bamboo/atlassian-bamboo-elastic-image/.

imageVer=2.2
wget https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/bamboo/atlassian-bamboo-elastic-image/${imageVer}/atlassian-bamboo-elastic-image-${imageVer}.zip
sudo mkdir -p /opt/bamboo-elastic-agent
sudo unzip -o atlassian-bamboo-elastic-image-${imageVer}.zip -d /opt/bamboo-elastic-agent
sudo chown -R bamboo /opt/bamboo-elastic-agent
sudo chmod -R u+r+w /opt/bamboo-elastic-agent

5.4 インスタンス設定

この段階では、カスタマイズされたインスタンスに Bamboo がデプロイされているはずです。カスタマイズされたインスタンスを作成する最後のステップは、インスタンスに EC2 環境をセットアップすることです。これをセットアップするには、次の手順を実行します。

  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
    

    このページのすべてのツールが推奨される場所にインストールされている場合、変更は必要ありません。それ以外の場合は、必要に応じてファイルを更新できます。
    profile.sh をインスタンスに合わせて正しくカスタマイズしたら、インスタンスの /mnt ディレクトリで次のコマンドを実行して、このファイルを /etc/profile.d ディレクトリにコピーする必要があります。

    mv profile.sh /etc/profile.d/bamboo.sh
  3. Bamboo エージェントの自動起動を設定する
    インスタンスの起動時に Bamboo エージェントが自動的に起動するようにインスタンスを設定する必要があります。これは、/etc/rc.local ファイルに Bamboo の rc.local ファイルを調達 (source) することで実現できます。

    . /opt/bamboo-elastic-agent/etc/rc.local
    

    必ず /etc/rc.local の「exit 0」行の前にこの行を追加してください。

  4. 最後の設定とクリーンアップ
    最後に、次のコマンドを実行して Bamboo のようこそ画面を作成し、インスタンスのキーをクリーンアップします。

    cp /opt/bamboo-elastic-agent/etc/motd /etc/motd
    echo bamboo-<x.x.x>  >> /etc/motd
    rm -f /root/firstlogin /etc/ssh/ssh_host_dsa_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
    

    <x.x.x> は実行している Bamboo のバージョン (4.1.2 など) です。

  5. 次に、「カスタマイズしたインスタンスのイメージを作成する」セクションの手順に従って AMI を作成します。

  6. Bamboo からイメージを起動します。エージェントが起動し、必要なすべてのデータを EC2 インスタンスにダウンロードします。
  7. /opt/bamboo-elastic-agent/bin/prepareInstanceForSaving.sh を実行します。
  8. 次に、「カスタマイズしたインスタンスのイメージを作成する」セクションの手順に従って AMI を作成します。これで完了です。新しく作成された AMI には、Bamboo エージェントを起動するのに必要なものがすべて含まれています。

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

su -c /opt/bamboo-elastic-agent/bin/bamboo-elastic-agent - bamboo

  • ラベルなし