jetbrains-infra / packer-builder-vsphere

Packer plugin for remote builds on VMware vSphere
Mozilla Public License 2.0
542 stars 175 forks source link

Build 'vsphere-iso' errored: error creating vm: host '' not found #295

Open mashiutz opened 4 years ago

mashiutz commented 4 years ago

Hello There :) Im trying to build a new Windows template (using latest version - 2.3). We have a Cluster with DRS Enabled, so im only specifying a Cluster in my Json. If im also specifying a Resource Pool, i'm getting the same error. Through vSphere web UI, i have made sure that the cluster do no reside in any folder. vSphere version is 6.7 Im using the following json file :

`{ "builders": [ { "type": "vsphere-iso",

    "vcenter_server":       "vcenter.domain.net",
    "insecure_connection":  "false",
    "username":             "superman@vsphere.local",
    "password":             "adminpass",
    "datacenter":           "Datacenter-IT",
    "Cluster":              "IT-256GB",
    "datastore":            "VMFS_ISO",

    "communicator":         "winrm",
    "winrm_username":       "theadmin",
    "winrm_password":       "theadminPass",

    "vm_name":              "TEMPLATE-2019",
    "folder":               "WinTemplate-IT",
    "convert_to_template":  "true",
    "cpus":                 "2",
    "cpu_cores":            "1",
    "ram":                  "4096",
    "network_card":         "vmxnet3",
    "disk_controller_type": "lsilogic-sas",
      "guest_os_type":        "windows9Server64Guest",
    "disk_thin_provisioned": false,
    "disk_size":            "71680",
      "iso_paths": [
      "[VMFS_ISO] Windows-ISO/SW_DVD9_Win_Server_STD_CORE_2019_1809.1_64Bit_English_DC_STD_MLF_X22-02970.ISO",
      "[VMFS_ISO] VM Tools 10.1.0/vmtools/VMTools 10.1.0-windows.iso"
    ],
    "floppy_files": [
      "floppy/autounattend.xml",
      "floppy/setup.ps1",
      "floppy/vmtools.cmd"
    ]

  }
]

}`

Many thanks!

danonh commented 4 years ago

Can you confirm that superman@vsphere.local has a proper rights to create VMs on hosts within the cluster? Most people define cluster level permissions without propagate checkbox enabled.If you login to vsphere using superman@vsphere.local can you create VMs on IT-256GB cluster?

mashiutz commented 4 years ago

Yep, i have just logged in with that user and created a VM in the cluster. Maybe there are some special permissions that are needed? The API logs on the VCenter server show nothing :(

mashiutz commented 4 years ago

@mkuzmin please, maybe some input?

danonh commented 4 years ago

@mkuzmin will not respond as he is not involved in vsphere packer builder project anymore. Try to change value for insecure_connection to true, also remove cpu_cores value for testing purposes.

danonh commented 4 years ago

also if above will not solve your problem, could you try use builder from fallowing link? https://teamcity.jetbrains.com/viewLog.html?buildId=2529292&buildTypeId=PackerVSphere_Build&tab=artifacts

mashiutz commented 4 years ago

Thank you very much! I'll update you. are you involved with the project now?

danonh commented 4 years ago

I'm not involved with the project, but same as you I use vsphere-iso and vsphere-clones builders provided by jetbrains. I use it successfully on vSphere 6.7 although some updates for the builder would be advised. More info about @mkuzmin involvement into this project can be found here: https://github.com/hashicorp/packer/pull/7168

mashiutz commented 4 years ago

First, thank you for your help :) I have tried your suggestions above, but I’m getting the same results. Hope someone has more input on this.

danonh commented 4 years ago

