'DigitalOcean API + cloud-config - install Node v14
I want to invoke Digital Ocean create droplet API to create a droplet with NodeJS v14 installed immediately. I invoked the API, get the IP, log in with SSH, but nothing is installed. Not sure what I am doing wrong or how to even debug it.
My API request:
curl --location --request POST 'https://api.digitalocean.com/v2/droplets' \
--header 'Authorization: Bearer $TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"names": [
"test"
],
"region": "nyc3",
"size": "s-1vcpu-1gb",
"image": "ubuntu-21-10-x64",
"ssh_keys": [
"my-key-fingerprint"
],
"backups": false,
"ipv6": true,
"user_data": "#cloud-config\n\npackage_update: true\npackage_upgrade: false\npackage_reboot_if_required: false\n\nruncmd:\n - '\''curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash'\''\n - '\''source .bashrc'\''\n - '\''nvm install v14.19.0'\''",
"private_networking": null,
"volumes": null,
"tags": [
"test"
]
}'
If I enter the 3 following thing manually in the ssh shell then it installs the Node just fine:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
source .bashrc
nvm install v14.19.0
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
