-
Notifications
You must be signed in to change notification settings - Fork 0
/
remote.tf
75 lines (60 loc) · 1.81 KB
/
remote.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
resource "null_resource" "copy-test-file" {
for_each = { for inst in local.instances : inst.servername => inst }
connection {
type = "ssh"
host = each.value.servername
user = var.username
password = var.password
}
provisioner "file" {
source = "files/rootCA.suse.crt"
destination = "/etc/pki/trust/anchors/rootCA.suse.crt"
}
}
resource "null_resource" "update-ca-certificates" {
for_each = { for inst in local.instances : inst.servername => inst }
provisioner "remote-exec" {
connection {
host = each.value.servername
user = var.username
password = var.password
}
inline = ["update-ca-certificates"]
}
}
resource "null_resource" "registration" {
for_each = { for inst in local.instances : inst.servername => inst }
provisioner "remote-exec" {
when = create
connection {
host = each.value.servername
user = var.username
password = var.password
}
inline = each.value.role == "master" ? [
format("%s %s",
rancher2_cluster_v2.cluster.cluster_registration_token[0]["insecure_node_command"],
join(" ", formatlist("--%s", split(",", "etcd,controlplane")))
)
] : [
format("%s %s",
rancher2_cluster_v2.cluster.cluster_registration_token[0]["insecure_node_command"],
join(" ", formatlist("--%s", split(",", "worker")))
)
]
}
provisioner "remote-exec" {
when = destroy
connection {
host = self.triggers.host
agent = true
user = self.triggers.username
password = self.triggers.password
}
inline = [
"sudo sed -i 's#rm -rf /var/lib/kubelet#rm -rf /var/lib/kubelet || true#g' /usr/local/bin/rke2-uninstall.sh",
"sudo rancher-system-agent-uninstall.sh",
"sudo rke2-uninstall.sh"
]
}
}