-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.tf
172 lines (139 loc) · 5.48 KB
/
main.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
provider "equinix" {
auth_token = var.metal_auth_token
}
module "sshkey" {
source = "./modules/sshkey"
cluster_name = var.cluster_name
}
module "bastion" {
source = "./modules/bastion"
depends_on = [module.sshkey]
project_id = var.metal_project_id
metro = var.metal_metro
plan = var.plan_bastion
operating_system = var.bastion_operating_system
ssh_private_key_path = module.sshkey.ssh_private_key_file
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
ocp_version = var.ocp_version
ocp_version_zstream = var.ocp_version_zstream
//depends = [module.prepare_openshift.finished]
}
module "dns_lb" {
source = "./modules/dns"
dns_provider = var.dns_provider
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
node_type = "lb"
node_ips = tolist([module.bastion.lb_ip])
}
module "prepare_openshift" {
source = "./modules/prereq"
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
ocp_version = var.ocp_version
count_controlplane = var.count_controlplane
count_compute = var.count_compute
ssh_public_key = module.sshkey.ssh_public_key
ssh_private_key_path = module.sshkey.ssh_private_key_file
bastion_ip = module.bastion.lb_ip
ocp_api_token = var.ocp_cluster_manager_token
depends = [module.bastion.finished]
}
module "openshift_bootstrap" {
source = "./modules/node"
depends_on = [module.sshkey]
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
node_count = var.count_bootstrap
plan = var.plan_controlplane
metro = var.metal_metro
ssh_private_key_path = module.sshkey.ssh_private_key_file
project_id = var.metal_project_id
bastion_ip = module.bastion.lb_ip
node_type = "bootstrap"
depends = [module.prepare_openshift.finished]
}
module "dns_bootstrap" {
source = "./modules/dns"
dns_provider = var.dns_provider
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
node_type = "bootstrap"
node_ips = module.openshift_bootstrap.node_ip
}
module "openshift_controlplane" {
source = "./modules/node"
depends_on = [module.sshkey]
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
node_count = var.count_controlplane
plan = var.plan_controlplane
metro = var.metal_metro
ssh_private_key_path = module.sshkey.ssh_private_key_file
project_id = var.metal_project_id
bastion_ip = module.bastion.lb_ip
node_type = "master"
depends = [module.prepare_openshift.finished]
}
module "dns_controlplane" {
source = "./modules/dns"
dns_provider = var.dns_provider
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
node_type = "master"
node_ips = module.openshift_controlplane.node_ip
}
module "openshift_workers" {
source = "./modules/node"
depends_on = [module.sshkey]
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
node_count = var.count_compute
plan = var.plan_compute
metro = var.metal_metro
ssh_private_key_path = module.sshkey.ssh_private_key_file
project_id = var.metal_project_id
bastion_ip = module.bastion.lb_ip
node_type = "worker"
depends = [module.prepare_openshift.finished]
}
module "dns_workers" {
source = "./modules/dns"
dns_provider = var.dns_provider
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
node_type = "worker"
node_ips = module.openshift_workers.node_ip
}
module "openshift_install" {
source = "./modules/install"
ssh_private_key_path = module.sshkey.ssh_private_key_file
operating_system = var.bastion_operating_system
bastion_ip = module.bastion.lb_ip
count_controlplane = var.count_controlplane
count_compute = var.count_compute
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
bootstrap_ip = module.openshift_bootstrap.node_ip
controlplane_ips = module.openshift_controlplane.node_ip
worker_ips = module.openshift_workers.node_ip
depends = [module.openshift_controlplane.node_ip, module.openshift_workers.node_ip]
ocp_storage_nfs_enable = var.ocp_storage_nfs_enable
ocp_storage_ocs_enable = var.ocp_storage_ocs_enable
ocp_virtualization_enable = var.ocp_virtualization_enable
}
resource "null_resource" "get_kubeconfig" {
depends_on = [module.prepare_openshift.finished]
provisioner "local-exec" {
command = <<EOT
[[ -d ${path.root}/auth ]] || mkdir -p ${path.root}/auth
/usr/bin/scp -r -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${module.sshkey.ssh_private_key_file} root@${module.bastion.lb_ip}:/tmp/artifacts/install/auth/* ${path.root}/auth/
EOT
interpreter = [ "/bin/bash", "-c" ]
}
}
data "external" "kubeadmin_password" {
depends_on = [null_resource.get_kubeconfig]
program = ["/bin/bash", "-c", "[ -f \"${path.root}/auth/kubeadmin-password\" ] && echo \"{\\\"password\\\":\\\"$(cat ${path.root}/auth/kubeadmin-password)\\\"}\""]
}