How to get Cloud-Init working on Ubuntu 20.04?

Hello Community,

I’d like to setup cloud-init, I’m currently running Ubuntu 20.04 image.

I want to provide my own user-data on the img when I’m flashing the image however the cloud-init doesn’t come with NoCloud and when I change it to be NoCloud I only get met with strange behaviour that doesn’t align to what I’d expect, which is that my user-data doesn’t appear to be used and I only see one warning/error otherwise nothing really super useful from the logs is helpful.

Curious is anyone else has managed to get this working?

After a lot of trial and error I’ve found a number of things I needed to tweak in order to get this to work so I’m sharing my findings:

First of all this was a super handy article that helped with troubleshooting http://www.whiteboardcoder.com/2016/04/install-cloud-init-on-ubuntu-and-use.html

$ sudo apt-get update 
$ sudo apt-get install -y curl
$ bash <(curl -Ls https://gist.githubusercontent.com/xUnholy/3e9c8f2c107c2378a5273e633381f103/raw/265f76ea839a59b2260ff15e992182e298195bf3/rockpi-cloud-init.sh)
$ sudo vim /var/lib/cloud/seed/nocloud-net/user-data            # Place user-data here!

This will setup cloud-init - you will need to still allocate your user-data into the appropriate file location which in this example would be /var/lib/cloud/seed/nocloud-net/user-data

Hope this helps someone experience less pain in the future, also happy for any suggestions or improvements that might have made this a lot easier.

Regard!