-
Notifications
You must be signed in to change notification settings - Fork 1
/
infra.tf
97 lines (86 loc) · 4.04 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
# ******* Infra VMs *******
resource "azurerm_virtual_machine" "infra" {
name = "${var.openshift_cluster_prefix}-infra-${count.index}"
location = "${azurerm_resource_group.rg.location}"
resource_group_name = "${azurerm_resource_group.rg.name}"
availability_set_id = "${azurerm_availability_set.infra.id}"
network_interface_ids = ["${element(azurerm_network_interface.infra_nic.*.id, count.index)}"]
vm_size = "${var.infra_vm_size}"
delete_os_disk_on_termination = true
delete_data_disks_on_termination = true
count = "${var.infra_instance_count}"
tags {
displayName = "${var.openshift_cluster_prefix}-infra VM Creation"
}
connection {
type = "ssh"
bastion_host = "${azurerm_public_ip.bastion_pip.fqdn}"
bastion_user = "${var.admin_username}"
bastion_private_key = "${file(var.connection_private_ssh_key_path)}"
host = "${element(azurerm_network_interface.infra_nic.*.private_ip_address, count.index)}"
user = "${var.admin_username}"
private_key = "${file(var.connection_private_ssh_key_path)}"
}
provisioner "file" {
source = "${var.openshift_script_path}/nodePrep.sh"
destination = "nodePrep.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x nodePrep.sh",
"sudo bash nodePrep.sh \"${var.openshift_rht_user}\" \"${var.openshift_rht_password}\" \"${var.openshift_rht_poolid}\""
]
}
os_profile {
computer_name = "${var.openshift_cluster_prefix}-infra-${count.index}"
admin_username = "${var.admin_username}"
admin_password = "${var.openshift_password}"
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
path = "/home/${var.admin_username}/.ssh/authorized_keys"
key_data = "${var.ssh_public_key}"
}
}
storage_image_reference {
publisher = "${lookup(var.os_image_map, join("_publisher", list(var.os_image, "")))}"
offer = "${lookup(var.os_image_map, join("_offer", list(var.os_image, "")))}"
sku = "${lookup(var.os_image_map, join("_sku", list(var.os_image, "")))}"
version = "${lookup(var.os_image_map, join("_version", list(var.os_image, "")))}"
}
storage_os_disk {
name = "${var.openshift_cluster_prefix}-infra-osdisk${count.index}"
vhd_uri = "${azurerm_storage_account.infra_storage_account.primary_blob_endpoint}vhds/${var.openshift_cluster_prefix}-infra-osdisk${count.index}.vhd"
caching = "ReadWrite"
create_option = "FromImage"
}
storage_data_disk {
name = "${var.openshift_cluster_prefix}-infra-docker-pool"
vhd_uri = "${azurerm_storage_account.infra_storage_account.primary_blob_endpoint}vhds/${var.openshift_cluster_prefix}-infra-docker-pool${count.index}.vhd"
disk_size_gb = "${var.data_disk_size}"
create_option = "Empty"
lun = 0
}
storage_data_disk {
name = "${var.openshift_cluster_prefix}-infra-glusterfs-pool1${count.index}"
vhd_uri = "${azurerm_storage_account.nodeos_storage_account.primary_blob_endpoint}vhds/${var.openshift_cluster_prefix}-infra-glusterfs-pool1${count.index}.vhd"
disk_size_gb = 20
create_option = "Empty"
lun = 1
}
storage_data_disk {
name = "${var.openshift_cluster_prefix}-infra-glusterfs-pool2${count.index}"
vhd_uri = "${azurerm_storage_account.nodeos_storage_account.primary_blob_endpoint}vhds/${var.openshift_cluster_prefix}-infra-glusterfs-pool2${count.index}.vhd"
disk_size_gb = 20
create_option = "Empty"
lun = 2
}
storage_data_disk {
name = "${var.openshift_cluster_prefix}-infra-glusterfs-pool3${count.index}"
vhd_uri = "${azurerm_storage_account.nodeos_storage_account.primary_blob_endpoint}vhds/${var.openshift_cluster_prefix}-infra-glusterfs-pool3${count.index}.vhd"
disk_size_gb = 20
create_option = "Empty"
lun = 3
}
}