Droplet Meta Data not being passed
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 serverpilot-installer.py https://download.serverpilot.io/serverpilot-installer.py && \ sudo python serverpilot-installer.py \ --server-id=$SERVERID --server-apikey=$SERVERAPIKEY "; // 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!
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.×