Custom images for Atlassian Bambooby Jon Atkinson, 05 Apr 2014
We heavily use Atlassian Bamboo for continuous integration. Unfortunately, the base images supplied with Bamboo, well, they're terrible.
This covers setting up a customised image, configured to run the Bamboo Elastic Agent. We configure these images to run our Django/Python stack, but that's optional, and you can replace these packages with whatever you need.
Setup and requirements
This assumes a base of the Ubuntu 12.04 LTS image, which is referenced in EC2 as
ami-6aad335a. This image has a default user called
ubuntu, which has
- Create the instance in EC2. Make sure you're creating the image in the appropriate region to match your Bamboo configuration:
- Setup the access rules so that you can get in.
Connect to the instance:
$ ssh -i /path/to/your.pem -l ubuntu
Update the packages on the instance:
$ sudo apt-get update && # sudo apt-get upgrade
Install some prerequisites which we'll need to complete these steps:
$ sudo apt-get install unzip wget
Install the Java requirements. You'll need JDK and a working Maven installation:
$ sudo apt-get install default-jdk maven2
Setting up the Bamboo agent
First, create the user:
$ sudo useradd -m bamboo
Get the most recent version of the Bamboo agent. This can be found at
https://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/bamboo/atlassian-bamboo-elastic-image/. The below retrieves the latest version at the time of writing:
$ cd /tmp/
$ wget http://maven.atlassian.com/content/repositories/atlassian-public/com/atlassian/bamboo/atlassian-bamboo-elastic-image/3.0/atlassian-bamboo-elastic-image-3.0.zip
Create a folder for the agent to live in:
$ sudo mkdir -p /opt/bamboo-elastic-agent
Unzip the agent.
$ sudo unzip -o atlassian-bamboo-elastic-image-3.0.zip -d /opt/bamboo-elastic-agent/
$ sudo chown -R bamboo /opt/bamboo-elastic-agent $ sudo chmod -R u+r+w /opt/bamboo-elastic-agent
bamboouser's profile script:
$ sudo vim /etc/profile.d/bamboo.sh
Add the following:
export JAVAHOME=/usr export EC2HOME=/usr export EC2PRIVATEKEY=/root/pk.pem export EC2CERT=/root/cert.pem` export PATH=/opt/bamboo-elastic-agent/bin:$EC2HOME/bin:$JAVAHOME/bin:$M2HOME/bin:$MAVENHOME/bin:$ANTHOME/bin:$PATH
/etc/rc.local, add the following line, before the final
Setup the MOTD:
$ sudo cp /opt/bamboo-elastic-agent/etc/motd /etc/motd
Customise the MOTD:
$ sudo "echo bamboo-5.4-OD-3 >> /etc/motd"
Now, we should do a little housekeeping to clean up the instance:
$ sudo rm -f /root/firstlogin /etc/ssh/sshhostdsakey /etc/ssh/sshhostdsakey.pub /etc/ssh/sshhostkey /etc/ssh/sshhostkey.pub /etc/ssh/sshhostrsakey /etc/ssh/sshhostrsakey.pub /root/.ssh/authorized_keys
$ sudo touch /root/firstrun
- Create a new AMI from the instance.
- Once the image has been created, check the permissions are set appropriately, and then find the ami-id for your new image.
- Visit Bamboo > Image Configurations > New Image, and register the image with your Bamboo server. You may need to modify any existing build plans to prefer this image.