-
Notifications
You must be signed in to change notification settings - Fork 1
/
vm.tf
79 lines (70 loc) · 2.43 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
resource "azurerm_public_ip" "kafkaPublicIP" {
name = "${var.suffix}-KafkaPublicIP"
location = azurerm_resource_group.genericRG.location
resource_group_name = azurerm_resource_group.genericRG.name
allocation_method = "Static"
tags = var.tags
}
resource "azurerm_network_interface" "kafkaNIC" {
name = "${var.suffix}-KafkaNIC"
location = azurerm_resource_group.genericRG.location
resource_group_name = azurerm_resource_group.genericRG.name
ip_configuration {
name = "kafkaServer"
subnet_id = azurerm_subnet.subnets["headnodes"].id
#subnet_id = data.azurerm_subnet.kafkasubnet.id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.kafkaPublicIP.id
}
tags = var.tags
}
resource "azurerm_virtual_machine" "kafkaServer" {
name = "${var.suffix}-KafkaServer"
location = azurerm_resource_group.genericRG.location
resource_group_name = azurerm_resource_group.genericRG.name
network_interface_ids = ["${azurerm_network_interface.kafkaNIC.id}"]
vm_size = "Standard_DS3_v2"
# Uncomment this line to delete the OS disk automatically when deleting the VM
delete_os_disk_on_termination = true
# Uncomment this line to delete the data disks automatically when deleting the VM
delete_data_disks_on_termination = true
storage_image_reference {
publisher = "RedHat"
offer = "RHEL"
sku = "7-RAW-CI"
version = "latest"
}
storage_os_disk {
name = "${var.suffix}-kafkaServerosDisk1"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "kafkaServer"
admin_username = var.vmUserName
custom_data = <<-EOF
#cloud-config
package_upgrade: true
packages:
- httpd
- java-1.8.0-openjdk-devel
- tmux
- git
write_files:
- content: <!doctype html><html><body><h1>Hello kafkaAdmin 2019 from Azure!</h1></body></html>
path: /var/www/html/index.html
runcmd:
- [ systemctl, enable, httpd.service ]
- [ systemctl, start, httpd.service ]
EOF
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
path = "/home/${var.vmUserName}/.ssh/authorized_keys"
key_data = file(var.sshKeyPath)
}
}
tags = var.tags
}