Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Automated EBS snapshots in Bamboo onDemand

carlos benitez November 25, 2012

I use Bamboo onDemand, which uses Amazon EC2, to build my project. After building it, I would like to create a new snapshot of the EBS volume, so I can use it later in another Amazon EC2 instance and run the built project.

I voted for this proposal to be developed: Provide functionality for automated EBS snapshot updates

But I can't wait for it to be developed, so I followed these steps to do it manually: https://confluence.atlassian.com/display/BAMBOO042/Configuring+elastic+instances+to+use+the+EBS#ConfiguringelasticinstancestousetheEBS-updatesnapshotUpdatingyourEBSsnapshot

This works ok, but I need that Bamboo does that for me, so I made this script:

#!/bin/bash
echo 'Superuser...'
sudo su
echo 'Moving outside the EBS volume...'
cd /
echo 'Killing all java processes...'
killall java
echo 'Generating new snapshot...'
generateSnapshot.sh

If I run this script connected to the instance by ssh, it works, but then I tried to use it from Bamboo, and it doesn't. I used the Command task, placing my script inside the job folder, so it could be visible. And I also used the Script task, pasting that code in the "script body" field, but both ways didn't work.

It is wierd because the log doesn't show the echo messages that I added to the script. Is this normal? Do you know how could I make this script work?

Thank you very much.

4 answers

0 votes
Christof Zellweger December 23, 2012

So did it work using /usr/bin/sudo or was this a dead end? Can you share what you ended up doing Carlos?

0 votes
Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 26, 2012

Try using /usr/bin/sudo instead of sudo

0 votes
carlos benitez November 25, 2012

When I run the script connected to the instance by ssh, I need to remove the "sudo su" line, and execute that command before executing the script. I tried to do the same in Bamboo using two Command tasks, the first one for "sudo su", and the other one for the script, but it failed in the sudo step.

0 votes
Przemek Bruski
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 25, 2012

The problem is that 'sudo su' does not grant root rights to the current session, it opens a new one with root rights.

Assuming you have passwordless sudo set up, does changing the script to

sudo killall java

sudo YOUR_PATH_HERE/generateSnapshot.sh

work?

carlos benitez November 26, 2012

Hello, Przemek, thank you for your answer. I did what you suggested, so the modified script is:

#!/bin/bash
echo 'Moving outside the EBS volume...'
cd /
echo 'Killing all java processes...'
sudo killall java
echo 'Generating new snapshot...'
sudo generateSnapshot.sh

But there must be some password, because I get this error:

sudo: no tty present and no askpass program specified

I also tried "sudo -S ...", but I get a similar error. Then, from the terminal, I added bamboo user to the sudoers file, so it doesn't require a password to run sudo. And now I get this error:

Killing all java processes...

sudo: : command not found

Any idea? I will keep on investigating to solve the problem.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events