-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster.tf
101 lines (85 loc) · 2.89 KB
/
master.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
# master tf
# Create network interface
resource "azurerm_network_interface" "tfmasternic" {
name = "${var.prefix}-master-nic"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.tfrg.name}"
network_security_group_id = "${azurerm_network_security_group.tfjmeternsg.id}"
ip_configuration {
name = "${var.prefix}-masternic-config"
subnet_id = "${data.azurerm_subnet.jmetersnet.id}"
#private_ip_address_allocation = "dynamic"
private_ip_address_allocation = "Static"
private_ip_address = "${replace(data.azurerm_subnet.jmetersnet.address_prefix, "0/24", "4")}" #"10.0.0.4"
public_ip_address_id = "${azurerm_public_ip.tfjmeterip.id}"
}
tags = {
environment = "${var.tag}"
}
}
# Create virtual machine
resource "azurerm_virtual_machine" "tfmastervm" {
name = "${var.prefix}master"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.tfrg.name}"
network_interface_ids = ["${azurerm_network_interface.tfmasternic.id}"]
vm_size = "${var.vmsize}"
storage_os_disk {
name = "${var.prefix}-master-osdisk"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Premium_LRS"
disk_size_gb = "128" # increase default os disk
}
/*
# custom image
storage_image_reference {
id = "${var.osimageuri}"
}
*/
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04.0-LTS"
version = "latest"
}
os_profile {
computer_name = "jmmaster"
admin_username = "${var.admin_username}"
admin_password = "${var.admin_password}"
}
os_profile_linux_config {
disable_password_authentication = false
}
tags = {
environment = "${var.tag}"
}
}
resource "azurerm_virtual_machine_extension" "mastervmext" {
name = "mastervmext"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.tfrg.name}"
virtual_machine_name = "${azurerm_virtual_machine.tfmastervm.name}"
publisher = "Microsoft.Azure.Extensions"
type = "CustomScript"
type_handler_version = "2.0"
settings = <<SETTINGS
{
"script": "${base64encode( file(var.vmscript))}"
}
SETTINGS
tags = {
environment = "${var.tag}"
}
}
resource "azurerm_public_ip" "tfjmeterip" {
name = "${var.prefix}-jmeterip"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.tfrg.name}"
#public_ip_address_allocation = "static"
allocation_method = "Static"
sku = "Basic" # "Standard"
}
output "jmeter_pip" {
value = "${azurerm_public_ip.tfjmeterip.ip_address}"
}