rename datastore in vcenter

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

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

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

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

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> napisał:

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”}

"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

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

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

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

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

Hello

In case of gather info there is no mood :frowning:

“properties”: [
“_moId”
],
“proxy_host”: null,
“proxy_port”: null,
“schema”: “vsphere”,
“username”: “root”,
“validate_certs”: false

set facts are not working for me :frowning:

greetings
jon