community.vmware.vmware_drs_group_manager (4.2.0) — module

Manage VMs and Hosts in DRS group.

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

The module can be used to add VMs / Hosts to or remove them from a DRS group.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
---
- name: Add VMs in an existing DRS VM group
  delegate_to: localhost
  community.vmware.vmware_drs_group_manager:
    hostname: "{{ vcenter_hostname }}"
    password: "{{ vcenter_password }}"
    username: "{{ vcenter_username }}"
    cluster: DC0_C0
    datacenter: DC0
    group_name: TEST_VM_01
    vms:
      - DC0_C0_RP0_VM0
      - DC0_C0_RP0_VM1
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Add Hosts in an existing DRS Host group
  delegate_to: localhost
  community.vmware.vmware_drs_group_manager:
    hostname: "{{ vcenter_hostname }}"
    password: "{{ vcenter_password }}"
    username: "{{ vcenter_username }}"
    cluster: DC0_C0
    datacenter: DC0
    group_name: TEST_HOST_01
    hosts:
      - DC0_C0_H0
      - DC0_C0_H1
      - DC0_C0_H2
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove VM from an existing DRS VM group
  delegate_to: localhost
  community.vmware.vmware_drs_group_manager:
    hostname: "{{ vcenter_hostname }}"
    password: "{{ vcenter_password }}"
    username: "{{ vcenter_username }}"
    cluster: DC0_C0
    datacenter: DC0
    group_name: TEST_VM_01
    vms:
      - DC0_C0_RP0_VM0
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove host from an existing DRS Host group
  delegate_to: localhost
  community.vmware.vmware_drs_group_manager:
    hostname: "{{ vcenter_hostname }}"
    password: "{{ vcenter_password }}"
    username: "{{ vcenter_username }}"
    cluster: DC0_C0
    datacenter: DC0
    group_name: TEST_HOST_01
    hosts:
      - DC0_C0_H0
    state: absent

Inputs

    
vms:
    description:
    - A List of vms to add / remove in the group.
    - Required if O(hosts) is not set.
    - O(hosts) and O(vms) are mutually exclusive parameters.
    elements: str
    required: false
    type: list

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

hosts:
    description:
    - A List of hosts to add / remove in the group.
    - Required if O(vms) is not set.
    - O(hosts) and O(vms) are mutually exclusive parameters.
    elements: str
    required: false
    type: list

state:
    choices:
    - present
    - absent
    default: present
    description:
    - If set to V(present), VMs/hosts will be added to the given DRS group.
    - If set to V(absent), VMs/hosts will be removed from the given DRS group.
    type: str

cluster:
    aliases:
    - cluster_name
    description:
    - Cluster to which DRS group associated with.
    required: true
    type: str

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

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

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

datacenter:
    aliases:
    - datacenter_name
    description:
    - Name of the datacenter.
    required: false
    type: str

group_name:
    description:
    - The name of the group to manage.
    required: true
    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

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

drs_group_member_info:
  description: Metadata about DRS group
  returned: always
  sample:
    Asia-Cluster1:
    - group_name: vm_group_002
      type: vm
      vms:
      - dev-1
  type: dict
msg:
  description: Info message
  returned: always
  sample: Updated host group TEST_HOST_01 successfully
  type: str