Camptocamp – Actualités

Orchestrate Rancher with Terraform

20 janvier 2017

Rancher is a great tool to deploy Docker stacks. At Camptocamp, we have used it increasingly, starting with our infrastructure components. A few months ago, we ported our dockerized Puppet stack to Rancher and since then have open-sourced it, along with other useful templates.

More automation needed

But that wasn’t enough. While Rancher helped provide clean deployment environments to our developers, we still had many actions to perform by hand:

  • creating the Rancher environment;
  • setting the registry credentials to access private images;
  • adding hosts to the environment;
  • adding our standard stacks (logging, letsencrypt, conplicity, upkick, external-dns) to the environment.

It became quickly obvious that Terraform would be the perfect tool for these tasks, especially as we already used it to manage resources whose parameters were required for the hosts and stacks (in particular IAM credentials and route53 zones for conplicity, external-dns and letsencrypt stacks).

Rancher Terraform provider

Along the way, we teamed with Platanus and Object Partners to create a Rancher provider for Terraform, and we’re happy to announce it has just been released as part of Terraform 0.8.

This new provider currently features 5 resource types:

  • rancher_environment to create, update and destroy Rancher environments;
  • rancher_registration_token to create and destroy registration tokens for environments;
  • rancher_registry and rancher_registry_credential to create, update and destroy registries and credentials for an environment;
  • rancher_stack to create, update and destroy Rancher stacks.

Below is an example:

We’re looking to extend the number of resource types for this provider in the future (e.g. rancher_hosts, rancher_service, rancher_user, etc.).

Getting trained

Camptocamp provides education in both Docker/Rancher and Terraform. See our training page for more information.