josenk / terraform-provider-esxi

Terraform-provider-esxi plugin
GNU General Public License v3.0
544 stars 154 forks source link

Error: Failed to register guest:Process exited with status 1 #77

Closed andrewm659 closed 4 years ago

andrewm659 commented 5 years ago

I am trying to create test VMs on ESXi 6.5.0 using Terraform 0.12.

I am getting the following error: [andrew.meyer@automation01 esxi]$ terraform apply

An execution plan has been generated and is shown below. Resource actions are indicated with the following symbols:

Terraform will perform the following actions:

esxi_guest.vmtest will be created + resource "esxi_guest" "vmtest" { + boot_disk_size = "50" + boot_disk_type = "thin" + disk_store = "datastore-nas" + guest_name = "vmtest" + guest_shutdown_timeout = (known after apply) + guest_startup_timeout = (known after apply) + guestos = "centos7_64Guest" + id = (known after apply) + ip_address = (known after apply) + memsize = "2048" + notes = (known after apply) + numvcpus = "1" + power = "on" + resource_pool_name = "ha-root-pool" + virthwver = "13"

+ network_interfaces { + mac_address = (known after apply) + nic_type = "vmxnet3" + virtual_network = "prod" } }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.

Enter a value: yes

esxi_guest.vmtest: Creating...

Error: Failed to register guest:Process exited with status 1

