Created
March 2, 2021 09:49
-
-
Save Akasurde/68cbe24fa60b5ea9922628e47f048fc2 to your computer and use it in GitHub Desktop.
Rename datastore object using MoID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
gather_facts: no | |
vars_files: | |
- vcenter_vars.yml | |
vars: | |
datastore_name: "DS_117_1" | |
tasks: | |
- 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 | |
- debug: | |
msg: "{{ datastore_moid }}" | |
- community.vmware.vmware_object_rename: | |
new_name: "DS_171_2" | |
object_moid: "{{ datastore_moid }}" | |
object_type: Datastore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment