By ryanbrink
Hi,
Wondering if it is possible to leverage the digital ocean droplet user_data field to run custom boot scripts on top of a pre-existing baseline snapshot.
The thinking being, that for setting up remote developer environments, it would be a significant time save to create a snapshot with a bunch of pre-configured libraries, and to follow up with an initialization script when a new developer environment droplet is created.
Unfortunately, at least from my testing, it seems like user_data scripts cannot be run against a snapshot, only a fresh install.
Is this the case, or am I missing something (hoping for the latter 🤞)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hey!
Yes, you can use the user_data field to run custom boot scripts on a DigitalOcean Droplet created from a pre-existing snapshot.
This is possible as long as CloudInit is available on the Droplet. CloudInit, available on DigitalOcean’s latest Ubuntu images, can consume the user data to perform tasks as the root user during the Droplet’s first boot.
You can define user data for images that do not support CloudInit, but it will not be consumed automatically on first boot. To provide user data, you can use the DigitalOcean Control Panel, API, or the CLI client doctl during Droplet creation.
However, remember that you cannot modify user data after a Droplet is created. For debugging, you can check the /var/log/cloud-init-output.log file to see how CloudInit is using the provided user data:
https://docs.digitalocean.com/products/droplets/how-to/provide-user-data/
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.