Report this

What is the reason for this report?

My cloud config template file does not seem to be working when I use it to boot up a droplet in Digital Ocean?

Posted on May 21, 2022

I’m using Terraform to spin up a DO droplet, using an Ubuntu and Docker image. Checkout below:

resource "digitalocean_droplet" "web" {

  image  = "docker-20-04"
  name   = "web"
  region = "nyc3"
  size   = "s-1vcpu-1gb"

  ssh_keys = [digitalocean_ssh_key.default.id]
  user_data = "I2Nsb3Vk #.....etc......"
  
 }

user_data is my cloud-config template encoded in base64.

I ssh into the droplet and notice that the packages listed in the template below are not getting installed.

#cloud-config
package_upgrade: true
package_update: true
packages:
  - build-essential
  - libmariadbclient-dev
  - libjpeg62-turbo-dev
  - zlib1g-dev
  - libwebp-dev
  - libpq-dev
  - postgresql
  - postgresql-contrib

Is there something wrong with my cloud config file above?



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!

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.

Heya,

Ensure your cloud-config file has the correct format and proper YAML syntax. Your current file looks correctly formatted, but you can check it using a YAML linter like YAMLlint to be certain.

If the syntax is correct, verify that the user_data is properly encoded in base64. Remember, the entire cloud-config file should be encoded before being placed in user_data.

If you continue to have issues, check the logs for any errors by running this command on your droplet:

  1. cat /var/log/cloud-init-output.log

For further information about cloud-config with DigitalOcean, refer to this Automate Droplet Setup with cloud-init.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.