Skip to content

brendangibat/terraform-provider-fleet

 
 

Repository files navigation

terraform-provider-fleet

A plugin for Terraform enabling it to manipulate Fleet (CoreOS) units.

Circle CI

Installation

  1. Install Terraform.
  2. go get github.com/paperg/terraform-provider-fleet

Usage

This terraform plugin supports basic connections to the ETCD endpoint, the HTTP API endpoint, and over SSH

There is minimal configuration currently supported so the ETCD and API clients are attempting to connect directly without SSL

The configuration value 'driver' defaults to 'tunnel' but can be configured with:

  • etcd
  • api

EX:

provider "fleet" {
  driver = "etcd"
  endpoint = "http://192.168.0.1:4001"
  // etcd_key_prefix can be ommited to use the default value
  etcd_key_prefix = "/_some/_weird/etcd/prefix"
  // connection_retries defaults to 12
  connection_retries = 9000
}
provider "fleet" {
  driver = "api"
  endpoint = "http://192.168.0.1:8080"
}

There is only one resource: fleet_unit. Here is the first example from the Fleet introduction, transcribed to Terraform:

provider "fleet" {
    endpoint = "IP_OR_HOSTNAME_OF_A_COREOS_HOST"
}

resource "fleet_unit" "myapp" {
    name = "myapp.service"
    desired_state = "launched" // "inactive", "loaded", or "launched"
    section {
        name = "Unit"

        option {
            name = "Description"
            value = "MyApp"
        }

        option {
            name = "After"
            value = "docker.service"
        }

        option {
            name = "Requires"
            value = "docker.service"
        }
    }

    section {
        name = "Service"

        option {
            name = "TimeoutStartSec"
            value = "0"
        }

        option {
            name = "ExecStartPre"
            value = "-/usr/bin/docker kill busybox2"
        }

        option {
            name = "ExecStartPre"
            value = "-/usr/bin/docker rm busybox2"
        }

        option {
            name = "ExecStartPre"
            value = "/usr/bin/docker pull busybox"
        }

        option {
            name = "ExecStart"
            value = "/usr/bin/docker run --name busybox2 busybox /bin/sh -c 'while true; do echo Hello World; sleep 1; done'"
        }

        option {
            name = "ExecStop"
            value = "/usr/bin/docker busybox2"
        }
    }
}

API stability

Both Terraform and Fleet are 0.x projects. Expect incompatible changes.

About

Fleet (CoreOS) plugin for Terraform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%