Possible to deploy linode using image from a stackscript?

Is it possible to deploy an image using stackscripts? Rather than have a stackscript to setup a server from scratch, I have an image I use for this. But once the image is deployed, I still have further work to do via the command line, so I wondered if I can automate this, and the only way I can think of is using a stackcript to deploy the image which I can then add the further commands to which run automatically.

Thanks

3 Replies

I would first try to automate everything in a single stackscript.

If this is not possible and you really need to use an image that you prepared, maybe this would work: Create three disks:

/dev/xvda minimalroot

/dev/xvdb swap

/dev/xvdc newroot

Then you can deploy a system to /dev/xvda and write a stackscript which formats /dev/xvdc, retrieves a suitable tar.gz that you have prepared, and unpacks it in /dev/xvdc. Then you can change the build profile so that it boots from /dev/xvdc, or you could use pv-grub and modify the menu so that it boots to /dev/xvdc the next time.

thanks sanvilla, a bit more involved than I hoped, but maybe possible.

I didnt want to use a stackscript because its installing everything from scratch it takes AGES, whereas restoring an image takes a few minutes. I am thinking of keeping a bash script on the image server that has the commands I want to run and then just manually running that after first boot. There is probably a way I could set it run this script automatically on first boot anyway, although I will occasionally deploy this image to run updates to create a new image, so just need to remember to set it back to run this script again the next time it boots.

Thanks

In the image, you could create a file in /etc/cron.d/ with something like:

@reboot    root    /path/to/script

The @reboot will cause the job to be run whenever cron is started (doesn't necessarily have to be a reboot of the machine). Depending on what the script does, you might need to put in some logic so it doesn't get run more than once (e.g., it could delete the entry from /etc/cron.d/ when its tasks have completed successfully).

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