community.vmware.vmware_object_rename (4.2.0) — module

Renames VMware objects

Authors: Abhijeet Kasurde (@Akasurde)

Install collection

Install with ansible-galaxy collection install community.vmware:==4.2.0


Add to requirements.yml

  collections:
    - name: community.vmware
      version: 4.2.0

Description

This module can be used to rename VMware objects.

All variables and VMware object names are case sensitive.

Renaming Host and Network is not supported by VMware APIs.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Rename a virtual machine
  community.vmware.vmware_object_rename:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    new_name: Fedora_31
    object_name: Fedora_VM
    object_type: VirtualMachine
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Rename a virtual machine using moid
  community.vmware.vmware_object_rename:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    new_name: Fedora_31
    object_moid: vm-14
    object_type: VirtualMachine
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Rename a datacenter
  community.vmware.vmware_object_rename:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    new_name: Asia_Datacenter
    object_name: dc1
    object_type: Datacenter
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Rename a folder with moid
  community.vmware.vmware_object_rename:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    new_name: backup
    object_moid: group-v46
    object_type: Folder
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Rename a cluster with moid
  community.vmware.vmware_object_rename:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    new_name: CCR_1
    object_moid: domain-c33
    object_type: Cluster
  delegate_to: localhost

Inputs

    
port:
    default: 443
    description:
    - The port number of the vSphere vCenter.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PORT)
      will be used instead.
    type: int

hostname:
    description:
    - The hostname or IP address of the vSphere vCenter server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_HOST)
      will be used instead.
    type: str

new_name:
    aliases:
    - object_new_name
    description:
    - New name for VMware object.
    required: true
    type: str

password:
    aliases:
    - pass
    - pwd
    description:
    - The password of the vSphere vCenter server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PASSWORD)
      will be used instead.
    type: str

protocol:
    choices:
    - http
    - https
    default: https
    description:
    - The connection to protocol.
    type: str

username:
    aliases:
    - admin
    - user
    description:
    - The username of the vSphere vCenter server.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_USER)
      will be used instead.
    type: str

proxy_host:
    description:
    - Address of a proxy that will receive all HTTPS requests and relay them.
    - The format is a hostname or a IP.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PROXY_HOST)
      will be used instead.
    required: false
    type: str

proxy_port:
    description:
    - Port of the HTTP proxy that will receive all HTTPS requests and relay them.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_PROXY_PORT)
      will be used instead.
    required: false
    type: int

object_moid:
    description:
    - Managed object id of the VMware object to work with.
    - Mutually exclusive with O(object_name).
    type: str

object_name:
    description:
    - Name of the object to work with.
    - Mutually exclusive with O(object_moid).
    type: str

object_type:
    choices:
    - ClusterComputeResource
    - Cluster
    - Datacenter
    - Datastore
    - Folder
    - Network
    - ResourcePool
    - VM
    - VirtualMachine
    description:
    - Type of object to work with.
    - Valid options are Cluster, ClusterComputeResource, Datacenter, Datastore, Folder,
      ResourcePool, VM or VirtualMachine.
    required: true
    type: str

validate_certs:
    default: true
    description:
    - Allows connection when SSL certificates are not valid.
    - Set to V(false) when certificates are not trusted.
    - If the value is not specified in the task, the value of environment variable E(VMWARE_VALIDATE_CERTS)
      will be used instead.
    type: bool

Outputs

rename_status:
  description: metadata about VMware object rename operation
  returned: on success
  sample:
    current_name: Fedora_31
    desired_name: Fedora_31
    previous_name: Fedora_VM
  type: dict