-
Notifications
You must be signed in to change notification settings - Fork 1
/
outputs.tf
232 lines (210 loc) · 8.12 KB
/
outputs.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
locals {
names = concat(hcloud_server.minio_lab_server[*].name, digitalocean_droplet.minio_lab_server[*].name, aws_instance.minio_lab_server[*].tags.Name)
ips = concat(hcloud_server.minio_lab_server[*].ipv4_address, digitalocean_droplet.minio_lab_server[*].ipv4_address, aws_instance.minio_lab_server[*].public_ip)
}
## Ansible Outputs
resource "local_file" "ansible_inventory" {
content = templatefile("./assets/templates/ansible-inventory.tmpl", {
hcloud_minio_ips = hcloud_server.minio_lab_server[*].ipv4_address,
hcloud_name = hcloud_server.minio_lab_server[*].name,
do_minio_ips = digitalocean_droplet.minio_lab_server[*].ipv4_address,
do_name = digitalocean_droplet.minio_lab_server[*].name,
aws_minio_ips = aws_instance.minio_lab_server[*].public_ip,
aws_name = aws_instance.minio_lab_server[*].tags.Name,
private_key = "./files/${var.deployment_name}/${var.deployment_name}-private-key.pem",
user = var.user,
deployment_name = var.deployment_name,
environment_domain = var.environment_domain
}
)
filename = "./ansible/inventory/${var.deployment_name}/${var.deployment_name}-inventory"
depends_on = [hcloud_server.minio_lab_server]
}
resource "local_file" "ansible_config" {
content = templatefile("./assets/templates/ansible.cfg.tmpl", {
deployment_name = var.deployment_name
}
)
filename = "./ansible/ansible.cfg"
}
resource "local_file" "ansible_all" {
content = templatefile("./assets/templates/all.tmpl", {
deployment_name = var.deployment_name,
user = var.user,
ansible_user = var.user,
environment_systemd_directory = var.environment_systemd_directory,
docker_compose_version = var.docker_compose_version,
lab_repo_url = var.lab_repo_url,
code_server_version = var.code_server_version,
code_server_password = var.code_server_password
shutdown_after_time = var.shutdown_after_time
minio_password = var.minio_password
environment_domain = var.environment_domain
dns_service = var.dns_service
letsencrypt_email = var.letsencrypt_email
gh_pat = var.gh_pat
haproxy_password = var.haproxy_password
codelab_version = var.codelab_version
aws_access_key = var.aws_access_key
aws_secret_key = var.aws_secret_key
}
)
filename = "./ansible/inventory/${var.deployment_name}/group_vars/all.yml"
}
resource "local_file" "cloudflare_ini" {
content = templatefile("./assets/templates/cloudflare.ini.tmpl", {
cloudflare_email = var.cloudflare_email
cloudflare_api_token = var.cloudflare_api_token
}
)
filename = "./ansible/files/${var.deployment_name}/cloudflare.ini"
}
#UI Links
resource "local_file" "minio_ui" {
content = templatefile("./assets/templates/minio-ui-links.txt.tmpl", {
server_names = local.names
server_ips = local.ips
user = var.user
minio_password = var.minio_password,
code_server_password = var.code_server_password,
host_info = "${formatlist( "%s: %s", local.names, local.ips)}",
environment_domain = var.environment_domain,
deployment_name = var.deployment_name
}
)
filename = "ansible/files/${var.deployment_name}/minio-ui-links.txt"
}
resource "local_file" "minio_ui_sh" {
content = templatefile("./assets/templates/minio-ui-links.sh.tmpl", {
server_names = local.names
server_ips = local.ips
user = var.user
minio_password = var.minio_password,
code_server_password = var.code_server_password,
host_info = "${formatlist( "%s: %s", local.names, local.ips)}"
green = "\\e[32m"
end = "\\e[0m"
environment_domain = var.environment_domain,
deployment_name = var.deployment_name
}
)
filename = "ansible/files/${var.deployment_name}/minio-ui-links.sh"
}
#Minio Outputs - Need to Move these to Ansible
resource "local_file" "mc_setup" {
content = templatefile("./assets/templates/tools/mc/minio-client-setup.sh.tmpl", {
minio_password = var.minio_password,
hcloud_minio_ips = hcloud_server.minio_lab_server[*].ipv4_address,
hcloud_name = hcloud_server.minio_lab_server[*].name,
do_minio_ips = digitalocean_droplet.minio_lab_server[*].ipv4_address,
do_name = digitalocean_droplet.minio_lab_server[*].name,
aws_minio_ips = aws_instance.minio_lab_server[*].public_ip,
aws_name = aws_instance.minio_lab_server[*].tags.Name,
user = var.user
}
)
filename = "ansible/files/${var.deployment_name}/minio-client-setup.sh"
depends_on = [hcloud_server.minio_lab_server]
}
resource "local_file" "mc_repl_setup" {
content = templatefile("./assets/templates/tools/mc/minio-site-repl-setup.sh.tmpl", {
server_names = local.names
}
)
filename = "ansible/files/${var.deployment_name}/minio-site-repl-setup.sh"
depends_on = [hcloud_server.minio_lab_server]
}
resource "local_file" "minio_native_start_all" {
content = templatefile("./assets/templates/tools/native/minio-native-start-all.sh.tmpl", {
server_ips = local.ips
user = var.user
}
)
filename = "ansible/files/${var.deployment_name}/minio-native-start-all.sh"
depends_on = [hcloud_server.minio_lab_server]
}
# ## Server Setup Scripts
# resource "local_file" "install_code_server" {
# content = templatefile("./assets/templates/code-server.sh.tmpl", {
# user = var.user,
# code_server_password = var.code_server_password,
# code_server_version = var.code_server_version,
# lab_repo_url = var.lab_repo_url
# }
# )
# filename = "./files/code-server.sh"
# }
# ## Minio Deployment Scripts
# ### Minio Docker Compose Scripts
# resource "local_file" "minio_docker" {
# content = templatefile("./assets/templates/tools/docker/compose/docker-compose.yml.tmpl", {
# minio_password = var.minio_password,
# user = var.user
# }
# )
# filename = "./files/tools/docker/compose/docker-compose.yml"
# }
# resource "local_file" "start_minio_docker-compose" {
# content = templatefile("./assets/templates/tools/docker/compose/minio-docker-compose-start.sh.tmpl", {
# user = var.user,
# hcloud_minio_ips = hcloud_server.minio_lab_server[*].ipv4_address
# do_minio_ips = digitalocean_droplet.minio_lab_server[*].ipv4_address
# }
# )
# filename = "./files/tools/docker/compose/minio-docker-compose-start.sh"
# depends_on = [
# hcloud_server.minio_lab_server
# ]
# }
# resource "local_file" "stop_minio_docker-compose" {
# content = templatefile("./assets/templates/tools/docker/compose/minio-docker-compose-stop.sh.tmpl", {
# user = var.user,
# hcloud_minio_ips = hcloud_server.minio_lab_server[*].ipv4_address
# do_minio_ips = digitalocean_droplet.minio_lab_server[*].ipv4_address
# }
# )
# filename = "./files/tools/docker/compose/minio-docker-compose-stop.sh"
# depends_on = [hcloud_server.minio_lab_server]
# }
# ### Minio Native Server Scripts
# resource "local_file" "start_minio_native" {
# content = templatefile("./assets/templates/tools/native/minio-native-start.sh.tmpl", {
# user = var.user,
# minio_password = var.minio_password
# hcloud_minio_ips = hcloud_server.minio_lab_server[*].ipv4_address,
# do_minio_ips = digitalocean_droplet.minio_lab_server[*].ipv4_address
# }
# )
# filename = "./files/tools/native/start-minio-native.sh"
# depends_on = [hcloud_server.minio_lab_server]
# }
# # General Outputs
# output "ssh-key" {
# value = local_file.ssh_key.filename
# }
# ## HCloud output
# output "hcloud_minio_servers_status" {
# value = {
# for server in hcloud_server.minio_lab_server :
# server.name => server.status
# }
# }
# output "hcloud_minio_servers_ips" {
# value = {
# for server in hcloud_server.minio_lab_server :
# server.name => join("", ["${server.ipv4_address}", ":8080"])
# }
# }
# ## DO output
# output "do_minio_servers_status" {
# value = {
# for server in digitalocean_droplet.minio_lab_server :
# server.name => server.status
# }
# }
# output "do_minio_servers_ips" {
# value = {
# for server in digitalocean_droplet.minio_lab_server :
# server.name => server.ipv4_address
# }
# }