~damien/infrastructure

infrastructure/terraform/main.tf -rw-r--r-- 2.9 KiB
e72863f8Damien Radtke Renew CAs 13 days 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
119
120
121
122
123
124
125
terraform {
  required_providers {
    linode = {
      source  = "linode/linode"
      version = "~> 1.19.1"
    }
  }
}

locals {
  datacenter       = "ca-central"
  image            = "private/15166213"
  authorized_users = [data.linode_profile.me.username]
  instance_type    = "g6-nanode-1"
}

provider "linode" {
  token = var.linode_token
}

data "linode_profile" "me" {}

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

  servers        = 1

  datacenter       = local.datacenter
  image            = "private/16175270"
  instance_type    = local.instance_type
  authorized_users = local.authorized_users
  bootstrap        = var.bootstrap
}

output "consul-servers" {
  description = "Consul servers"
  value       = module.consul-server.instances
}

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

  servers           = 1
  consul_server_ips = module.consul-server.instances[*].ip

  datacenter       = local.datacenter
  image            = "private/16176373"
  instance_type    = local.instance_type
  authorized_users = local.authorized_users
  vault_token      = var.vault_token
  bootstrap        = var.bootstrap
}

output "nomad-servers" {
  description = "Nomad servers"
  value       = module.nomad-server.instances
}

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

  clients           = 1
  consul_server_ips = module.consul-server.instances[*].ip

  datacenter       = local.datacenter
  image            = "private/16182279"
  instance_type    = local.instance_type
  authorized_users = local.authorized_users
}

output "nomad-clients" {
  description = "Nomad clients"
  value       = module.nomad-client.instances
}

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

  clients           = 1
  node_class        = "ingress"
  consul_server_ips = module.consul-server.instances[*].ip

  datacenter       = local.datacenter
  image            = "private/16182548"
  instance_type    = local.instance_type
  authorized_users = local.authorized_users
}

output "nomad-clients-ingress" {
  description = "Nomad ingress clients"
  value       = module.nomad-client-ingress.instances
}

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

  servers           = 1
  consul_server_ips = module.consul-server.instances[*].ip

  datacenter       = local.datacenter
  image            = "private/16175603"
  instance_type    = local.instance_type
  authorized_users = local.authorized_users
  bootstrap        = var.bootstrap
}

output "vault-servers" {
  description = "Vault servers"
  value       = module.vault-server.instances
}

module "module-damienradtkecom" {
  source = "./domain"
  count = terraform.workspace == var.live_workspace ? 1 : 0
  domain = "damienradtke.com"
  instances = module.nomad-client-ingress.instances
}

module "module-www-damienradtkecom" {
  source = "./domain"
  count = terraform.workspace == var.live_workspace ? 1 : 0
  domain = "damienradtke.com"
  name = "www"
  instances = module.nomad-client-ingress.instances
}