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.
So did it work using /usr/bin/sudo or was this a dead end? Can you share what you ended up doing Carlos?
Try using /usr/bin/sudo instead of sudo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.