-
Notifications
You must be signed in to change notification settings - Fork 0
/
rcluster.tf
50 lines (42 loc) · 1.37 KB
/
rcluster.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
# Create a new rancher2 RKE Cluster
resource "rancher2_cluster" "app_cluster" {
name = var.cluster_name
description = "Application Cluster RKE"
rke_config {
network {
plugin = "canal"
}
}
}
resource "null_resource" "controlplane_provision" {
count = length(var.controlplane)
provisioner "remote-exec" {
inline = [
"curl -sfL https://releases.rancher.com/install-docker/20.10.sh | sh -",
"sudo usermod -aG docker ${var.controlplane[count.index].ssh_user}",
"${rancher2_cluster.app_cluster.cluster_registration_token.0.node_command} --controlplane --etcd"
]
}
connection {
type = "ssh"
user = var.controlplane[count.index].ssh_user
private_key = var.controlplane[count.index].private_key
host = var.controlplane[count.index].ip_address
}
}
resource "null_resource" "workers_provision" {
count = length(var.workers)
provisioner "remote-exec" {
inline = [
"curl -sfL https://releases.rancher.com/install-docker/20.10.sh | sh -",
"sudo usermod -aG docker ${var.workers[count.index].ssh_user}",
"${rancher2_cluster.app_cluster.cluster_registration_token.0.node_command} --worker"
]
}
connection {
type = "ssh"
user = var.workers[count.index].ssh_user
private_key = var.workers[count.index].private_key
host = var.workers[count.index].ip_address
}
}