Deploying OVA to a folder in standalone ESXi datastore fails

Hi,

I’m trying to deply OVA to a folder in the datastore using Ansible but it fais even though the folder exists.

Inventory

[dc:children]
server1

[server1]
eur ansible_host=192.168.9.61

[server1:vars]
dstore1=DC_Disk1_VM

Vars File

vms1:
  - vm_name1: "DC-EDG-RTR1"
    ovapath1: "/root/VyOS_20250624_0020.ova"
  - vm_name1: "DC-EDG-RTR2"
    ovapath1: "/root/VyOS_20250624_0020.ova"

Playbook

---
- name: Deploy OVA to ESXi host
  hosts: eur
  gather_facts: false

  vars_files:
    - vars_eur_vms.yml

  tasks:
    - name: Deploy OVA
      vmware_deploy_ovf:
        hostname: "{{ ansible_host }}"
        username: "{{ ansible_user }}"
        password: "{{ ansible_password }}"
        datacenter: "ha-datacenter"
        datastore: "{{ dstore1 }}"
        folder: "{{ dstore1 }}/VMS"
        networks:
          "Network 1": "{{ net1 }}"
          "Network 2": "{{ net2 }}"
        ovf: "{{ item.ovapath1 }}"
        name: "{{ item.vm_name1 }}"
        validate_certs: no
      loop: "{{ vms1 }}"
      delegate_to: localhost

Error

failed: [eur -> localhost] (item={'vm_name1': 'DC-EDG-RTR1', 'ovapath1': '/root/VyOS_20250624_0020.ova'}) => {"ansible_loop_var": "item", "changed": false, "item": {"ovapath1": "/root/VyOS_20250624_0020.ova", "vm_name1": "DC-EDG-RTR1"}, "msg": "Unable to find the specified folder DC_Disk1_VM/vm/VMS"}
failed: [eur -> localhost] (item={'vm_name1': 'DC-EDG-RTR2', 'ovapath1': '/root/VyOS_20250624_0020.ova'}) => {"ansible_loop_var": "item", "changed": false, "item": {"ovapath1": "/root/VyOS_20250624_0020.ova", "vm_name1": "DC-EDG-RTR2"}, "msg": "Unable to find the specified folder DC_Disk1_VM/vm/VMS"}

I have tried "[DC_Disk1_VM]/VMS" and ha-datacenter/vm/VMS as well but that too does not work

But a VM deployed to the root of datastore that I attach ISO to form a folder in the same datastore, it works fine.

changed: [eur -> localhost] => (item={'vm_name2': 'DC-VBR', 'isofile2': '[DC_Disk1_VM]/ISO/Server_2022_x64_VL_20348.1487_Unattended.iso'})

Any thoughts what might be the issue here..

The error occurs because the folder parameter in vmware_deploy_ovf refers to the VM folder within the vCenter inventory, not a folder in the datastore. Since you’re using a standalone ESXi host (not vCenter), folders like ha-datacenter/vm/VMS don’t actually exist unless manually created via the vSphere UI. To fix this, either omit the folder parameter or ensure the target folder exists under the host’s inventory structure—not just in the datastore filesystem.

Thanks @jhonnmick

The error occurs because the folder parameter in vmware_deploy_ovf refers to the VM folder within the vCenter inventory, not a folder in the datastore.

Thanks for clsarifying the above, in that case I’ll try to unregister the VM, moves its files to the right directory and re-register it, will see how it goes..