daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Jul 21st, 2017 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Hi,
  2.  
  3. In the latest version of Terraform .69 using the vSphere provider I am facing an issue with NIC creation. The terraform.tf file looks like this:
  4.  
  5. # Enter the details of the vCenter here
  6. variable "vcenter_address" {default = "x.x.x.x}
  7. variable "vcenter_user" {default = "xxx"}
  8. variable "vcenter_password" {default = "xxxxxx"}
  9.  
  10. # This is the prefix assigned to the machine
  11. variable "short_name" {default = "dc01"}
  12.  
  13. # Some vSphere global variables
  14. variable "vsphere_dc" {default = "LAB"}
  15. variable "vsphere_cluster" {default = "LAB"}
  16. variable "timezone" {default = "Asia/Dubai"}
  17. variable "search_domain" {default = "watteel.local"}
  18. variable "dns_servers" {default = "192.168.111.1,8.8.8.8"}
  19.  
  20. # Details for the master nodes
  21. variable "master_cpu" {default = 2}
  22. variable "master_mem" {default = 1024}
  23. variable "master_count" {default = 1}
  24. variable "master_template" {default = "Templates/CentOS7_x86_64"}
  25. variable "master_datastore" {default = "ISCSI_HDD_LUN3_THIN"}
  26. variable "master_network_label" {default = "VLAN111"}
  27. variable "master_gateway" {default = "192.168.111.1"}
  28. variable "master_netmask" {default = "24"}
  29.  
  30. provider "vsphere" {
  31.   vsphere_server = "${var.vcenter_address}"
  32.   user = "${var.vcenter_user}"
  33.   password = "${var.vcenter_password}"
  34.   allow_unverified_ssl = "True"
  35. }
  36.  
  37. resource "vsphere_virtual_machine" "masters" {
  38.     name = "${var.short_name}-control-${format("%02d", count.index+1)}"
  39.     datacenter = "${var.vsphere_dc}"
  40.     cluster = "${var.vsphere_cluster}"
  41.     vcpu = "${var.master_cpu}"
  42.     memory = "${var.master_mem}"
  43.     disk {
  44.         datastore = "${var.master_datastore}"
  45.         template = "${var.master_template}"
  46.     }
  47.     gateway = "${var.master_gateway}"
  48.     network_interface {
  49.         label = "${var.master_network_label}"
  50.         ipv4_address = "${var.master_ip_range}${format(count.index+1)}"
  51.         ipv4_prefix_length = "${var.master_netmask}"
  52.     }
  53.  
  54.   domain = "${var.search_domain}"
  55.   dns_suffixes = ["${var.search_domain}"]
  56.   dns_servers = ["${split(",", var.dns_servers)}"]
  57.   time_zone = "${var.timezone}"
  58.   count = "${var.master_count}"
  59. }
  60.  
  61.  
  62.  
  63. The job runs, however no IPv4 interface is assigned. An IPv6 address appears and that's all.
  64. From terraform.tfstate:
  65.  
  66.  "resources": {
  67.                 "vsphere_virtual_machine.masters": {
  68.                     "type": "vsphere_virtual_machine",
  69.                     "primary": {
  70.                         "id": "dc01-control-01",
  71.                         "attributes": {
  72.                             "cluster": "LAB",
  73.                             "datacenter": "LAB",
  74.                             "disk.#": "1",
  75.                             "disk.0.datastore": "ISCSI_HDD_LUN3_THIN",
  76.                             "disk.0.iops": "0",
  77.                             "disk.0.size": "0",
  78.                             "disk.0.template": "Templates/CentOS7_x86_64",
  79.                             "dns_servers.#": "2",
  80.                             "dns_servers.0": "192.168.111.1",
  81.                             "dns_servers.1": "8.8.8.8",
  82.                             "dns_suffixes.#": "1",
  83.                             "dns_suffixes.0": "watteel.local",
  84.                             "domain": "watteel.local",
  85.                             "gateway": "192.168.111.1",
  86.                             "id": "dc01-control-01",
  87.                             "memory": "1024",
  88.                             "name": "dc01-control-01",
  89.                             "network_interface.#": "1",
  90.                             "network_interface.0.adapter_type": "",
  91.                             "network_interface.0.ip_address": "",
  92.                             "network_interface.0.ipv4_address": "",
  93.                             "network_interface.0.ipv4_prefix_length": "0",
  94.                             "network_interface.0.ipv6_address": "fe80::250:56ff:fe80:2c9a",
  95.                             "network_interface.0.ipv6_prefix_length": "64",
  96.                             "network_interface.0.label": "VLAN111",
  97.                             "network_interface.0.subnet_mask": "",
  98.                             "time_zone": "Asia/Dubai",
  99.                             "vcpu": "2"
  100.                         }
  101.  
  102.  
  103. I've tried using both the old ip_address and subnet_mask fields from previous versions, as well as the new ipv4_address and prefix length.
  104.  
  105. Interestingly Terraform shows the correct IP on stdout when I run it.
  106.  
  107. [root@hatchery terraform]# terraform apply vsphere/
  108. vsphere_virtual_machine.masters: Creating...
  109.   cluster:                                "" => "LAB"
  110.   datacenter:                             "" => "LAB"
  111.   disk.#:                                 "" => "1"
  112.   disk.0.datastore:                       "" => "ISCSI_HDD_LUN3_THIN"
  113.   disk.0.template:                        "" => "Templates/CentOS7_x86_64"
  114.   dns_servers.#:                          "" => "2"
  115.   dns_servers.0:                          "" => "192.168.111.1"
  116.   dns_servers.1:                          "" => "8.8.8.8"
  117.   dns_suffixes.#:                         "" => "1"
  118.   dns_suffixes.0:                         "" => "watteel.local"
  119.   domain:                                 "" => "watteel.local"
  120.   gateway:                                "" => "192.168.111.1"
  121.   memory:                                 "" => "1024"
  122.   name:                                   "" => "dc01-control-01"
  123.   network_interface.#:                    "" => "1"
  124.   network_interface.0.ip_address:         "" => "<computed>"
  125.   network_interface.0.ipv4_address:       "" => "192.168.111.201"
  126.   network_interface.0.ipv4_prefix_length: "" => "24"
  127.   network_interface.0.ipv6_address:       "" => "<computed>"
  128.   network_interface.0.ipv6_prefix_length: "" => "<computed>"
  129.   network_interface.0.label:              "" => "VLAN111"
  130.   network_interface.0.subnet_mask:        "" => "<computed>"
  131.   time_zone:                              "" => "Asia/Dubai"
  132.   vcpu:                                   "" => "2"
  133.  
  134. vsphere_virtual_machine.masters: Creation complete
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top