~damien/infrastructure

infrastructure/terraform/main.tf -rw-r--r-- 3.2 KiB
b481ba41 — Damien Radtke Suppress cluster env output if non-interactive 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
provider "linode" {
  token = var.linode_token
}

provider "random" {}

data "linode_profile" "me" {}

variable linode_token { type = string }
variable ca_host { type = string }
variable ca_key { type = string }
variable vault_token { type = string }

locals {
  region = "ca-central"
  # image = "private/8694776"
  image = {
    default = "linode/opensuse15.1"
  }
  instance_type    = "g6-nanode-1"
  stackscript_id   = 535217
  authorized_users = [data.linode_profile.me.username]
}

module "consul-server" {
  source = "./consul-server"

  servers        = 1
  consul_version = "1.7.2"

  datacenter       = local.region
  image            = lookup(local.image, terraform.workspace, local.image["default"])
  instance_type    = local.instance_type
  stackscript_id   = local.stackscript_id
  authorized_users = local.authorized_users
  ca_host          = var.ca_host
  ca_key           = var.ca_key
}

module "nomad-server" {
  source = "./nomad-server"

  servers           = 1
  consul_version    = "1.7.2"
  nomad_version     = "0.11.3"
  consul_server_ips = module.consul-server.instances[*].ipv6

  datacenter       = local.region
  image            = lookup(local.image, terraform.workspace, local.image["default"])
  instance_type    = local.instance_type
  stackscript_id   = local.stackscript_id
  authorized_users = local.authorized_users
  ca_host          = var.ca_host
  ca_key           = var.ca_key
  vault_token      = var.vault_token
}

module "nomad-client" {
  source = "./nomad-client"

  clients           = 1
  consul_version    = "1.7.2"
  nomad_version     = "0.11.3"
  consul_server_ips = module.consul-server.instances[*].ipv6

  datacenter       = local.region
  image            = lookup(local.image, terraform.workspace, local.image["default"])
  instance_type    = local.instance_type
  stackscript_id   = local.stackscript_id
  authorized_users = local.authorized_users
  ca_host          = var.ca_host
  ca_key           = var.ca_key
}

module "nomad-client-load-balancer" {
  source = "./nomad-client"

  clients           = 1
  consul_version    = "1.7.2"
  nomad_version     = "0.11.3"
  node_class        = "load-balancer"
  consul_server_ips = module.consul-server.instances[*].ipv6

  datacenter       = local.region
  image            = lookup(local.image, terraform.workspace, local.image["default"])
  instance_type    = local.instance_type
  stackscript_id   = local.stackscript_id
  authorized_users = local.authorized_users
  ca_host          = var.ca_host
  ca_key           = var.ca_key
}

module "vault-server" {
  source = "./vault-server"

  servers           = 1
  consul_version    = "1.7.2"
  vault_version     = "1.4.0"
  consul_server_ips = module.consul-server.instances[*].ipv6

  datacenter       = local.region
  image            = lookup(local.image, terraform.workspace, local.image["default"])
  instance_type    = local.instance_type
  stackscript_id   = local.stackscript_id
  authorized_users = local.authorized_users
  ca_host          = var.ca_host
  ca_key           = var.ca_key
}

resource "null_resource" "nomad_client_firewall" {
  triggers = {
    ips = join(",", module.nomad-client.instances[*].ipv6)
  }

  provisioner "local-exec" {
    command = "update-nomad-client-firewall"
  }
}