forked from hashicorp/terraform-aws-terraform-enterprise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.tf
132 lines (116 loc) · 5.37 KB
/
config.tf
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
126
127
128
129
130
131
locals {
app_data_mode = var.postgresql_address != "" ? "external_services" : "demo"
app_network_type = var.airgap_package_url != "" ? "airgap" : "online"
install_type = "${local.app_data_mode}-${local.app_network_type}"
}
# Settings for automated PTFE installation
data "template_file" "repl_ptfe_config" {
template = local.rptfeconf[local.install_type]
vars = {
hostname = module.lb.endpoint
enc_password = local.encryption_password
iact_subnet_list = var.iact_subnet_list
iact_subnet_time_limit = var.iact_subnet_time_limit
pg_user = var.postgresql_user
pg_password = var.postgresql_password
pg_netloc = var.postgresql_address
pg_dbname = var.postgresql_database
pg_extra_params = var.postgresql_extra_params
aws_instance_profile = var.aws_instance_profile ? "1" : "0"
aws_access_key_id = var.aws_access_key_id
aws_secret_access_key = var.aws_secret_access_key
s3_bucket_name = var.s3_bucket
s3_bucket_region = var.s3_region
additional_no_proxy = var.additional_no_proxy
}
}
# Settings for automated replicated installation.
data "template_file" "repl_config" {
template = local.replconf[local.install_type]
vars = {
console_password = random_pet.console_password.id
proxy_url = var.http_proxy_url
additional_no_proxy = var.additional_no_proxy
release_sequence = var.release_sequence
}
}
locals {
internal_airgap_url = "http://${aws_elb.cluster_api.dns_name}:${local.assistant_port}/setup-files/replicated.tar.gz?token=${random_string.setup_token.result}"
}
data "template_file" "cloud_config" {
count = local.primary_count
template = file("${path.module}/templates/cloud-config.yaml")
vars = {
hostname = module.lb.endpoint
license_b64 = filebase64(var.license_file)
install_ptfe_sh = base64gzip(file("${path.module}/files/install-ptfe.sh"))
# Needed for Airgap installations
airgap_package_url = var.airgap_package_url
airgap_installer_url = var.airgap_package_url == "" ? "" : count.index == 0 ? var.airgap_installer_url : local.internal_airgap_url
bootstrap_token = "${random_string.bootstrap_token_id.result}.${random_string.bootstrap_token_suffix.result}"
cluster_api_lb = aws_elb.cluster_api.dns_name
cluster_api_endpoint = "${aws_elb.cluster_api.dns_name}:6443"
setup_token = random_string.setup_token.result
primary_pki_url = "http://${aws_elb.cluster_api.dns_name}:${local.assistant_port}/api/v1/pki-download?token=${random_string.setup_token.result}"
role_id = count.index
health_url = "http://${aws_elb.cluster_api.dns_name}:${local.assistant_port}/healthz"
assistant_host = "http://${aws_elb.cluster_api.dns_name}:${local.assistant_port}"
assistant_token = random_string.setup_token.result
proxy_url = var.http_proxy_url
additional_no_proxy = var.additional_no_proxy
installer_url = var.installer_url
weave_cidr = var.weave_cidr
repl_cidr = var.repl_cidr
ca_bundle_url = var.ca_bundle_url
import_key = var.import_key
startup_script = base64gzip(var.startup_script)
role = count.index == 0 ? "main" : "primary"
distro = var.distribution
rptfeconf = base64gzip(data.template_file.repl_ptfe_config.rendered)
replconf = base64gzip(data.template_file.repl_config.rendered)
}
}
data "template_cloudinit_config" "config" {
count = local.primary_count
gzip = true
base64_encode = true
part {
content_type = "text/cloud-config"
content = data.template_file.cloud_config[count.index].rendered
}
}
data "template_file" "cloud_config_secondary" {
template = file("${path.module}/templates/cloud-config-secondary.yaml")
vars = {
install_ptfe_sh = base64gzip(file("${path.module}/files/install-ptfe.sh"))
bootstrap_token = "${random_string.bootstrap_token_id.result}.${random_string.bootstrap_token_suffix.result}"
cluster_api_endpoint = "${aws_elb.cluster_api.dns_name}:6443"
health_url = "http://${aws_elb.cluster_api.dns_name}:${local.assistant_port}/healthz"
assistant_host = "http://${aws_elb.cluster_api.dns_name}:${local.assistant_port}"
assistant_token = random_string.setup_token.result
proxy_url = var.http_proxy_url
additional_no_proxy = var.additional_no_proxy
installer_url = var.installer_url
role = "secondary"
airgap_installer_url = var.airgap_package_url == "" ? "" : local.internal_airgap_url
ca_bundle_url = var.ca_bundle_url
import_key = var.import_key
startup_script = base64gzip(var.startup_script)
}
}
data "template_cloudinit_config" "config_secondary" {
gzip = true
base64_encode = true
part {
content_type = "text/cloud-config"
content = data.template_file.cloud_config_secondary.rendered
}
}
data "template_file" "ssh_config" {
template = file("${path.module}/templates/ssh_config")
vars = {
hostname = element(aws_instance.primary.*.public_ip, 0)
ssh_user = var.ssh_user != "" ? var.ssh_user : local.default_ssh_user
keyfile_path = module.common.ssh_priv_key_file
}
}