Everything looks good with your template file. I would assume it's a vSphere permission issue, although you said you have checked that already. Can you give superman@vsphere.local full administrator rights to your vCenter server for testing purposes (if you work on production environment better don't do that)? If not, check permissions on WinTemplate-IT folder and on your vswitch/dvswitch, for superman@vsphere.local. I had similar problem yesterday when someone took my permissions off from my esxi host (I used it in non-clustered environment). Take a look here for permissions settings: https://github.com/jetbrains-infra/packer-builder-vsphere/issues/97

lbonilla68 commented 4 years ago

What gets people a lot times is when their cluster is in a folder structure. If it is then you need to provide the full path for example "FolderName/ClusterName". I use the same structure for the vm_folder field. Hope that helps.

jasonwilliams14 commented 4 years ago

@nslracer I've been running into this issue today. 2 node esxi cluster, and am running vcenter as a VM on one of the nodes. Still cant seem to get passed the issue (running DRS BTW). Driving me a bit mad. Could vcenter as VM on one of the nodes be an issue? SO close, but cant seem to figure out this same error:

This is specifying a resource pool:

`vsphere-iso output will be in this color.

==> vsphere-iso: Creating VM... Build 'vsphere-iso' errored: error creating vm: resource pool 'Arkham Asylum/Resources/deployments' not found

==> Some builds didn't complete successfully and had errors: --> vsphere-iso: error creating vm: resource pool 'Arkham Asylum/Resources/deployments' not found`

this is NOT specifying a resource pool:

`==> vsphere-iso: Creating VM... Build 'vsphere-iso' errored: error creating vm: resource pool 'Arkham Asylum/Resources/' not found

==> Some builds didn't complete successfully and had errors: --> vsphere-iso: error creating vm: resource pool 'Arkham Asylum/Resources/' not found

==> Builds finished but no artifacts were created. `

any ideas? thx

lbonilla68 commented 4 years ago

@jasonwilliams14 - I also run a 2 node ESXi cluster with vCenter as one of the VM's so I know for sure that's not your issue.

I believe the issue might be the space in your resource names. The builder just does not handle spaces well in the datacenter, cluster, folder and resource pool fields. If it's an option I would remove all spaces on your VMware object names (Cluster, Datacenter, folders, etc), update your code and try again.

jasonwilliams14 commented 4 years ago

@nslracer I will give that a shot. Thx

lbonilla68 commented 4 years ago

@jasonwilliams14 Any luck?

jasonwilliams14 commented 4 years ago

@nslracer heya...was going to respond today. I did get it working. i cleaned up the naming convention with no spaces and that seemed to be the issue. Now I can pull ubuntu/debian and centos images just fine now with my setup. Much appreciated!

lbonilla68 commented 4 years ago

@jasonwilliams14 Nice!!

mashiutz commented 4 years ago

Hi everyone Involved, I know its been a while... I'm still getting the same result: Build 'vsphere-iso' errored: error creating vm: host '' not found. My resource pool's does not have any spaces in their names, only dashes. I'm using the latest version of Packer which is currently 1.5.4. I know that the vsphere-iso builder was integrated into packer.exe. Still no luck. Any take on this? Should I file an issue on the official Packer GitHub? Thanks again :)

codefox42 commented 4 years ago

I can also reproduce this issue with Packer 1.5.4 and vSphere 6.7 (having a cluster name containing a dash in the middle).

Yornik commented 4 years ago

Can confirm on Packer 1.5.4 with a cluster name with 2 dashes

codefox42 commented 4 years ago

Removing the dash from the cluster name did not change the behavior for our system:

Build 'vsphere-iso' errored: error creating vm: host '' not found

Probably some other aspect is causing this error.

mashiutz commented 4 years ago

Have anyone found a way around this issue? Do you know if this will get fixed in the next version? I'll open an issue on the official Packer GitHub as well

lbonilla68 commented 4 years ago

See if the answer on this thread will help

https://github.com/jetbrains-infra/packer-builder-vsphere/issues/285#issuecomment-589819250

pisaniej commented 2 years ago

For future reference, if anyone here has a / in their network, you'll need to escape it with%2f ...semi-related