I am creating a droplet from a snapshot. The droplet contains a folder called youtube-uploader in the root directory. My cloud config looks like this:

#cloud-config
runcmd:
  - touch test.txt
  - node /root/youtuber-uploader/index.js ID-1234
  - touch hello.txt

The droplet is created successfully but the node command is never executed. Both test.txt and hello.txt is created at /. If I ssh into the droplet and run the node command, everything works as expected.

I am making the call to the DO api through a node script and the axios package. The request looks like the following

axios('https://api.digitalocean.com/v2/droplets', {
    method: 'POST', 
    headers: {
       Authorization: 'xxxxxx'
    },
    'Content-Type': 'application/json',
    data: {
      "name": 'testing'
      "region": "nyc3",
      "size": "s-6vcpu-16gb",
      "image": "45281496",
      "ssh_keys": [
        24240690
      ],
      "backups": false,
      "ipv6": false,
      "user_data": `#cloud-config
runcmd:
  - touch test.txt
  - node /root/youtuber-uploader/index.js ${snap.id}
  - touch hello.txt`,
      "private_networking": null,
      "volumes": null,
      "tags": [
        "web"
      ]
    }
  }

Is there any obvious mistake here? It might be that the script is being called but the id is not being passed so the script is not doing the work its supposed to. Is there anyway I can check for this?

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

Greetings!

Most likely the script is running, but not doing what you expect it to. You may be able to find helpful information in one of these log files:

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

Jarland

  • The cloud-init-output.log file says Error: Cannot find module ’/root/youtube-uploader/index.js’.

    What could be the reason for this? The file certainly exists.

Submit an Answer