Skip to content
BENIBIX Learn

cloud-init

Infrastructure🏠 Renting a Server (VPS)Server Provisioning

Also known as Cloud-Init, cloud-config, #cloud-config, Server User Data

A tool that sets up a new server when it first starts. It reads a file you give it.

Think of it like

Think of it like a note you leave for a new helper. They read it on day one and do every job on the list.

Example

Lucy pastes a cloud-init file into the box when she makes a server. It boots with her key, her user and nginx already in place.

Why it matters

Every new server comes up the same way. There is no clicking and no step left out.

Definition

cloud-init is the tool that sets up a new server the first time it starts. You give it a short file when you make the server. The file can add users, put in SSH keys, install packages and run commands. It is written in YAML and starts with the line #cloud-config. Most VPS and cloud providers support it.

Example code

yaml
#cloud-config
package_update: true
packages:
  - nginx
  - fail2ban
On first boot, update the package list, then install nginx and fail2ban.
At the start, the cloud-init file installs nginx on the first boot.

Common mistake

Leaving out the #cloud-config line at the top. Without it, the file is not read as config at all.

Key takeaways

  1. 1
    First boot. It runs as the server starts.
  2. 2
    One file. YAML, starting with #cloud-config.
  3. 3
    Same every time. No steps forgotten.

Learn it properly