2017-08-24 113 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