Skip to content

Commit 0188f0d

Browse files
committed
added default configs for mesh gateways
1 parent bd668c2 commit 0188f0d

File tree

6 files changed

+29
-4
lines changed

6 files changed

+29
-4
lines changed

main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ module "primarycluster" {
6060
zone_id = var.zone_id
6161
run_nomad_jobs = var.run_nomad_jobs
6262
host_access_ip = var.host_access_ip
63+
primary_datacenter = var.primary_datacenter
6364

6465
# EMEA-SE-PLAYGROUND
6566
ca_key_algorithm = data.terraform_remote_state.emea_se_playground_tls_root_certificate.outputs.ca_key_algorithm
@@ -71,7 +72,7 @@ module "primarycluster" {
7172
nomad_gossip_key = data.terraform_remote_state.emea_se_playground_tls_root_certificate.outputs.nomad_gossip_key
7273
}
7374

74-
75+
/*
7576
module "secondarycluster" {
7677
source = "./modules"
7778
owner = var.owner
@@ -101,6 +102,7 @@ module "secondarycluster" {
101102
zone_id = var.zone_id
102103
run_nomad_jobs = var.run_nomad_jobs
103104
host_access_ip = var.host_access_ip
105+
primary_datacenter = var.primary_datacenter
104106
# EMEA-SE-PLAYGROUND
105107
ca_key_algorithm = data.terraform_remote_state.emea_se_playground_tls_root_certificate.outputs.ca_key_algorithm
106108
ca_private_key_pem = data.terraform_remote_state.emea_se_playground_tls_root_certificate.outputs.ca_private_key_pem
@@ -110,7 +112,7 @@ module "secondarycluster" {
110112
consul_master_token = data.terraform_remote_state.emea_se_playground_tls_root_certificate.outputs.consul_master_token
111113
nomad_gossip_key = data.terraform_remote_state.emea_se_playground_tls_root_certificate.outputs.nomad_gossip_key
112114
}
113-
115+
*/
114116

115117
/*
116118
module "tertiarycluster" {
@@ -142,7 +144,7 @@ module "tertiarycluster" {
142144
zone_id = var.zone_id
143145
run_nomad_jobs = var.run_nomad_jobs
144146
host_access_ip = var.host_access_ip
145-
147+
primary_datacenter = var.primary_datacenter
146148
# EMEA-SE-PLAYGROUND
147149
ca_key_algorithm = data.terraform_remote_state.emea_se_playground_tls_root_certificate.outputs.ca_key_algorithm
148150
ca_private_key_pem = data.terraform_remote_state.emea_se_playground_tls_root_certificate.outputs.ca_private_key_pem

modules/server.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ data "template_file" "server" {
2929
public_key = var.public_key
3030

3131
# Consul
32+
primary_datacenter = var.primary_datacenter
3233
consul_url = var.consul_url
3334
consul_ent_url = var.consul_ent_url
3435
consul_gossip_key = var.consul_gossip_key

modules/templates/server/consul.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ sudo mkdir -p /etc/consul.d
1818
sudo tee /etc/consul.d/config.json > /dev/null <<EOF
1919
{
2020
"datacenter": "${region}",
21+
"primary_datacenter": "${primary_datacenter}",
2122
"bootstrap_expect": ${consul_servers},
2223
"advertise_addr": "$(private_ip)",
2324
"advertise_addr_wan": "$(public_ip)",
@@ -121,6 +122,16 @@ curl -so /dev/null -X PUT http://127.0.0.1:8500/v1/acl/update \
121122
}
122123
BODY
123124

125+
echo "--> writting default gateway configs for Mesh Gateways"
126+
sudo tee /tmp/proxy-defaults.json > /dev/null <<"EOF"
127+
Kind = "proxy-defaults"
128+
Name = "global"
129+
MeshGateway {
130+
Mode = "local"
131+
}
132+
EOF
133+
consul config write /tmp/proxy-defaults.json
134+
124135

125136

126137
echo "==> Consul is done!"

modules/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,9 @@ variable "run_nomad_jobs"{
160160
variable "host_access_ip" {
161161
description = "CIDR blocks allowed to connect via SSH on port 22"
162162
default = [ ]
163+
}
164+
165+
variable "primary_datacenter"{
166+
description = "the primary datacenter for mesh gateways"
167+
default = ""
163168
}

outputs.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ output "Primary_workers_Nodes" {
6262

6363

6464
// Secondary
65-
65+
/*
6666
output "Secondary_Consul" {
6767
value = module.secondarycluster.consul_ui
6868
}
@@ -85,6 +85,7 @@ output "Secondary_servers_nodes" {
8585
output "Secondary_workers_Nodes" {
8686
value = module.secondarycluster.workers
8787
}
88+
*/
8889

8990
// Tertiary
9091
/*

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,9 @@ variable "run_nomad_jobs" {
199199
variable "host_access_ip" {
200200
description = "CIDR blocks allowed to connect via SSH on port 22"
201201
default = []
202+
}
203+
204+
variable "primary_datacenter"{
205+
description = "the primary datacenter for mesh gateways"
206+
default = ""
202207
}

0 commit comments

Comments
 (0)