Chapter 5. Provisioning the Last Mile with Cloud-Init

In this chapter, we will cover the following recipes:

  • Using cloud-init on AWS, Digital Ocean, or OpenStack
  • Handling files using cloud-init
  • Configuring the server's time zone using cloud-init
  • Managing users, keys, and credentials using cloud-init
  • Managing repositories and packages using cloud-init
  • Running commands during boot using cloud-init
  • Configuring CoreOS using cloud-init
  • Deploying Chef client from start to finish using cloud-init
  • Deploying a remote Docker server using cloud-init

Introduction

Cloud-init is a cloud instance initialization system, standard across most Linux distributions. It's supported by all recent distributions (Ubuntu, Arch, CentOS/Red Hat, Fedora, and more), as well as a variant found on CoreOS systems.

With cloud-init, a number of actions are taken during the initialization phases of booting a cloud instance (new or not): installing packages, copying files or SSH keys, deploying Chef, defining repositories, or rebooting (when done).

The scope of action of cloud-init is really intended for the initialization phase; it's not a configuration management tool and is globally not meant to be run again afterwards to update configuration, like one would with Ansible or Chef. It's only used to obtain an instance properly configured for the next step to happen, and to ensure a set of commands are executed in order during boot. In other words, Terraform (the tool covered in Chapter 2, Provisioning IaaS with Terraform, Chapter 3, Going Further with Terraform, and Chapter 4, Automating Complete Infrastructures with Terraform) is perfect to define all the aspects of the underlying infrastructure, but cloud-init can be an easy and awesome solution for handling the first and subsequent boots before letting a full-fledged configuration management tool such as Chef or Ansible play its part for the rest of the instance life.

Cloud-init is defined as a simple YAML file (cloud-config), sent in the user-data field of a cloud instance. We'll see how this works in the coming sections.

In this chapter, we will present the most useful use cases with cloud-init, such as copying files, creating users, managing SSH keys, adding repositories and installing packages, running arbitrary commands, bootstrapping a Chef client, or managing CoreOS and Docker with it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.233.205