on main.tf line 31, in resource "esxi_guest" "vmtest": 31: resource "esxi_guest" "vmtest" {

[andrew.meyer@automation01 esxi]$ `

Here is my main.tf

terraform { required_version = ">= 0.12" }

############################################## # VARIABLES ##############################################

variable "esxi_hostname" {} variable "esxi_hostport" {} variable "esxi_username" {} variable "esxi_password" {} variable "esxi_datastore" {} variable "esxi_resource_pool_name" {} #variable "esxi_guest_name" {} variable "esxi_virtual_network" {} variable "esxi_nic_type" {} variable "esxi_virtual_disk_size" {} variable "esxi_virtual_disk_disk_store" {} variable "esxi_boot_disk_size" {} variable "esxi_disk_store" {} variable "esxi_virtual_disk_dir" {}`

provider "esxi" { esxi_hostname = var.esxi_hostname esxi_hostport = var.esxi_hostport esxi_username = var.esxi_username esxi_password = var.esxi_password }

resource "esxi_guest" "vmtest" { resource_pool_name = var.esxi_resource_pool_name guest_name = "vmtest" disk_store = var.esxi_disk_store numvcpus = "1" memsize = "2048" guestos = "centos7_64Guest" boot_disk_type = "thin" boot_disk_size = var.esxi_boot_disk_size virthwver = "13" power = "on" # # Specify an existing guest to clone, an ovf source, or neither to build a bare-metal guest vm. # #clone_from_vm = "Templates/centos7" #ovf_source = "/local_path/centos-7.vmx"

network_interfaces { virtual_network = var.esxi_virtual_network nic_type = var.esxi_nic_type } }

#https://github.com/josenk/terraform-provider-esxi/wiki/How-to-import #resource "esxi_resource_pool" "MyPool" { # # To be imported #}

#resource "esxi_guest" "MyVM" { # # To be imported #}

#resource "esxi_virtual_disk" "vdisk1" { # virtual_disk_size = var.esxi_virtual_disk_size # virtual_disk_disk_store = var.esxi_virtual_disk_disk_store # virtual_disk_dir = var.esxi_virtual_disk_dir #}

Here is my terrafrom.tfvars esxi_hostname = "10.150.1.35" esxi_hostport = "22" esxi_username = "root" esxi_password = "password" esxi_datastore = "datastore-nas" esxi_resource_pool_name = "ha-root-pool" #esxi_guest_name = "" esxi_virtual_network = "prod" esxi_nic_type = "vmxnet3" esxi_boot_disk_size= "50" esxi_disk_store = "datastore-nas" esxi_virtual_disk_disk_store = "datastore-nas" esxi_virtual_disk_size = "50" esxi_virtual_disk_dir = "/vmfs/volumes/"

Here is the output from /var/log/hostd.log on vmware esxi 6.5.0

2019-10-29T20:13:25.831Z verbose hostd[DF81B70] [Originator@6876 sub=PropertyProvider opID=vim-cmd-8b-d9cd user=dcui] RecordOp ASSIGN: info, haTask--vim.SessionManager.logout-174352053. Applied change to temp map.

2019-10-29T20:13:25.831Z verbose hostd[DF81B70] [Originator@6876 sub=PropertyProvider opID=vim-cmd-8b-d9cd user=dcui] RecordOp REMOVE: sessionList["52d31faa-11b1-d377-2b9d-c451bfd772e2"], ha-sessionmgr. Applied change to temp map.

2019-10-29T20:13:25.831Z verbose hostd[DF81B70] [Originator@6876 sub=PropertyProvider opID=vim-cmd-8b-d9cd user=dcui] RecordOp ASSIGN: latestEvent, ha-eventmgr. Applied change to temp map.

2019-10-29T20:13:25.831Z info hostd[DF81B70] [Originator@6876 sub=Vimsvc.ha-eventmgr opID=vim-cmd-8b-d9cd user=dcui] Event 558 : User dcui@127.0.0.1 logged out (login time: Tuesday, 29 October, 2019 20:13:25, number of API invocations: 0, user agent: VMware-client/6.5.0)

2019-10-29T20:13:25.831Z verbose hostd[DF81B70] [Originator@6876 sub=PropertyProvider opID=vim-cmd-8b-d9cd user=dcui] RecordOp ASSIGN: info, haTask--vim.SessionManager.logout-174352053. Applied change to temp map. Accepted password for user dcui from 127.0.0.1

2019-10-29T20:13:28.332Z info hostd[E540B70] [Originator@6876 sub=Vimsvc.ha-eventmgr opID=vim-cmd-f2-d9d1] Event 559 : User dcui@127.0.0.1 logged in as VMware-client/6.5.0

2019-10-29T20:13:28.334Z info hostd[DFC2B70] [Originator@6876 sub=Vimsvc.TaskManager opID=vim-cmd-f2-d9d2 user=dcui] Task Created : haTask-ha-folder-vm-vim.Folder.registerVm-174352054

2019-10-29T20:13:28.334Z verbose hostd[DFC2B70] [Originator@6876 sub=PropertyProvider opID=vim-cmd-f2-d9d2 user=dcui] RecordOp ADD: recentTask["haTask-ha-folder-vm-vim.Folder.registerVm-174352054"], ha-folder-vm. Sent notification immediately.

2019-10-29T20:13:28.334Z verbose hostd[DFC2B70] [Originator@6876 sub=PropertyProvider opID=vim-cmd-f2-d9d2 user=dcui] RecordOp ADD: recentTask["haTask-ha-folder-vm-vim.Folder.registerVm-174352054"], ha-taskmgr. Applied change to temp map.

2019-10-29T20:13:28.334Z verbose hostd[ABF2B80] [Originator@6876 sub=PropertyProvider opID=vim-cmd-f2-d9d2 user=dcui] RecordOp ASSIGN: info, haTask-ha-folder-vm-vim.Folder.registerVm-174352054. Applied change to temp map.

2019-10-29T20:13:28.334Z info hostd[ABF2B80] [Originator@6876 sub=Solo.HaVMFolder opID=vim-cmd-f2-d9d2 user=dcui] Register called: []/vmfs/volumes/datastore-nas/vmtest/vmtest.vmx

2019-10-29T20:13:28.570Z error hostd[ABF2B80] [Originator@6876 sub=Vmsvc.VMFileChecker opID=vim-cmd-f2-d9d2 user=dcui] Unable to stat VM config file '/vmfs/volumes/datastore-nas/vmtest/vmtest.vmx'. Error code 2: 'No such file or directory'

2019-10-29T20:13:28.570Z warning hostd[ABF2B80] [Originator@6876 sub=Vmsvc opID=vim-cmd-f2-d9d2 user=dcui] RegisterVm file check error: IO error: Unable to stat VM config file '/vmfs/volumes/datastore-nas/vmtest/vmtest.vmx'. Error code 2: 'No such file or directory'

2019-10-29T20:13:28.577Z info hostd[ABF2B80] [Originator@6876 sub=Default opID=vim-cmd-f2-d9d2 user=dcui] AdapterServer caught exception: vim.fault.NotFound ` Not sure what I am doing wrong.

hieunba commented 5 years ago

Can you check your datastore? Is this /vmfs/volumes/datastore-nas available?

andrewm659 commented 5 years ago

I use this datastore daily.

andrewm659 commented 5 years ago

I have also tried the actual path that vmware gives. Same thing.

andrewm659 commented 5 years ago

It seems to continue to complain about the resource name....

josenk commented 5 years ago

I think the problem is with your virtual_disk_dir a path? Did you refer to the example? It should simply be a subdirectory . "/vmfs/volumes/" will automatically be added.

https://github.com/josenk/terraform-provider-esxi/blob/master/examples/03%20Resource%20Pools%20-%20Additional%20Storage/main.tf#L46

replay111 commented 5 years ago

Hi, I have same problem:

esxi_guest.valar: Creating...

Error: Failed to register guest:Process exited with status 1

  on main.tf line 26, in resource "esxi_guest" "valar":
  26: resource "esxi_guest" "valar" {

my tf file:

resource "esxi_guest" "valar" {
  guest_name = "valar" 
  disk_store = "LOCAL_STORAGE"
  memsize = "2048"
  power = "off"
  network_interfaces {
    virtual_network = "VM Network" 
  }
}

Esxi: 6.5 terraform -v Terraform v0.12.10

josenk commented 5 years ago

You'll need to do a bit of debugging first... You may need to look at the esxi logs to see why it failed.

Is this your first attempt to use this plugin?

replay111 commented 5 years ago

Yes - I am totally new ;-)

replay111 commented 5 years ago

Can I create VM without any template? In logs in ESXi I can see entry like this:

Unable to stat VM config file '/vmfs/volumes/LOCAL_STORAGE/valar/valar.vmx'. Error code 2: 'No such file or directory'

Path /vmfs/volumes/LOCAL_STORAGE exists and manually I can create and remove folders and files on it.

josenk commented 5 years ago

Does /vmfs/volumes/LOCAL_STORAGE/valar exist?

Do you get any error if you run this command? If you do, you need to "fix" them. Sometimes there are vm's that are "partially" built. The bad vms need to be manually unregistered and sometimes a reboot is required.

$ vim-cmd vmsvc/getallvms

Do you get any error if you run these commands. Please update this thread the the output of the commands.

$ esxcli storage filesystem list $ df -h

replay111 commented 5 years ago
vim-cmd vmsvc/getallvms

result:

Vmid   Name   File   Guest OS   Version   Annotation
esxcli storage filesystem list

result:

Mount Point                                        Volume Name    UUID                                 Mounted  Type            Size          Free
-------------------------------------------------  -------------  -----------------------------------  -------  ------  ------------  ------------
/vmfs/volumes/5dbe0cb1-5329c262-68fd-b8ca3ad50a84  LOCAL_STORAGE  5dbe0cb1-5329c262-68fd-b8ca3ad50a84     true  VMFS-5  471909531648  470888218624
josenk commented 5 years ago

I found the problem... There was an introduced bug when creating bare-metal VM's in the last release (1.5.2). A work-around is to install one of the older versions (1.5.1 or earlier).

This will be fixed in the next release.

replay111 commented 5 years ago

THIS IS OUTSTANDING!!! ;-)

replay111 commented 5 years ago

Now I have to figure out how to set proper guest os and other staff but VM is created (without template) - this is awesome!

Thank you!

josenk commented 5 years ago

The README.md has the resource configuration reference. To set the guest os type, the configuration item is "guestos". Set it to whatever type you need.

Some more basic information on guest os types.

https://github.com/josenk/vagrant-vmware-esxi/wiki/VMware-ESXi-6.5-guestOS-types

replay111 commented 5 years ago

Yes - I've found that and I tune-up a little my start config - thanks a lot for your help!

josenk commented 5 years ago

Should be fixed in latest.

https://github.com/josenk/terraform-provider-esxi/releases/tag/v1.5.3

replay111 commented 4 years ago

Yes - confirmed - works like a charm... at least creating/destroying VM ;-)

replay111 commented 4 years ago

One thing - those parameters are not setting proper guest os on new created machine:

guestos = "centos7-64"
guestos = "centos7"

or maybe I am setting something in wrong way (but terraform plan shows guest os set by me)

replay111 commented 4 years ago

ok - this does the job: guestos = "centos-64"

I think this issue can be closed ;-)