vmware_guest error: Unable to access the virtual machine configuration: Unable to access file

SUMMARY

When attempting to provision a new vmware VM using the vmware_guest module to VSAN storage, I am getting the following error:

msg": "Failed to create a virtual machine : Unable to access the virtual machine configuration: Unable to access file [some_other_non_vsan_storage_cluster_not_connected_to_ESXI_Cluster] Linux_Base_Template/Linux_Base_Template.vmtx".

Same problem documented in: Ansible Issue: 28649 — I have attempted the fix that is documented there by added a disk section ( see above ) with the datastore variable ( we have many datastores ). The templates live on a separate storage system NOT connected to ESXi Clusters that are configured for VSAN. * This works perfectly by manually cloning via vCenter to the target ESXi Cluster. * This works perfectly if I am provisioning to ESXi clusters that have the "[some_other_non_vsan_storage_cluster_not_connected_to_ESXI_Cluster] " connected to it. * This works perfectly by executing vmware powercli NEW-VM command here is the code for that: https://thesleepyadmins.com/2018/09/08/deploy-multiple-vms-using-powercli-and-vmware-template

Code:


msg": "Failed to create a virtual machine : Unable to access the virtual machine configuration: Unable to access file [some_other_non_vsan_storage_cluster_not_connected_to_ESXI_Cluster] Linux_Base_Template/Linux_Base_Template.vmtx". "invocation": { "module_args": { "name": "TMPBLDLNXLL0001", "hostname": "vCenterServer", "username": "XXXXXXXXXX", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "annotation": "Test VSAN provisioning", "template": "Linux-8_Base_Template", "datacenter": "devnulldc", "folder": "devnulldc/vm/Sandbox", "cluster": "CL-03", "disk": [ { "size_gb": 50, "type": "thin", "datastore": "['vSAN']", "autoselect_datastore": null, "controller_number": null, "controller_type": null, "disk_mode": null, "filename": null, "size": null, "size_kb": null, "size_mb": null, "size_tb": null, "unit_number": null } ], "hardware": { "num_cpus": 2, "memory_mb": 4096, "num_cpu_cores_per_socket": 2, "hotadd_cpu": false, "hotremove_cpu": false, "hotadd_memory": false, "nested_virt": false, "scsi": "paravirtual", "boot_firmware": null, "cpu_limit": null, "cpu_reservation": null, "max_connections": null, "mem_limit": null, "mem_reservation": null, "memory_reservation_lock": null, "secure_boot": null, "version": null, "virt_based_security": null, "iommu": null }, "networks": [ { "name": "BlackholeNet", "type": "static", "ip": "987.65.43.21", "netmask": "255.255.255.0", "gateway": "987.65.43.1", "device_type": "vmxnet3", "dvswitch_name": "vDSwitch", "start_connected": true } *** Truncated ***

** Note obviously I have masked a lot of information ( like IP address, etc ) ***

Forgot to mention I have a issue opened here: vmware_guest error: Unable to access the virtual machine configuration: Unable to access file · Issue #1201 · ansible-collections/community.vmware · GitHub

Did you find a resolution to this by chance?

I just ran into the issue when I changed datastores. I was using a general datastore holding templates but the goal was to use the same datastore of the Content library and use those templates.

“msg”: “Failed to create a virtual machine : Unable to access the virtual machine configuration: Unable to access file [<datastore_name>] W2K19_STD/W2K19_STD.vmtx”}

Thanks.

This sounds like a datastore permissions issue within VMware related to the user ID you are using with the module. When we build our server provisioning workflow we had to create a special user ID for provisioning and grant it specific rights with VMware so it could do the things needed on the proper datastores, create VMs, manage networks, etc.

Walter

Thanks, Walter. I am going to check on this. I too had established a specific service account with all of the necessary rights for vSphere provisioning. It’s quite possible
something was missed regarding the datastore holding the content library.

I did find this issue too which indicates the Python pyvmomi library may not have support for the Content Library.
https://github.com/ansible/ansible/issues/37007

I hope it is a creds issue though.

The “solution” I ended up implementing is a work around. I simply put the template on the VSAN datastore - and named it something like [template]-vsan. And added logic, so that template would be referenced when the vsan datastore was selected. This has been working for me for months now.