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.
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
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.
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.
Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs