Advertisement
Guest User

Untitled

a guest
Mar 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. cat vcenter.tf
  2. terraform {
  3. required_version = "> 0.8.7"
  4. }
  5.  
  6.  
  7.  
  8. # ============================================
  9. # Authentication to vCenter server
  10.  
  11. provider "vsphere" {
  12. user = "${var.vsphere_user}"
  13. password = "${var.vsphere_pass}"
  14. vsphere_server = "${var.vsphere_server}"
  15. allow_unverified_ssl = true
  16. }
  17.  
  18. # ============================================
  19. # VM config
  20.  
  21. resource "vsphere_virtual_machine" "tes_dev" {
  22. count = "${var.num_nodes}"
  23. name = "${var.devuser}-vm-${count.index + 1}"
  24.  
  25. time_zone = "America/Los_Angeles"
  26.  
  27. folder = "${var.folder_name}"
  28.  
  29. # specify the vm, not template if you use linked_clone
  30. linked_clone = true
  31.  
  32. vcpu = "${var.cpus}"
  33. memory = "${var.mem}"
  34.  
  35. datacenter = "${var.this_datacenter}"
  36. cluster = "${var.this_cluster}"
  37.  
  38. # specify the template to use, and where to put it.
  39. disk {
  40. template = "${var.disk_template}"
  41. datastore = "${var.datastore_name}"
  42. }
  43.  
  44. domain = "lab-2.test"
  45. dns_suffixes = ["lab-2.test","test.com"]
  46. dns_servers = [""]
  47.  
  48.  
  49. # control network interface,
  50. # if you don't specify the address/netmask/gateway, dhcp is assumed
  51.  
  52. # net1 interface (CONTROL)
  53. network_interface {
  54. label = "${var.control_network_name}"
  55. # ipv4_address = "${var.control_network_ip[count.index]}"
  56. # ipv4_prefix_length = "${var.control_network_netmask}"
  57. # ipv4_gateway = "${var.control_network_gateway}"
  58.  
  59. }
  60.  
  61. # net2 interface (DATA)
  62. network_interface {
  63. label = "${var.net2_network}"
  64. }
  65. provisioner "file" {
  66. source = "settings"
  67. destination = "/home/admin"
  68. connection {
  69. type = "ssh"
  70. user = ""
  71. timeout = "30s"
  72. password = ""
  73. bastion_host = ""
  74. bastion_user = "test"
  75. }
  76. }
  77. provisioner "remote-exec" {
  78. inline = [
  79. "chmod +x /home/admin/settings/*sh",
  80. # "/home/admin/settings/post_terraform_deploy.sh"
  81. ]
  82. connection {
  83. type = "ssh"
  84. user = ""
  85. timeout = "30s"
  86. password = ""
  87. bastion_host = ""
  88. bastion_user = "test"
  89. }
  90. }
  91. }
  92.  
  93. # ============================================
  94. # vsphere parameters
  95.  
  96. ## not sure if we need folder name
  97.  
  98. variable "this_datacenter" {
  99. default = "Lab1"
  100. }
  101.  
  102. variable "this_cluster" {
  103. default = "ClusterOne"
  104. }
  105.  
  106. variable "datastore_name" {
  107. default = "VMdatastore4"
  108. }
  109.  
  110.  
  111. # VM Template name
  112. variable "disk_template" {
  113. # use this if not creating linked clones
  114. default = "VMgroup/contiv-vm-clone"
  115. }
  116.  
  117.  
  118. # ============================================
  119. # Output section
  120.  
  121. output "lab2_ip_addresses" {
  122. value = ["${vsphere_virtual_machine.contiv_dev.*.network_interface.0.ipv4_address}"]
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement