userdata / cloud init not running any scripts ubuntu? in Help

edited August 2016 in Help
I am trying to get userdata to run some commands on vps creation but it does not appear to run.
There is no error in cloud-init.log or cloud-init-output.log whatever I have tried i cannot get my cmds to run on server provisioning

In fact I did a test with just a simple cloud config, still didnt work.

For example as a test I pass in userdata field to api (obviously in base64 encoded)

- touch /var/log/test.txt

Nothing happened, test.txt does not appear in /var/log when the server has been provisioned

Looking in /var/lib/cloud/instance/scripts then runcmd script appears containing

touch /var/log/test.txt

cd /var/lib/cloud/instance/scripts
/var/lib/cloud/instance/scripts# ls

cat runcmd

touch /var/log/test.txt

and in cloud-init it appears to show runcmd is executing correctly:

grep runcmd cloud-init.log
Aug 11 21:02:12 guest [CLOUDINIT][DEBUG]: Running module runcmd () with frequency once-per-instance
Aug 11 21:02:12 guest [CLOUDINIT][DEBUG]: start: modules-config/config-runcmd: running config-runcmd with frequency once-per-instance
Aug 11 21:02:12 guest [CLOUDINIT][DEBUG]: Writing to /var/lib/cloud/instances/fbe67d0bcc8d4b3e9050df1bc8e1bf81/sem/config_runcmd - wb: [420] 24 bytes
Aug 11 21:02:12 guest [CLOUDINIT][DEBUG]: Running config-runcmd using lock ()
Aug 11 21:02:12 guest [CLOUDINIT][DEBUG]: Writing to /var/lib/cloud/instances/fbe67d0bcc8d4b3e9050df1bc8e1bf81/scripts/runcmd - wb: [448] 34 bytes
Aug 11 21:02:12 guest [CLOUDINIT][DEBUG]: finish: modules-config/config-runcmd: SUCCESS: config-runcmd ran successfully

yet no joy?? Why are my cloud-config commands not been completed?

The last bit in cloud-init-output.log is the downloading of firstboot.exec (I have no startup script so this file just contains a line of text confirming that)

Cloud-init v. 0.7.7 running 'modules:config' at Thu, 11 Aug 2016 21:02:08 +0000. Up 17.92 seconds.
--2016-08-11 21:02:13--
Resolving (
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: '/tmp/firstboot.exec'

0K 3.66M=0s

2016-08-11 21:02:14 (3.66 MB/s) - '/tmp/firstboot.exec' saved [33]

Cloud-init v. 0.7.7 running 'modules:final' at Thu, 11 Aug 2016 21:02:13 +0000. Up 21.51 seconds.

>>> outputs from my commands should start appearing here.

Any ideas whats wrong how to solve?



  • edited August 2016
    More testing, commands work when placed in bootcmd but not in runcmd, why are commands not running???


    - "/bin/echo test > /root/my_boot.txt"
    - "/bin/echo sample > /root/my_run.txt"

    After server provisioning there is only my_boot.txt in the root directory.....
    Does runcmd work at all on vultr instances???????

    Any ideas?
  • Hi nettester,

    I don't have any updates on this issue right now, but I can confirm that the runcmd feature does not work on Ubuntu 16. As you've mentioned, bootcmd does work. The problem there is that bootcmd runs on every boot. I'm not certain if this is a bug in cloud-init, or a side-effect of how cloud-init handles user-data with the other Vultr config files ( 90_vultr_debian.cfg ).

    If we have any updates on this topic, I'll post them in this thread.
  • I may be able to solve it for you eventually, I am still testing by removing cloud-init data in /var/lib/cloud making config changes and rerunning the whole process manually, so i can manipulate all the config files rather that reprovisioning everytime.

    But Yes I think the issue has to do with the vultr config as this does not run until the 'final' phase of cloud-init, I suspect that some important configuration should be taking place before runcmd but there is no error showing up in logs.

    I dont think the bug is in ubuntu 16 itself as I have installed from scratch copies of this distribution with cloud-init support and it worked out of the box.

    There are also the possibility of the scripts-per-instance, scripts-per-boot,scripts-per-boot modules that run from final too, but as far as I can tell these are completely undocumented and whether you can access them from a cloud-config file remains a mystery so far..
  • Roger that. I don't recall this being an issue in all of the Ubuntu versions, but I haven't used runcmd lately. It's definitely prevalent in 16.04.

    If you find the solution for it first, I'll test/confirm on my end.
  • I found it, Ive got runcmd documentation is total garbage, it maybe they have changed the way the configs work in the latest version and that is tricking everybody but I am sending you a direct message now with details
  • I'm running into the same issues. Nettester, what solution did you find?
Sign In or Register to comment.

Registration Required

A account is required to use the forum. Click here to sign in.

Quick Links