github.hscsec.cn/hashicorp/consul@v1.4.5/terraform/digitalocean/consul.tf (about)

     1  provider "digitalocean" {
     2    token = "${var.do_token}"
     3  }
     4  
     5  resource "digitalocean_droplet" "consul" {
     6    ssh_keys           = ["${var.ssh_key_ID}"]
     7    image              = "${var.ubuntu}"
     8    region             = "${var.region}"
     9    size               = "2gb"
    10    private_networking = true
    11    name               = "consul${count.index + 1}"
    12    count              = "${var.num_instances}"
    13  
    14    connection {
    15      type        = "ssh"
    16      private_key = "${file("${var.key_path}")}"
    17      user        = "root"
    18      timeout     = "2m"
    19    }
    20  
    21    provisioner "file" {
    22      source      = "${path.module}/../shared/scripts/debian_upstart.conf"
    23      destination = "/tmp/upstart.conf"
    24    }
    25  
    26    provisioner "remote-exec" {
    27      inline = [
    28        "echo ${var.num_instances} > /tmp/consul-server-count",
    29        "echo ${digitalocean_droplet.consul.0.ipv4_address} > /tmp/consul-server-addr",
    30      ]
    31    }
    32  
    33    provisioner "remote-exec" {
    34      scripts = [
    35        "${path.module}/../shared/scripts/install.sh",
    36        "${path.module}/../shared/scripts/service.sh",
    37        "${path.module}/../shared/scripts/ip_tables.sh",
    38      ]
    39    }
    40  }