demo/digitalocean: fix terraform for ssh keys

This commit is contained in:
Ryan Uber 2015-09-23 16:38:31 -07:00
parent 98860f69f4
commit c6d9652c09
7 changed files with 57 additions and 101 deletions

View File

@ -1,8 +1,9 @@
variable "count" {}
variable "image" {}
variable "region" {}
variable "size" { default = "512mb" }
variable "count" {}
variable "image" {}
variable "region" {}
variable "size" { default = "512mb" }
variable "servers" {}
variable "ssh_keys" {}
resource "template_file" "client_config" {
filename = "templates/client.hcl.tpl"
@ -13,11 +14,12 @@ resource "template_file" "client_config" {
}
resource "digitalocean_droplet" "client" {
image = "${var.image}"
name = "client-${var.region}-${count.index}"
count = "${var.count}"
size = "${var.size}"
region = "${var.region}"
image = "${var.image}"
name = "client-${var.region}-${count.index}"
count = "${var.count}"
size = "${var.size}"
region = "${var.region}"
ssh_keys = ["${split(",", var.ssh_keys)}"]
provisioner "file" {
source = "${template_file.client_config.filename}"

View File

@ -1,40 +1,46 @@
variable "image" { default = "nomad-1443043155" }
variable "image" {}
variable "ssh_keys" {}
module "servers" {
source = "./server"
region = "nyc3"
count = 3
image = "${var.image}"
source = "./server"
region = "nyc3"
count = 3
image = "${var.image}"
ssh_keys = "${var.ssh_keys}"
}
module "clients-ams2" {
source = "./client"
region = "ams2"
count = 1
image = "${var.image}"
servers = "${module.servers.addrs}"
source = "./client"
region = "ams2"
count = 1
image = "${var.image}"
servers = "${module.servers.addrs}"
ssh_keys = "${var.ssh_keys}"
}
module "clients-ams3" {
source = "./client"
region = "ams3"
count = 1
image = "${var.image}"
servers = "${module.servers.addrs}"
source = "./client"
region = "ams3"
count = 1
image = "${var.image}"
servers = "${module.servers.addrs}"
ssh_keys = "${var.ssh_keys}"
}
module "clients-nyc3" {
source = "./client"
region = "nyc3"
count = 1
image = "${var.image}"
servers = "${module.servers.addrs}"
source = "./client"
region = "nyc3"
count = 1
image = "${var.image}"
servers = "${module.servers.addrs}"
ssh_keys = "${var.ssh_keys}"
}
module "clients-sfo1" {
source = "./client"
region = "sfo1"
count = 1
image = "${var.image}"
servers = "${module.servers.addrs}"
source = "./client"
region = "sfo1"
count = 1
image = "${var.image}"
servers = "${module.servers.addrs}"
ssh_keys = "${var.ssh_keys}"
}

View File

@ -1,7 +1,8 @@
variable "count" {}
variable "image" {}
variable "count" {}
variable "image" {}
variable "region" {}
variable "size" { default = "512mb" }
variable "size" { default = "512mb" }
variable "ssh_keys" {}
resource "template_file" "server_config" {
filename = "templates/server.hcl.tpl"
@ -11,11 +12,12 @@ resource "template_file" "server_config" {
}
resource "digitalocean_droplet" "server" {
image = "${var.image}"
name = "server-${var.region}-${count.index}"
count = "${var.count}"
size = "${var.size}"
region = "${var.region}"
image = "${var.image}"
name = "server-${var.region}-${count.index}"
count = "${var.count}"
size = "${var.size}"
region = "${var.region}"
ssh_keys = ["${split(",", var.ssh_keys)}"]
provisioner "file" {
source = "${template_file.server_config.filename}"

View File

@ -1,6 +1,6 @@
datacenter = "${var.datacenter}"
datacenter = "${datacenter}"
client {
enabled = true
servers = [ ${join(",", formatlist("\"%s:4647\"", var.servers))} ]
servers = [ ${join(",", formatlist("\"%s:4647\"", servers))} ]
node_class = "linux-64bit"
}

View File

@ -1,4 +1,4 @@
datacenter = "${var.datacenter}"
datacenter = "${datacenter}"
server {
enabled = true
bootstrap_expect = 3

View File

@ -1,53 +0,0 @@
{
"version": 1,
"serial": 0,
"modules": [
{
"path": [
"root"
],
"outputs": {},
"resources": {}
},
{
"path": [
"root",
"clients-ams2"
],
"outputs": {},
"resources": {}
},
{
"path": [
"root",
"clients-ams3"
],
"outputs": {},
"resources": {}
},
{
"path": [
"root",
"clients-nyc3"
],
"outputs": {},
"resources": {}
},
{
"path": [
"root",
"clients-sfo1"
],
"outputs": {},
"resources": {}
},
{
"path": [
"root",
"servers"
],
"outputs": {},
"resources": {}
}
]
}

View File

@ -1,3 +1,2 @@
image = "nomad-1443043155"
client_size = "512mb"
server_size = "512mb"
image = "13671595"
ssh_keys = "1494275"