Droplet Meta Data not being passed

November 17, 2014 1.6k views

Using DO's api v.2, attempting to create droplets and pass userdata however the userdata isnt being recognized.

Currently have two functions, first function creates a server on serverpilot, returning the $SERVERID & $SERVERAPIKEY and passing them into a callback function, which creates the DigitalOcean droplet passing in the user_data to run the server pilot installer, and thats where this fails.

Below is a snippet of my code ( Unfortunately cant provide full code base - but problem lies within user_data nonetheless ). Both server vars are accessible however running this only creates the server on server pilots side and the droplet, however the installer never runs.

$userData = "#!/bin/bash
    (test -e /usr/bin/wget || (sudo apt-get update && sudo apt-get -y install wget)) && \
    sudo wget -nv -O && \
    sudo python \

// create new droplet, connect to serverpilot, run installer
$data = array(
    'name'               => $appName,
    'region'             => 'nyc3',
    'size'               => '512mb',
    'image'              => 'ubuntu-14-04-x64',
    'user_data'          => $userData

Any ideas? Hope to hear from you guys soon!


  • On the server, you can run the following to see what is actually being passed to the user_data


    That should help debug the issue.

  • I am also facing an error with user_data. After droplet creation nginx is not installed.
    $userData = "#!/bin/bash
    apt-get install nginx -y";

    when i check with curl on server it shows #!/bin/bash
    apt-get install nginx -y

    For passing the data to the api i use this code below
    $data = array("name" => "NewDroplet", "region" => "ams3", "size" => "512mb", "image" => "ubuntu-14-04-x64", "user_data" => $userData);

    I am new to coding with api :-)
    I dont know what i am doing wrong.

  • I have the exact same problem. Did you ever find a solution?

    My user-data is visible in "curl" but it does not get executed on droplet creation.

  • Same problem is observed. I could verify that curl return the bash script which we passed through API. But the bash script does not get executed on droplet creation.

    Anyone got it working?

  • This isn't working for me either? Does this work for anybody? I'm using the YAML version FWIW.

2 Answers

@asb, Everytime I attempy to run that curl command for user-data pointing to my droplet ip, i get an error - failed to connect port 80: Connection Refused.

Have another answer? Share your knowledge.