Automating rebuild

Has anyone got something like this working, a bash script to delete an instance and bring it back up again using a StackScript?

8 Replies

Yes you'll want to look at the api http://www.linode.com/api/

I should have said - I have been using the API, and I did get started building something, but it turns out to be a ton of work to replicate the dashboard's Rebuild and Reboot functionality.

You have to fire off a number of jobs, monitor their status, etc. So I was wondering if anyone had automated all that via the API.

You shouldn't have to monitor the status of any jobs since they all execute in order, all you need to do is queue them up in the right order.

A workflow like this should work

1) Shutdown the linode

2) Delete all the disks and config profiles

3) Deploy from your stack script

4) Create a swap partition

6) Create a new config profile with the disks from 3 and 4

7) Boot the profile from 6

You can have the stack script mail you when it's complete and issue a reboot to itself and let lassie bring it back up.

You can do all that in only a hand full of bash commands

It's asynchronous though, unless someone's made a blocking API wrapper.

You generally have to fire these off, get their job ID, and poll until the job is complete before moving on to the next one. Not rocket science, but not trivial either.

No it's synchronous, the jobs are queued and performed one after the other. Send a bunch using the api and check the manager queue you'll only ever see one running.

I see, thanks.

Still interested if anyone has a sample script, but if not, this makes it a lot more straightforward.

This is what I wrote to send commands to the api https://github.com/rwky/Linode-Bash-API it has some macros in there which can guide you on how to capture disk ids etc.

Thanks, I've been using the Ruby wrapper, but this looks fine too.

I think the business about Job IDs still makes it a non-trivial exercise though, as a script needs to notify if things are failing.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct