-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
87 lines (71 loc) · 3.17 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
# ╭─────────────────────────────────╮
# │ ┏━┓┏━┓┏━┓╻ ╻╻╺┳┓┏━╸┏━┓┏━┓ │
# │ ┣━┛┣┳┛┃ ┃┃┏┛┃ ┃┃┣╸ ┣┳┛┗━┓ │
# │ ╹ ╹┗╸┗━┛┗┛ ╹╺┻┛┗━╸╹┗╸┗━┛ │
# ╰─────────────────────────────────╯
provider "vsphere" {
allow_unverified_ssl = var.vs_insecure_connection
}
provider "random" {}
# ╭─────────────────────────────────╮
# │ ┏┳┓┏━┓╺┳┓╻ ╻╻ ┏━╸┏━┓ │
# │ ┃┃┃┃ ┃ ┃┃┃ ┃┃ ┣╸ ┗━┓ │
# │ ╹ ╹┗━┛╺┻┛┗━┛┗━╸┗━╸┗━┛ │
# ╰─────────────────────────────────╯
module "network_structure" {
vsphere_host_id = data.vsphere_host.vs_esx_host.id
source = "./modules/network"
}
module "gateway" {
datacenter = data.vsphere_datacenter.dc
resource_pool = data.vsphere_resource_pool.rp
datastore = data.vsphere_datastore.ssd
vm_folder = data.vsphere_folder.vm_folder.path
source = "./modules/gateway"
depends_on = [
module.network_structure,
resource.vsphere_folder.vm_folder
]
}
module "bastion" {
datacenter = data.vsphere_datacenter.dc
resource_pool = data.vsphere_resource_pool.rp
datastore = data.vsphere_datastore.ssd
vm_folder = data.vsphere_folder.vm_folder.path
source = "./modules/bastion"
depends_on = [
module.network_structure,
resource.vsphere_folder.vm_folder
]
}
# ╭───────────────────────────────────╮
# │ ┏━┓┏━╸┏━┓┏━┓╻ ╻┏━┓┏━╸┏━╸┏━┓ │
# │ ┣┳┛┣╸ ┗━┓┃ ┃┃ ┃┣┳┛┃ ┣╸ ┗━┓ │
# │ ╹┗╸┗━╸┗━┛┗━┛┗━┛╹┗╸┗━╸┗━╸┗━┛ │
# ╰───────────────────────────────────╯
resource "random_string" "lab_id" {
length = 4
upper = true
lower = true
number = true
special = false
}
resource "vsphere_folder" "vm_folder" {
path = "${var.vm_folder}-${random_string.lab_id.result}"
type = "vm"
datacenter_id = data.vsphere_datacenter.dc.id
}
# ╭─────────────────────────────╮
# │ ┏━┓╻ ╻╺┳╸┏━┓╻ ╻╺┳╸┏━┓ │
# │ ┃ ┃┃ ┃ ┃ ┣━┛┃ ┃ ┃ ┗━┓ │
# │ ┗━┛┗━┛ ╹ ╹ ┗━┛ ╹ ┗━┛ │
# ╰─────────────────────────────╯
output "vsphere-folder" {
value = resource.vsphere_folder.vm_folder.path
}
output "gateway-ip" {
value = module.gateway.default-ip
}
output "bastion-ip" {
value = module.bastion.default-ip
}