2017-08-24 115 views
1

这是我第一次尝试使用terraform创建vSphere VM。虚拟机成功创建,但需要7分钟才能完成。这是我采取的步骤。Terraform vSphere慢启动

  • 手动上传Ubuntu 16.04 ova。
  • 手动将图像转换为模板。
  • 通过GUI从模板手动创建VM。虚拟机启动需要大约20秒的时间,需要 。
  • 使用指向模板的terraform创建VM。这需要7 分钟。

使用terraform VM启动顺序与手动创建的VM相同,然后在下面的消息中挂起大约6分半钟。

[ 12.109016] blk_update_request: I/O error, dev fd0, sector 0 

对于手动和terraform VM创建,该错误消息重复约6次。但在手动创建期间,它几乎立即转到登录提示。在terraform创建期间,它会在此消息中挂起大约6分半钟,然后转到登录提示符。任何想法为什么它挂在terraform创作过程中?

intance.tf

resource "vsphere_virtual_machine" "hellovm" { 
    name = "hellovm2" 
    vcpu = 1 
    memory = 1024 
    datacenter = "Lab09-Datacenter01" 

    network_interface { 
    label = "Lab09-NetA" 
    } 

    disk { 
    template = "${var.vmtemp}" 
    type = "thin" 
    datastore = "${var.vmdatastore}" 
    } 
} 

terraform标准输出

Macbook12:concoursebootstrap steve$ terraform apply 
vsphere_folder.concourse-base: Refreshing state... (ID: Lab09-Datacenter01/VirtualMachines) 
vsphere_virtual_machine.hellovm: Refreshing state... (ID: hellovm) 
vsphere_virtual_machine.hellovm: Creating... 
    datacenter:        "" => "Lab09-Datacenter01" 
    detach_unknown_disks_on_delete:   "" => "false" 
    disk.#:         "" => "1" 
    disk.3867083049.bootable:    "" => "" 
    disk.3867083049.controller_type:  "" => "scsi" 
    disk.3867083049.datastore:    "" => "nfs-lab09-vol1" 
    disk.3867083049.iops:     "" => "" 
    disk.3867083049.keep_on_remove:   "" => "" 
    disk.3867083049.key:     "" => "<computed>" 
    disk.3867083049.name:     "" => "" 
    disk.3867083049.size:     "" => "" 
    disk.3867083049.template:    "" => "ubuntu-16.04-server-cloudimg-amd64" 
    disk.3867083049.type:     "" => "thin" 
    disk.3867083049.uuid:     "" => "<computed>" 
    disk.3867083049.vmdk:     "" => "" 
    domain:         "" => "vsphere.local" 
    enable_disk_uuid:      "" => "false" 
    linked_clone:       "" => "false" 
    memory:         "" => "1024" 
    memory_reservation:      "" => "0" 
    moid:         "" => "<computed>" 
    name:         "" => "hellovm" 
    network_interface.#:     "" => "1" 
    network_interface.0.ip_address:   "" => "<computed>" 
    network_interface.0.ipv4_address:  "" => "<computed>" 
    network_interface.0.ipv4_gateway:  "" => "<computed>" 
    network_interface.0.ipv4_prefix_length: "" => "<computed>" 
    network_interface.0.ipv6_address:  "" => "<computed>" 
    network_interface.0.ipv6_gateway:  "" => "<computed>" 
    network_interface.0.ipv6_prefix_length: "" => "<computed>" 
    network_interface.0.label:    "" => "Lab09-NetA" 
    network_interface.0.mac_address:  "" => "<computed>" 
    network_interface.0.subnet_mask:  "" => "<computed>" 
    skip_customization:      "" => "false" 
    time_zone:        "" => "Etc/UTC" 
    uuid:         "" => "<computed>" 
    vcpu:         "" => "1" 
vsphere_virtual_machine.hellovm: Still creating... (10s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (20s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (30s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (40s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (50s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (1m0s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (1m10s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (1m20s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (1m30s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (1m40s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (1m50s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (2m0s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (2m10s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (2m20s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (2m30s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (2m40s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (2m50s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (3m0s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (3m10s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (3m20s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (3m30s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (3m40s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (3m50s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (4m0s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (4m10s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (4m20s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (4m30s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (4m40s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (4m50s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (5m0s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (5m10s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (5m20s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (5m30s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (5m40s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (5m50s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (6m0s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (6m10s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (6m20s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (6m30s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (6m40s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (6m50s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (7m0s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (7m10s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (7m20s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (7m30s elapsed) 
vsphere_virtual_machine.hellovm: Still creating... (7m40s elapsed) 
vsphere_virtual_machine.hellovm: Creation complete (ID: hellovm) 

Apply complete! Resources: 1 added, 0 changed, 0 destroyed. 

申请Ubuntu的dmesg的

ubuntu dmesg

VM后

terraform跟踪输出创建,它是等待启动

terrafrom trace output

的terraform输出的其余部分。重复原木然后几分钟以下

terraform trace output part 2

回答

1

对不起,您有使用vSphere供应商合作的问题!

从我在日志中看到的内容和通过查看配置,可能是因为虚拟机启动时不一定具有IP地址。 Terraform vSphere提供程序目前正在等待所有接口具有网络连接(通过VMware工具报告),然后继续读取虚拟机的状态。在创建虚拟机时也是这样,所以这很可能是问题的原因(特别是在日志中显示waiting for interfaces to appear消息之后等待很长时间)。

查看您的配置,我看到没有在TF代码中分配ipv4_address,这意味着Terraform将发送VM定制规范,告知接口使用DHCP。如果您的网络上没有DHCP,那可能是问题的一部分。

我会建议他:

  • 如果你没有,你正在使用的网络上的DHCP,使用ipv4_address和相关选项分配一个IP地址给虚拟机,然后再次尝试应用。您也可以在有问题的网络上安装DHCP,以避免必须在TF代码中分配IP地址。
  • 确保VM安装了VMware工具。您也可以在Ubuntu上安装open-vm-tools软件包。
  • 最后,如果你仍然有问题,你可以检查虚拟机的自定义日志 - 这些可以在操作系统/var/log/vmware-imc/toolsDeployPkg.log上找到。 More info on Linux customization

让我知道这是否解决了你的问题!

+0

感谢您的建议。我会试一试并发布结果。 – ptsw

+1

嗨vancluever,我们尝试将IP分配更改为静态值,尝试删除该部分,并且我们没有更改部署时间。在查看toolsDeployPkg.log中的日志之后,没有与操作相关联的时间戳,使得难以在输出中查看原因。您是否有任何其他建议可以看到内核启动过程和显示登录提示 – ecoles

+0

@ptsw之间发生的问题对于此问题上的无线电沉默,感到抱歉!我只是想提一下,我们今天发布了插件的0.3.0版本,它显着改变了定制和网络服务员的行为,所以你可能想要放弃!另外,如果这些更改都不能解决您的问题,您可能需要完全跳过服务员,现在可以通过设置新的['wait_for_guest_net'](https://www.terraform.io/docs/providers/vsphere /r/virtual_machine.html#wait_for_guest_net)选项设置为“false”。让我知道事情的后续! – vancluever