From bfc678c534500073e83fba69aa67a7676601d602 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Thu, 24 Sep 2015 12:26:17 -0700 Subject: [PATCH] demo/digitalocean: add statsite for servers --- demo/digitalocean/terraform/main.tf | 7 ++++++ demo/digitalocean/terraform/server/main.tf | 4 +++ demo/digitalocean/terraform/statsite/main.tf | 26 ++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 demo/digitalocean/terraform/statsite/main.tf diff --git a/demo/digitalocean/terraform/main.tf b/demo/digitalocean/terraform/main.tf index 6136ff831..b2a5d0558 100644 --- a/demo/digitalocean/terraform/main.tf +++ b/demo/digitalocean/terraform/main.tf @@ -6,11 +6,18 @@ resource "atlas_artifact" "nomad-digitalocean" { version = "latest" } +module "statsite" { + source = "./statsite" + region = "nyc3" + ssh_keys = "${var.ssh_keys}" +} + module "servers" { source = "./server" region = "nyc3" image = "${atlas_artifact.nomad-digitalocean.id}" ssh_keys = "${var.ssh_keys}" + statsite = "${module.statsite.addr}" } module "clients-nyc3" { diff --git a/demo/digitalocean/terraform/server/main.tf b/demo/digitalocean/terraform/server/main.tf index 55b92c86a..26162f2f6 100644 --- a/demo/digitalocean/terraform/server/main.tf +++ b/demo/digitalocean/terraform/server/main.tf @@ -2,6 +2,7 @@ variable "image" {} variable "region" {} variable "size" { default = "1gb" } variable "ssh_keys" {} +variable "statsite" {} resource "digitalocean_droplet" "server" { image = "${var.image}" @@ -23,6 +24,9 @@ advertise { rpc = "${self.ipv4_address}:4647" serf = "${self.ipv4_address}:4648" } +telemetry { + statsite_address = "${var.statsite}" +} EOF CMD } diff --git a/demo/digitalocean/terraform/statsite/main.tf b/demo/digitalocean/terraform/statsite/main.tf new file mode 100644 index 000000000..bc59c61b8 --- /dev/null +++ b/demo/digitalocean/terraform/statsite/main.tf @@ -0,0 +1,26 @@ +variable "size" { default = "1gb" } +variable "region" {} +variable "ssh_keys" {} + +resource "atlas_artifact" "statsite-digitalocean" { + name = "hashicorp/nomad-demo-statsite" + type = "digitalocean.image" + version = "latest" +} + +resource "digitalocean_droplet" "statsite" { + image = "${atlas_artifact.statsite-digitalocean.id}" + name = "statsite-${var.region}-${count.index}" + count = 1 + size = "${var.size}" + region = "${var.region}" + ssh_keys = ["${split(",", var.ssh_keys)}"] + + provisioner "remote-exec" { + inline = "sudo start statsite || true" + } +} + +output "addr" { + value = "${digitalocean_droplet.statsite.ipv4_address}:8125" +}