# Deploying OVA to a folder in standalone ESXi datastore fails

**URL:** <https://forum.ansible.com/t/deploying-ova-to-a-folder-in-standalone-esxi-datastore-fails/43857>\
**Category:** Get Help\
**Created:** [July 13, 2025, 4:18am UTC](https://forum.ansible.com/t/deploying-ova-to-a-folder-in-standalone-esxi-datastore-fails/43857 "2025-07-13T04:18:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tryllz](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tryllz](https://forum.ansible.com/u/tryllz)\
**Post date:** [July 13, 2025, 4:18am UTC](https://forum.ansible.com/t/deploying-ova-to-a-folder-in-standalone-esxi-datastore-fails/43857/1 "2025-07-13T04:18:39Z")

</div>

Hi,

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

**Inventory**

```auto
[dc:children]
server1

[server1]
eur ansible_host=192.168.9.61

[server1:vars]
dstore1=DC_Disk1_VM

```

**Vars File**

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

```

**Playbook**

```auto
---
- 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**

```auto
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.

```auto
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..

---

<div class="post-metadata">

**Author:** ![jhonnmick](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jhonnmick/32/8975_2.png) [@jhonnmick](https://forum.ansible.com/u/jhonnmick)\
**Post date:** [July 13, 2025, 8:56am UTC](https://forum.ansible.com/t/deploying-ova-to-a-folder-in-standalone-esxi-datastore-fails/43857/2 "2025-07-13T08:56:54Z")

</div>

The error occurs because the folder parameter in vmware[\_](https://calculadoradehoras.io/)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.

---

<div class="post-metadata">

**Author:** ![tryllz](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tryllz](https://forum.ansible.com/u/tryllz)\
**Post date:** [July 13, 2025, 10:09am UTC](https://forum.ansible.com/t/deploying-ova-to-a-folder-in-standalone-esxi-datastore-fails/43857/3 "2025-07-13T10:09:11Z")

</div>

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..

---

<div class="post-metadata">

**Author:** ![tryllz](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@tryllz](https://forum.ansible.com/u/tryllz)\
**Post date:** [July 13, 2025, 7:18pm UTC](https://forum.ansible.com/t/deploying-ova-to-a-folder-in-standalone-esxi-datastore-fails/43857/4 "2025-07-13T19:18:20Z")

</div>

That was the issue, and I resorted to Unregistering the VM, Move the VM folders to where I want to via Shell, and then Re-register the VM in ESXi via `vim-cmd`..

This works as expected but the code is inefficient as I have to write the same code 3 times to work it with 2 different sets of VMs in `vars_eur_vms.yml` file..

**vars\_eur\_vms.yml**

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

vms2:
  - vm_name2: "DC-ADDC"
    isofile2: "[test] Server_2022_x64_VL_20348.1487_Unattended.iso"
  - vm_name2: "DC-GRF"
    isofile2: "[test] Rocky-9.5-x86_64-minimal.iso"

```

**Playbook**

```auto
- name: REGISTE VM
  hosts: eur
  gather_facts: false

  vars:
    vmdirs1: "{{ item.vm_name1 }}"
    vmdirs2: "{{ item.vm_name2 }}"
    vmdirs3: "{{ item.vm_name3 }}"

  vars_files:
    - vars_eur_vms.yml

  tasks:
    - name: REGISTER VM
      ansible.builtin.shell:
        cmd: /bin/vim-cmd solo/registervm /vmfs/volumes/test/VM/"{{ vmdirs1 }}"/"{{ vmdirs1 }}".vmx
      loop: "{{ vms1 }}"
      become: true # Required if moving folders requires root privileges

```

I’m unsure how to loop `vm_name1` in `vms1` and `vm_name2` in `vms2` in the below command without writing the code twice..

```auto
cmd: /bin/vim-cmd solo/registervm /vmfs/volumes/test/VM/"{{ vmdirs1 }}"/"{{ vmdirs1 }}".vmx
loop: "{{ vms1 }}"

```
