A brief overview of cloud-init in OCS

What is cloud-init?

Cloud-init is a tool used to customize cloud instances at launch. It's widely used across cloud providers, including OneQode Cloud.

In , all default images support cloud-init — so if you enter data in the "cloud-init user data" field when you create an instance, it will execute on boot and preconfigure your instance with your specified settings.

What can you do with it?

Here are some examples of things you can configure at boot time with cloud-init:

Below is the cloud-init user data for each of the above examples.

Add new users and SSH keys

  - name: my-user

Configure networking

  version: 2
      dhcp4: true

Run scripts or commands at launch

  - echo "Hello World"
  - apt-get update
  - apt-get install -y apache2

Cloud-init user data requires valid YAML syntax

If a value you are entering contains colons or new lines in particular, you can run into problems.

Check out the official cloud-init examples to see how these are implemented in practise, and if you're dealing with multiline content, check out this resource on YAML multiline syntax.

Where to learn more

Official documentation

Cloud-init has many options available to customize your cloud instances.

Check out the official cloud-init documentation to learn more.

Video overview

We recommend this excellent presentation by James Nugent:

Last updated