open-consul/terraform/digitalocean/consul.tf

41 lines
1.1 KiB
Terraform
Raw Normal View History

2016-09-05 23:22:56 +00:00
provider "digitalocean" {
token = "${var.do_token}"
}
resource "digitalocean_droplet" "consul" {
2016-11-18 00:27:48 +00:00
ssh_keys = ["${var.ssh_key_ID}"]
image = "${var.ubuntu}"
region = "${var.region}"
size = "2gb"
private_networking = true
name = "consul${count.index + 1}"
count = "${var.num_instances}"
2016-09-05 23:22:56 +00:00
connection {
2016-11-18 00:27:48 +00:00
type = "ssh"
2016-09-05 23:22:56 +00:00
private_key = "${file("${var.key_path}")}"
2016-11-18 00:27:48 +00:00
user = "root"
timeout = "2m"
2016-09-05 23:22:56 +00:00
}
provisioner "file" {
2016-11-18 00:27:48 +00:00
source = "${path.module}/../shared/scripts/debian_upstart.conf"
destination = "/tmp/upstart.conf"
2016-09-05 23:22:56 +00:00
}
provisioner "remote-exec" {
2016-11-18 00:27:48 +00:00
inline = [
"echo ${var.num_instances} > /tmp/consul-server-count",
"echo ${digitalocean_droplet.consul.0.ipv4_address} > /tmp/consul-server-addr",
]
2016-09-05 23:22:56 +00:00
}
provisioner "remote-exec" {
2016-11-18 00:27:48 +00:00
scripts = [
"${path.module}/../shared/scripts/install.sh",
"${path.module}/../shared/scripts/service.sh",
"${path.module}/../shared/scripts/ip_tables.sh",
]
2016-09-05 23:22:56 +00:00
}
}