This repository has been archived by the owner on Apr 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathinfra.tf
153 lines (134 loc) · 6.63 KB
/
infra.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
resource "azurerm_availability_set" "osinfraas" {
name = "${var.openshift_azure_resource_prefix}-as-infra-${var.openshift_azure_resource_suffix}"
location = "${azurerm_resource_group.osrg.location}"
resource_group_name = "${azurerm_resource_group.osrg.name}"
managed = true
}
resource "azurerm_network_interface" "osinfranic" {
name = "${var.openshift_azure_resource_prefix}-nic-infra-${var.openshift_azure_resource_suffix}-${format("%01d", count.index)}"
count = "${var.openshift_azure_infra_vm_count}"
location = "${azurerm_resource_group.osrg.location}"
resource_group_name = "${azurerm_resource_group.osrg.name}"
network_security_group_id = "${azurerm_network_security_group.osinfransg.id}"
ip_configuration {
name = "configuration-${count.index}"
subnet_id = "${azurerm_subnet.osmastersubnet.id}"
private_ip_address_allocation = "dynamic"
load_balancer_backend_address_pools_ids = ["${azurerm_lb_backend_address_pool.osinfralbbepool.id}"]
}
}
resource "azurerm_lb_backend_address_pool" "osinfralbbepool" {
resource_group_name = "${azurerm_resource_group.osrg.name}"
loadbalancer_id = "${azurerm_lb.osinfralb.id}"
name = "BackEndAddressPool"
}
resource "azurerm_public_ip" "osinfraip" {
name = "${var.openshift_azure_resource_prefix}-vip-infra-${var.openshift_azure_resource_suffix}"
location = "${azurerm_resource_group.osrg.location}"
resource_group_name = "${azurerm_resource_group.osrg.name}"
public_ip_address_allocation = "static"
domain_name_label = "${var.openshift_azure_resource_prefix}-${var.openshift_infra_dns_name}-${var.openshift_azure_resource_suffix}"
}
resource "azurerm_lb" "osinfralb" {
name = "${var.openshift_azure_resource_prefix}-nlb-infra-${var.openshift_azure_resource_suffix}"
location = "${azurerm_resource_group.osrg.location}"
resource_group_name = "${azurerm_resource_group.osrg.name}"
frontend_ip_configuration {
name = "PublicIPAddress"
public_ip_address_id = "${azurerm_public_ip.osinfraip.id}"
}
}
resource "azurerm_lb_rule" "osinfralbrule80" {
resource_group_name = "${azurerm_resource_group.osrg.name}"
loadbalancer_id = "${azurerm_lb.osinfralb.id}"
name = "OpenShiftRouterHTTP"
protocol = "Tcp"
frontend_port = 80
backend_port = 80
frontend_ip_configuration_name = "PublicIPAddress"
probe_id = "${azurerm_lb_probe.osinfralbprobe80.id}"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.osinfralbbepool.id}"
}
resource "azurerm_lb_probe" "osinfralbprobe80" {
resource_group_name = "${azurerm_resource_group.osrg.name}"
loadbalancer_id = "${azurerm_lb.osinfralb.id}"
name = "httpProbe"
port = 80
number_of_probes = 2
}
resource "azurerm_lb_rule" "osinfralbrule443" {
resource_group_name = "${azurerm_resource_group.osrg.name}"
loadbalancer_id = "${azurerm_lb.osinfralb.id}"
name = "OpenShiftRouterHTTPS"
protocol = "Tcp"
frontend_port = 443
backend_port = 443
frontend_ip_configuration_name = "PublicIPAddress"
probe_id = "${azurerm_lb_probe.osinfralbprobe443.id}"
backend_address_pool_id = "${azurerm_lb_backend_address_pool.osinfralbbepool.id}"
}
resource "azurerm_lb_probe" "osinfralbprobe443" {
resource_group_name = "${azurerm_resource_group.osrg.name}"
loadbalancer_id = "${azurerm_lb.osinfralb.id}"
name = "httpsProbe"
port = 443
number_of_probes = 2
}
resource "azurerm_virtual_machine" "osinfravm" {
name = "${var.openshift_azure_resource_prefix}-vm-infra-${var.openshift_azure_resource_suffix}-${format("%01d", count.index)}"
count = "${var.openshift_azure_infra_vm_count}"
location = "${azurerm_resource_group.osrg.location}"
resource_group_name = "${azurerm_resource_group.osrg.name}"
network_interface_ids = ["${element(azurerm_network_interface.osinfranic.*.id, count.index)}"]
availability_set_id = "${azurerm_availability_set.osinfraas.id}"
vm_size = "${var.openshift_azure_infra_vm_size}"
storage_image_reference {
publisher = "${var.openshift_azure_vm_os["publisher"]}"
offer = "${var.openshift_azure_vm_os["offer"]}"
sku = "${var.openshift_azure_vm_os["sku"]}"
version = "${var.openshift_azure_vm_os["version"]}"
}
storage_os_disk {
name = "${var.openshift_azure_resource_prefix}-disk-os-infra-${var.openshift_azure_resource_suffix}-${format("%01d", count.index)}"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
storage_data_disk {
name = "${var.openshift_azure_resource_prefix}-disk-data-infra-${var.openshift_azure_resource_suffix}-${format("%01d", count.index)}"
managed_disk_type = "Standard_LRS"
create_option = "Empty"
lun = 0
disk_size_gb = "${var.openshift_azure_data_disk_size}"
}
os_profile {
computer_name = "${var.openshift_azure_resource_prefix}-vm-infra-${var.openshift_azure_resource_suffix}-${format("%01d", count.index)}"
admin_username = "${var.openshift_azure_vm_username}"
admin_password = "${uuid()}"
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
path = "/home/${var.openshift_azure_vm_username}/.ssh/authorized_keys"
key_data = "${file(var.openshift_azure_public_key)}"
}
}
}
resource "azurerm_virtual_machine_extension" "osinfravmextension" {
name = "osinfravmextension"
count = "${var.openshift_azure_infra_vm_count}"
location = "${azurerm_resource_group.osrg.location}"
resource_group_name = "${azurerm_resource_group.osrg.name}"
virtual_machine_name = "${element(azurerm_virtual_machine.osinfravm.*.name, count.index)}"
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.0"
settings = <<SETTINGS
{
"fileUris": [
"${var.openshift_azure_node_prep_script}"
],
"commandToExecute": "bash nodePrep.sh ${azurerm_storage_account.osstoragepv.name} ${var.openshift_azure_vm_username}"
}
SETTINGS
}