-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm.tf
111 lines (88 loc) · 3.16 KB
/
vm.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
# Creación de la máquina virtual de administración
resource "azurerm_linux_virtual_machine" "myVM" {
name = "admin"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
size = var.vm_size_adm
admin_username = local.myjson.ssh_user
admin_password = local.myjson.ssh_password
disable_password_authentication = false
network_interface_ids = [ azurerm_network_interface.admNic.id ]
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "OpenLogic"
offer = "CentOS"
sku = "8_4"
version = "8.4.2021071900"
}
boot_diagnostics {
storage_account_uri = azurerm_storage_account.storageAcc.primary_blob_endpoint
}
custom_data = base64encode(file("cloud_init.yaml"))
}
# Creación de las máquinas virtuales Master
resource "azurerm_linux_virtual_machine" "vmMaster" {
count = length(var.masters)
name = var.masters[count.index]
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
size = var.vm_size_master
admin_username = local.myjson.ssh_user
admin_password = local.myjson.ssh_password
disable_password_authentication = false
network_interface_ids = [ azurerm_network_interface.masterNic[count.index].id ]
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "OpenLogic"
offer = "CentOS"
sku = "8_4"
version = "8.4.2021071900"
}
boot_diagnostics {
storage_account_uri = azurerm_storage_account.storageAcc.primary_blob_endpoint
}
custom_data = base64encode(local.init_master)
}
# Creación de las máquinas virtuales Worker
resource "azurerm_linux_virtual_machine" "vmWorker" {
count = length(var.workers)
name = var.workers[count.index]
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
size = var.vm_size_worker
admin_username = local.myjson.ssh_user
admin_password = local.myjson.ssh_password
disable_password_authentication = false
network_interface_ids = [ azurerm_network_interface.workerNic[count.index].id ]
os_disk {
caching = "ReadWrite"
storage_account_type = "Standard_LRS"
}
source_image_reference {
publisher = "OpenLogic"
offer = "CentOS"
sku = "8_4"
version = "8.4.2021071900"
}
boot_diagnostics {
storage_account_uri = azurerm_storage_account.storageAcc.primary_blob_endpoint
}
custom_data = base64encode(local.init_worker)
}
resource "azurerm_resource_group" "rg" {
name = var.resource_group
location = var.location
}
resource "azurerm_storage_account" "storageAcc" {
name = var.resource_group
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
account_tier = "Standard"
account_replication_type = "LRS"
}