rename datastore in vcenter

173 views
Skip to first unread message

Jon POK

unread,
Feb 23, 2021, 2:00:45 AM2/23/21
to Ansible Project
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

Dick Visser

unread,
Feb 23, 2021, 3:43:13 AM2/23/21
to ansible...@googlegroups.com
What exactly does "its not working" mean?
Errors, etc?

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/fe60adee-e575-44bc-8323-665d49949d50n%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Abhijeet Kasurde

unread,
Feb 23, 2021, 3:50:26 AM2/23/21
to ansible...@googlegroups.com
Please read as "There is **no** option" instead of "There is option".

On Tue, Feb 23, 2021 at 2:19 PM Abhijeet Kasurde <akas...@redhat.com> wrote:
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



--
Thanks,
Abhijeet Kasurde

Abhijeet Kasurde

unread,
Feb 23, 2021, 3:51:12 AM2/23/21
to ansible...@googlegroups.com
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

On Tue, Feb 23, 2021 at 2:13 PM Dick Visser <dick....@geant.org> wrote:


--
Thanks,
Abhijeet Kasurde

Jon POK

unread,
Mar 1, 2021, 2:44:29 AM3/1/21
to ansible...@googlegroups.com
Hello

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

Jon POK

unread,
Mar 1, 2021, 4:37:02 AM3/1/21
to ansible...@googlegroups.com
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"}

Dick Visser

unread,
Mar 1, 2021, 6:46:13 AM3/1/21
to ansible...@googlegroups.com
"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
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAMRMTZVz3Ho2agxhf033D9ZMjbsC9MTaQuA1MgijCH1s6uh5MA%40mail.gmail.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Jon POK

unread,
Mar 1, 2021, 7:09:34 AM3/1/21
to ansible...@googlegroups.com
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

Jon POK

unread,
Mar 1, 2021, 7:44:27 AM3/1/21
to Ansible Project
Maybe stupid qiestion object_moid where I can find it? it seems that rename object without this var wont work
greetings Piotr

Abhijeet Kasurde

unread,
Mar 2, 2021, 12:21:45 AM3/2/21
to ansible...@googlegroups.com
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



--
Thanks,
Abhijeet Kasurde

Jon POK

unread,
Mar 2, 2021, 3:19:44 AM3/2/21
to ansible...@googlegroups.com
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


Jon POK

unread,
Mar 2, 2021, 3:58:07 AM3/2/21
to ansible...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages