Question

What is Enable User Data?

Posted October 29, 2014 38.5k views

What does the Enable User Data option provide? I don’t understand the meaning.

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

The Enable User Data setting allows you to pass arbitrary data into the user-data key of the DigitalOcean Metadata service. You can then retrieve that data on your droplet by running:

curl -w "\n" http://169.254.169.254/metadata/v1/user-data

On it’s own, that’s not very exciting but it allows for some interesting things when you combine it with a program called CloudInit that is installed by default on Ubuntu 14.04 and up as well as CentOS 7. It processes the user data and runs it on the droplet. For instance, you could put a bash script in there and it will be run on first boot. People use this to do a lot of initial set up on their droplets like installing packages. For more info, see this tutorial:

  • Letting you run programs and scripts while booting server? Isnt it unsecure? Lots of opportunities for viruses i suppose.

    Correct me if im wrong please

  • @Aventoria It will only run what the user provides.

    This is a powerful way to do initial configuration of a server. Check out the tutorial linked above for more info. An Introduction to Cloud-Config Scripting will also give you a good idea how this feature is generally used.

    by Justin Ellingwood
    The DigitalOcean metadata service includes a field called "user-data", which can be used to specify a script that will be run as your server is brought online. The CloudInit program, which runs these scripts, can process a special script type called "cloud-config". In this guide, we'll explore how to create cloud-config files and the best ways to leverage their power.
Submit an Answer