[Bamboo Knowledge Base]
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 stock images 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 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 tools
wget http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip unzip ec2-api-tools.zip mv ec2-api-tools-* /opt/ec2-api-tools
Note: if your distribution already contains ec2-api-tools package, you can install it instead.
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.
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.
First, you need to create a 'bamboo
' user on your instance by running the following command:
useradd -m bamboo
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
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:
Run the following command on your instance to set permissions on the bamboo user directory:
chown -R bamboo:bamboo /home/bamboo/
Configure path variables
Create a file profile.sh in your instance's /mnt
directory. This file contains the default Elastic Bamboo path configuration settings, as seen below:
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 the Bamboo agent automatically when the instance is started. You can do this by sourcing Bamboo rc.local file in /etc/rc.local file:
. /opt/bamboo-elastic-agent/etc/rc.local
Make sure you add this line before the "exit 0" line in your /etc/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_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
where <x.x.x> is the Bamboo version you are running (e.g. 4.1.2).
Now, follow the instructions from section "Creating an image of your Customised Instance" to create an AMI.
Note: if you started your instance from Bamboo right at the start, instead of steps 5 & 6, you can just run:
su -c /opt/bamboo-elastic-agent/bin/bamboo-elastic-agent - bamboo