forked from harvestdp/rancher-on-eks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04_helm_rancher.tf
63 lines (56 loc) · 1.56 KB
/
04_helm_rancher.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
# install rancher
resource "helm_release" "rancher" {
depends_on = [time_sleep.wait_for_ingress_nginx]
name = "rancher"
repository = "https://releases.rancher.com/server-charts/latest"
chart = "rancher"
version = var.rancher_version
namespace = "cattle-system"
create_namespace = true
values = var.rancher_values_filename != "" ? [file(var.rancher_values_filename)] : []
set {
name = "helmVersion"
value = "v3"
}
set {
name = "hostname"
value = local.full_domain
}
set {
name = "ingress.tls.source"
value = "letsEncrypt"
}
set {
name = "letsEncrypt.email"
value = var.cert_manager_letsencrypt_email
}
set {
name = "letsEncrypt.environment"
value = var.cert_manager_letsencrypt_environment
}
}
resource "null_resource" "wait_for_rancher" {
depends_on = [helm_release.rancher]
provisioner "local-exec" {
command = <<EOF
while [ "$${subject}" != "* subject: CN=$${RANCHER_HOSTNAME}" ]; do
subject=$(curl -vk -m 2 "https://$${RANCHER_HOSTNAME}/ping" 2>&1 | grep "subject:")
echo "Cert Subject Response: $${subject}"
if [ "$${subject}" != "* subject: CN=$${RANCHER_HOSTNAME}" ]; then
sleep 10
fi
done
while [ "$${resp}" != "pong" ]; do
resp=$(curl -sSk -m 2 "https://$${RANCHER_HOSTNAME}/ping")
echo "Rancher Response: $${resp}"
if [ "$${resp}" != "pong" ]; then
sleep 10
fi
done
EOF
interpreter = var.shell_interpreter
environment = {
RANCHER_HOSTNAME = local.full_domain
}
}
}