-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
51 lines (40 loc) · 3.17 KB
/
main.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
resource "nutanix_virtual_machine" "vm1" {
name = var.vm_name
cluster_uuid = data.nutanix_cluster.myCluster.id
num_vcpus_per_socket = var.vcpus_per_socket
num_sockets = var.no_socket
memory_size_mib = var.Memory_in_MB
#Commenting out this, as I think this code size is larger than the supported hence it is not working.
#guest_customization_cloud_init_user_data = base64encode("IyEvYmluL2Jhc2gKICAgICAgICAjIGFwYWNoZSBpbnN0YWxsYXRpb24sIGVuYWJsaW5nIGFuZCBzdGF0dXMgY2hlY2sKICAgICAgICBzdWRvIHl1bSAteSBpbnN0YWxsIGh0dHBkCiAgICAgICAgc3VkbyBzeXN0ZW1jdGwgc3RhcnQgaHR0cGQKICAgICAgICBzdWRvIHN5c3RlbWN0bCBlbmFibGUgaHR0cGQKICAgICAgICBzdWRvIHN5c3RlbWN0bCBzdGF0dXMgaHR0cGQgfCBncmVwIEFjdGl2ZQogICAgICAgICMgZmlyZXdhbGwgaW5zdGFsbGF0aW9uLCBzdGFydCBhbmQgc3RhdHVzIGNoZWNrCiAgICAgICAgc3VkbyB5dW0gaW5zdGFsbCBmaXJld2FsbGQKICAgICAgICBzdWRvIHN5c3RlbWN0bCBzdGFydCBmaXJld2FsbGQKICAgICAgICBzdWRvIHN5c3RlbWN0bCBzdGF0dXMgZmlyZXdhbGxkIHwgZ3JlcCBBY3RpdmUKICAgICAgICAjIGFkZGluZyBodHRwIGFuZCBodHRwcyBzZXJ2aWNlcwogICAgICAgIHN1ZG8gZmlyZXdhbGwtY21kIC0tcGVybWFuZW50IC0tYWRkLXNlcnZpY2U9aHR0cAogICAgICAgIHN1ZG8gZmlyZXdhbGwtY21kIC0tcGVybWFuZW50IC0tYWRkLXNlcnZpY2U9a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c8L2JvZHk+JyA+PiBpbmRleC5odG1sCiAgICAgICAgZWNobyAnPC9odG1sPicgPj4gaW5kZXguaHRtbAo=")
# Now we are using built in funcationility of the terraform to install the web server
connection {
type = "ssh"
user = "root"
password = "<password goes here>"
host = nutanix_virtual_machine.vm1.nic_list_status[0].ip_endpoint_list[0].ip
}
provisioner "remote-exec" {
inline = [
"yum -y install git",
"#To aviod the protocol error",
"yum update -y nss curl libcurl",
"curl https://raw.githubusercontent.com/tanmaybhandge/Linux_scripts/main/webserver.sh -o script.sh",
"sh script.sh",
]
}
nic_list {
subnet_uuid = data.nutanix_subnet.subnet_info.id
}
disk_list {
data_source_reference = {
kind = "image"
uuid = data.nutanix_image.image_info.id
}
device_properties {
disk_address = {
device_index = 0
adapter_type = "SCSI"
}
}
}
}