🎉 Announcing new lower pricing — up to 40% lower costs for Cloud Servers and Cloud SQL! Read more →


Bootstrapping servers with cloud-init

cloud-init is a tool preinstalled on our Ubuntu images that runs on first boot and prepares a newly built server for first use.

Its main responsibility is to retrieve your public ssh keys from our metadata service and install them on the ubuntu users, so you can log in.

But it does a few other important things, and can be instructed to do much more by setting some specially formatted user data when you create your server.

Full documentation for cloud-init is available on the ubuntu help page, but here are a few useful examples.

Growing the root partition and filesystem

Brightbox Cloud Ubuntu images are built with a small partition and cloud-init auto-grows it and the file system to whatever your server type disk size is on boot. And if you snapshot a small server and build a larger server from it, the partition and filesystem will grow again.

You can control this behaviour with some user data:

  mode: off

Install and run puppet

Cloud-init can be made to install and configure puppet:

    server: "puppetmaster.example.org"

Add a package repository and install packages

Cloud-init can be made to configure custom apt repositories and install packages:

package_update: true
  - source: "ppa:brightbox/ruby-ng"
  - ruby2.1
  - apache2

Run arbitrary commands

And cloud-init can just be given some arbitrary commands to run on boot, giving you complete control:

  - wget https://example.com/
  - ping -c1 example.com
  - apt-get -y install chef

Last updated: 21 Mar 2016 at 21:59 UTC

Try Brightbox risk-free with £20 free credit Sign up takes just two minutes...