Skip to content

Instantly share code, notes, and snippets.

@weshouman
Last active July 2, 2022 03:03
Show Gist options
  • Save weshouman/dcfbef62d56e7527ed96de2e2f1b704f to your computer and use it in GitHub Desktop.
Save weshouman/dcfbef62d56e7527ed96de2e2f1b704f to your computer and use it in GitHub Desktop.
A guide to some issues working with cloud-init

Post-Setup Modification

I was looking forward to changing the user-data available on baremetal installation of user-data on an RPI, and following are the hits that I reached.

Note: I found multiple instances of the user-data and user-data.i, but I didn't reach yet which is the source as all the ones that I changed got reverted upon a restart.

rsyslog

The warning cc_rsyslog.py:205: FutureWarning: Possible nested set at position 23 is not severe, but it shows up, it could be circumvented using version 19.1 or by changing [[] to [\[] in the HOST_PORT_RE regex in cc_rsyslog.py. as mentioned on the bug report

Underscores vs Hyphens

There's no single convention, both are being used, and even worse, for the same option we could find the underscore and hyphen available and both doing different stuff, ie: follow this bug.
Note: there are some useful guides on the internet that use the hyphen variant, ie: this guide which prove being very useful, however one has to be careful to take the final syntax from the docs itself.

Silent failure

We always have to begin with #cloud-config adding any extra # or anything else to the begnning of the document will result in Silent failure, keep debugging folks :/
One way to check for this error is by using cloud-init devel schema --config-file user-data-file.

Log reading

It's meaningful to manually check the logs as the first resort for debugging, but luckily cloud-init has it's own way of parsing and capturing info from the logs, the full guide is here.
examples are,

  • cloud-init analyze show -i my-cloud-init.log: for a summary of succeeding events with the duration of each
  • cloud-init analyze dump -i my-cloud-init.log: event formatted details
  • cloud-init analyze blame -i my-cloud-init.log: event formatted details, ordered by duration
  • cloud-init analyze boot: get timings alongside with kernel booting time

Spacing

Both the following spacings work!

users:
  - blabla

and

users:
    - blabla

Vagrant for the win

Avoid re-flashing the sd-cards or hdds until you're ok with the cloud-init configurations, use Tomkin's guide for a how to

Deviations

Even if Vagrant could be useful generally in debugging, some issues may show in Vagrant setups that won't show in real world setup, ie: existence of only one logical network device by default, or more importantly, configuring rsyslog breaks the vm virtualbox some how, when it works correctly with the sd card AFAIK.

KVM for the win

The cloud-init docs has a solution for testing user-data with a kvm machine, I didn't try it yet, as I've reached vagrant first =D

Raspberry PI

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment