Problem With Elastic Agents
Asked by George Irwin:

I'm using Bamboo OnDemand and I'm having trouble getting Agents to start when using Images (AMI). I've created a custom AMI which has Ubuntu, PostgreSQL, Python etc installed. When I use Bamboo to create an Elastic Instance with this AMI, the Instance is created successfully, but the Elastic Agent doesn't start (sticks on pending for more than 15 minutes).

I've also tried using the standard Ubuntu 12.10 AMI to see whether my custom AMI has broken something, but the problem is the same.

Can anyone tell me how to troubleshoot this or solve it??

Thanks

**EDIT:**

Thanks to all Przemek's help, I've managed to get a custom ubuntu-based AMI working with Bamboo. Mostly. I can start the Instance through Bamboo, but it won't start the Elastic Agent on that Instance. I have to SSH into the Instance and manually start the Elastic Agent with:

```
sudo su - bamboobamboo-elastic-agent
```

I've been trying to get that process to run via the Startup Script setting in Bamboo's Image Configuration:

```
#!/bin/bashxterm -hold -e "sudo su - bamboo &amp;&amp; bamboo-elastic-agent"fi
```

But that doesn't seem to work. Is there anyway that I can get the Startup Script to start the Elastic Agent instead of me having to SSH in and do it myself?!

Once I manually start the Elastic Agent, then I am able to successfully run my Django tests through Bamboo and see the test reports.

**EDIT 2:**

All is now working 100%. It seems I hadn't correctly copied the contents of the bamboo-elastic-agent startup script into rc.local. However, I now have a working AMI with Ubuntu, postgrsql, python and my production environment installed and working correctly with Bamboo. Thanks to Przemek for all his help.


Answers:
author: Przemek Bruski
body: Did you put elastic agent data on your image?

comments: author: George Irwin
body: Thanks Przemek, but I'm not sure what you mean...?


author: George Irwin
body: OK Przemek, I'm following the instrcutions here:

<https://confluence.atlassian.com/display/BAMBOO/Creating+a+custom+elastic+image+-+Linux>

However, running:

cat /opt/bamboo-elastic-agent/etc/rc.local \>\> /etc/rc.d/rc.local

returns no such file or directory.

I have rc0.d, rc1.d ...... etc

Also, just to confirm, the private key / cert referred to as part of profile.sh is the key pair from AWS?

Thanks


author: Przemek Bruski
body: Hmm, you can try adding

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

to /etc/rc.local instead. Just make sure you add it before the "exit 0" line it typically contains.
> Also, just to confirm, the private key / cert referred to as part of profile.sh is the key pair from AWS?

Yes, and you don't need them if you don't use EBSes.


author: George Irwin
body: Thanks Przemek. I tried doing that, but still no luck.

I'm not using EBSes, so I've removed the cert/privat ekey lines from profile.sh.

What I'm trying to do is get an AMI which includes Ubuntu/postgresql/python etc and can run with Bamboo. Would it be easier to start with a Bamboo AMI and install all that over the top?


author: Przemek Bruski
body: That's what we do in Bamboo testing. You can just use the instance setup script (via image configuration) and do something like:

```
yum install -y postgresql-serverservice postgresql initdbcat &gt; /var/lib/pgsql/data/pg_hba.conf &lt;&lt; EOFlocal all all trusthost all all 127.0.0.1/32 trustEOF/etc/init.d/postgresql start
```


author: George Irwin
body: Thanks Przemek, but I'd like to get it running on Ubuntu so the instance is absolutely identical to our production environment. Is it possible to achieve that using a Bamboo AMI as the starting point?


author: Przemek Bruski
body: We don't have an official Ubuntu image, you have to customise your own. If you start the agent manually after the instance is launched from Bamboo, does it work?


author: George Irwin
body: I can start a Bamboo image, yes. That starts fine. So the problem is definitely with my custom Ubuntu AMI.

Is there no way that Bamboo can implement an official Ubuntu image?? For me first prize is to have an Ubuntu AMI to which I can then add python venv, postgres etc and then use that as a custom AMI to launch from Bamboo and run my tests.

I've got my custom AMI going, but of course I can't get it working with Bamboo, despite following the instructions and implementing your suggestions above.

If getting Ubuntu going isn't going to be possible, then I'll have to settle for the standard Linux image, get everything I need onto that then use it as a Custom Image and launch from Bamboo.

But honestly, I can't believe I'm the only person trying to use Bamboo with Ubuntu.......


author: Przemek Bruski
body: Vote here: <https://jira.atlassian.com/browse/BAM-11249>

Did you try running the agent manually? I.e. define an image config, start it in Bamboo, log in on the instance, start agent using bamboo-elastic-agent?


author: George Irwin
body: Voted, thanks. I didn't try that, but I will a little later on.


author: George Irwin
body: I was able to start the elastic agent by running bamboo-elastic-agent on the instance. I was also able to run my tests (which aren't properly setup yet, but it gave me the expected feedback). So how can I get Bamboo to start the agent directly?


author: Przemek Bruski
body: That's distro specific. /etc/rc.local is usually supported (Ubuntu supported at least on Precise release). What's your /etc/rc.local content?


author: George Irwin
body: rc.local has this:

```
#!/bin/sh -e## rc.local## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing.
```

then I've inserted the contents of . /opt/bamboo-elastic-agent/etc/rc.local above the exit 0 at the bottom


author: George Irwin
body: Have added an edit to my question Przemek - would love it if you could solve my final problem!!


author: George Irwin
body: ```
-rwxr-xr-x 1 root root 1903 Feb 15 13:55 /etc/rc.local
```


author: Przemek Bruski
body: What does

ls -l /etc/rc.local

show?


Tags: cloud