There is a scenario guide -
https://docs.ansible.com/ansible/latest/scenario_guides/vmware_scenarios/scenario_rename_vm.html


On Fri, Aug 9, 2019 at 5:19 PM Abhijeet Kasurde <[email protected]> wrote:

> Are you sure the `uuid` provided is correct uuid (hw_product_uuid in
> vmware guest facts) ?
>
> I am able to rename existing VM using -
>
> ```
> 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
> ```
>
> On Fri, Aug 9, 2019 at 4:58 PM MKPhil <[email protected]> wrote:
>
>>
>> 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?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ansible Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/97366bc1-f0a8-4190-859f-7d96abc26df3%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/97366bc1-f0a8-4190-859f-7d96abc26df3%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Thanks,
> Abhijeet Kasurde
>


-- 
Thanks,
Abhijeet Kasurde

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFwWkHorRd778O94LCC9dbknVUrrKPE4WcFNB6c5ZLYnkdbe-A%40mail.gmail.com.

Reply via email to