# Cannot rename VM with vmware\_guest

**URL:** <https://forum.ansible.com/t/cannot-rename-vm-with-vmware-guest/31002>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [August 9, 2019, 11:27am UTC](https://forum.ansible.com/t/cannot-rename-vm-with-vmware-guest/31002 "2019-08-09T11:27:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MKPhil](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@MKPhil](https://forum.ansible.com/u/MKPhil)\
**Post date:** [August 9, 2019, 11:27am UTC](https://forum.ansible.com/t/cannot-rename-vm-with-vmware-guest/31002/1 "2019-08-09T11:27:53Z")

</div>

According to [https://docs.ansible.com/ansible/latest/modules/vmware\_guest\_module.html](https://docs.ansible.com/ansible/latest/modules/vmware_guest_module.html#vmware-guest-module) I can rename a VM with Ansible by using:

> - name: Rename a virtual machine (requires the virtual machine’s uuid)  
> vmware\_guest:  
> hostname: “{{ vcenter\_hostname }}”  
> username: “{{ vcenter\_username }}”  
> password: “{{ vcenter\_password }}”  
> validate\_certs: no  
> uuid: “{{ vm\_uuid }}”  
> name: new\_name  
> state: present  
> delegate\_to: localhost

However, when I try this (Ansible 2.8.2) it complains about a missing folder and datacenter parameter. If those are supplied, the error then says

Unable to find the datastore with given parameters. This could mean, new\_name is a non-existent virtual machine and module tried to deploy it as new virtual machine with no disk. Please specify disks parameter or specify template to clone from.

Any thoughts? Is the documentation wrong?

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [August 9, 2019, 11:49am UTC](https://forum.ansible.com/t/cannot-rename-vm-with-vmware-guest/31002/2 "2019-08-09T11:49:07Z")

</div>

Are you sure the `uuid` provided is correct uuid (hw\_product\_uuid in vmware guest facts) ?

I am able to rename existing VM using -

```auto

tasks:
- name: Gather facts about datastore
vmware_vm_facts:
hostname: "{{ vcenter_server }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
validate_certs: no
folder: "{{ folder }}"
delegate_to: localhost
register: vm_facts

- set_fact:
vm_uuid: "{{ item.uuid }}"
with_items:
- "{{ vm_facts.virtual_machines | json_query(query) }}"
vars:
query: "[?guest_name=='test_00']"

- vmware_guest:
hostname: "{{ vcenter_server }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
validate_certs: no
folder: "{{ folder }}"
uuid: "{{ vm_uuid }}"
name: "test_01"
state: present

```

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [August 9, 2019, 11:53am UTC](https://forum.ansible.com/t/cannot-rename-vm-with-vmware-guest/31002/3 "2019-08-09T11:53:38Z")

</div>

There is a scenario guide - [https://docs.ansible.com/ansible/latest/scenario\_guides/vmware\_scenarios/scenario\_rename\_vm.html](https://docs.ansible.com/ansible/latest/scenario_guides/vmware_scenarios/scenario_rename_vm.html)
