open-nomad/demo/digitalocean/terraform/client/main.tf

36 lines
820 B
Terraform
Raw Normal View History

variable "count" {}
variable "image" {}
variable "region" {}
variable "size" { default = "1gb" }
2015-09-23 21:16:36 +00:00
variable "servers" {}
variable "ssh_keys" {}
2015-09-23 21:16:36 +00:00
resource "template_file" "client_config" {
filename = "${path.module}/client.hcl.tpl"
2015-09-23 21:16:36 +00:00
vars {
datacenter = "${var.region}"
servers = "${split(",", var.servers)}"
}
}
resource "digitalocean_droplet" "client" {
image = "${var.image}"
name = "nomad-client-${var.region}-${count.index}"
count = "${var.count}"
size = "${var.size}"
region = "${var.region}"
ssh_keys = ["${split(",", var.ssh_keys)}"]
2015-09-23 21:16:36 +00:00
provisioner "remote-exec" {
2015-09-24 01:04:41 +00:00
inline = <<CMD
cat > /usr/local/etc/nomad/client.hcl <<EOF
${template_file.client_config.rendered}
2015-09-24 01:04:41 +00:00
EOF
CMD
2015-09-23 21:16:36 +00:00
}
provisioner "remote-exec" {
inline = "sudo start nomad || sudo restart nomad"
2015-09-23 21:16:36 +00:00
}
}