# rename datastore in vcenter

**URL:** <https://forum.ansible.com/t/rename-datastore-in-vcenter/34670>\
**Category:** Ansible Project\
**Created:** [February 23, 2021, 7:00am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670 "2021-02-23T07:00:44Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_POK](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@Jon\_POK](https://forum.ansible.com/u/Jon_POK)\
**Post date:** [February 23, 2021, 7:00am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/1 "2021-02-23T07:00:44Z")

</div>

Hello

I am trying to execute this task

- name: Rename Datastores on ESXi host vmware\_host\_datastore:  
hostname: ‘{{ vcenter\_hostname }}’  
username: ‘{{ vcenter\_username }}’  
password: ‘{{ vcenter\_password }}’  
datacenter\_name: ‘{{ datacenter }}’  
datastore\_name: datastore(1)  
rename: new\_datastore\_1  
esxi\_hostname: ‘{{ inventory\_hostname }}’ state: present

but is not working  
Has anybody try this and knows how to fix it?

Piotr

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [February 23, 2021, 8:42am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/2 "2021-02-23T08:42:48Z")

</div>

What exactly does “its not working” mean?  
Errors, etc?

---

<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:** [February 23, 2021, 8:49am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/3 "2021-02-23T08:49:19Z")

</div>

There is option ‘rename’ in vmware\_host\_datastore. If you want to rename an object in VMware please use `vmware_object_rename` module. - [https://github.com/ansible-collections/community.vmware/blob/main/plugins/modules/vmware\_object\_rename.py](https://github.com/ansible-collections/community.vmware/blob/main/plugins/modules/vmware_object_rename.py)

---

<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:** [February 23, 2021, 8:49am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/4 "2021-02-23T08:49:56Z")

</div>

Please read as “There is **no** option” instead of “There is option”.

---

<div class="post-metadata">

**Author:** ![Jon\_POK](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@Jon\_POK](https://forum.ansible.com/u/Jon_POK)\
**Post date:** [March 1, 2021, 7:44am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/5 "2021-03-01T07:44:06Z")

</div>

Hello

After execution datastore is not changed.  
Today i will paste error from -vvv execution

wt., 23 lut 2021, 09:43 użytkownik Dick Visser \<[dick.visser@geant.org](mailto:dick.visser@geant.org)\> napisał:

---

<div class="post-metadata">

**Author:** ![Jon\_POK](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@Jon\_POK](https://forum.ansible.com/u/Jon_POK)\
**Post date:** [March 1, 2021, 9:36am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/6 "2021-03-01T09:36:38Z")

</div>

the problem is that rename var is not recognized via module. Is it possible that module is not valid or has changed name

fatal: [localhost]: FAILED! =\> {“changed”: false, “msg”: “Unsupported parameters for (vmware\_host\_datastore) module: datacener\_name, rename Supported parameters include: datastore\_name, datastore\_type, esxi\_hostname, hostname, nfs\_path, nfs\_ro, nfs\_server, password, port, proxy\_host, proxy\_port, state, username, validate\_certs, vmfs\_device\_name, vmfs\_version”}

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [March 1, 2021, 11:45am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/7 "2021-03-01T11:45:49Z")

</div>

"datacener\_name" looks like a typo

But, as Abhijeet Kasurde already explained:

> If you want to rename an object in VMware please use `vmware_object_rename` module.

[https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware\_object\_rename\_module.html](https://docs.ansible.com/ansible/latest/collections/community/vmware/vmware_object_rename_module.html)

---

<div class="post-metadata">

**Author:** ![Jon\_POK](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@Jon\_POK](https://forum.ansible.com/u/Jon_POK)\
**Post date:** [March 1, 2021, 12:09pm UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/8 "2021-03-01T12:09:08Z")

</div>

Hello

Thanks for hint but is not working only in vcenter ? I would like to rename datastore on esxi host level  
Anyway I will check it thx

---

<div class="post-metadata">

**Author:** ![Jon\_POK](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@Jon\_POK](https://forum.ansible.com/u/Jon_POK)\
**Post date:** [March 1, 2021, 12:44pm UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/9 "2021-03-01T12:44:27Z")

</div>

Maybe stupid qiestion object\_moid where I can find it? it seems that rename object without this var wont work  
greetings Piotr

---

<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:** [March 2, 2021, 5:21am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/10 "2021-03-02T05:21:10Z")

</div>

Hi Piotr,

You can directly use names to rename the object like in your case datastore

- community.vmware.vmware\_object\_rename:  
new\_name: “DS\_117\_1”  
object\_name: “ds\_171\_2”  
object\_type: Datastore

You can gather information about Managed object id for the datastore using vmware\_datastore\_info as below

- name: Provide information about datastore {{ datastore\_name }}  
community.vmware.vmware\_datastore\_info:  
datacenter: Asia-Datacenter1  
name: “{{ datastore\_name }}”  
properties:

- \_moId  
schema: vsphere  
delegate\_to: localhost  
register: datastore\_info

- set\_fact:  
datastore\_moid: “{{ datastore\_info.datastores[0][‘moid’] }}”  
when: datastore\_info.datastores[0][‘moid’] is defined

---

<div class="post-metadata">

**Author:** ![Jon\_POK](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@Jon\_POK](https://forum.ansible.com/u/Jon_POK)\
**Post date:** [March 2, 2021, 8:19am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/11 "2021-03-02T08:19:17Z")

</div>

Hello

Directly is not working  
TASK [Rename object name] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [localhost]: FAILED! =\> {“changed”: false, “msg”: “Unsupported parameters for (community.vmware.vmware\_object\_rename) module: esxi\_hostname Supported parameters include: hostname, new\_name, object\_moid, object\_name, object\_type, password, port, protocol, username, validate\_certs”}

I will check if with mood is working but is does not make sense to run info copy mood paste manually to another playbook and rename datastore:(

greetings  
Jon

---

<div class="post-metadata">

**Author:** ![Jon\_POK](https://avatars.discourse-cdn.com/v4/letter/j/b487fb/32.png) [@Jon\_POK](https://forum.ansible.com/u/Jon_POK)\
**Post date:** [March 2, 2021, 8:57am UTC](https://forum.ansible.com/t/rename-datastore-in-vcenter/34670/12 "2021-03-02T08:57:41Z")

</div>

Hello

In case of gather info there is no mood ☹

“properties”: [  
“\_moId”  
],  
“proxy\_host”: null,  
“proxy\_port”: null,  
“schema”: “vsphere”,  
“username”: “root”,  
“validate\_certs”: false

set facts are not working for me ☹

greetings  
jon
