community / community.vmware / 4.2.0 / module / vmware_vm_vm_drs_rule Configure VMware DRS Affinity rule for virtual machines in the given cluster Authors: Abhijeet Kasurde (@Akasurde)community.vmware.vmware_vm_vm_drs_rule (4.2.0) — module
Install with ansible-galaxy collection install community.vmware:==4.2.0
collections: - name: community.vmware version: 4.2.0
This module can be used to configure VMware DRS Affinity rule for virtual machines in the given cluster.
- name: Create DRS Affinity Rule for VM-VM community.vmware.vmware_vm_vm_drs_rule: hostname: "{{ esxi_server }}" username: "{{ esxi_username }}" password: "{{ esxi_password }}" cluster_name: "{{ cluster_name }}" vms: - vm1 - vm2 drs_rule_name: vm1-vm2-affinity-rule-001 enabled: true mandatory: true affinity_rule: true delegate_to: localhost
- name: Create DRS Anti-Affinity Rule for VM-VM community.vmware.vmware_vm_vm_drs_rule: hostname: "{{ esxi_server }}" username: "{{ esxi_username }}" password: "{{ esxi_password }}" cluster_name: "{{ cluster_name }}" enabled: true vms: - vm1 - vm2 drs_rule_name: vm1-vm2-affinity-rule-001 mandatory: true affinity_rule: false delegate_to: localhost
- name: Delete DRS Affinity Rule for VM-VM community.vmware.vmware_vm_vm_drs_rule: hostname: "{{ esxi_server }}" username: "{{ esxi_username }}" password: "{{ esxi_password }}" cluster_name: "{{ cluster_name }}" drs_rule_name: vm1-vm2-affinity-rule-001 state: absent delegate_to: localhost
vms: description: - List of virtual machines name for which DRS rule needs to be applied. - Required if O(state=present). elements: str 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 state: choices: - present - absent default: present description: - If set to V(present), then the DRS rule is created if not present. - If set to V(present), then the DRS rule is already present, it updates to the given configurations. - If set to V(absent), then the DRS rule is deleted if present. required: false type: str enabled: default: false description: - If set to V(true), the DRS rule will be enabled. - Effective only if O(state=present). type: bool 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 mandatory: default: false description: - If set to V(true), the DRS rule will be mandatory. - Effective only if O(state=present). type: bool 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 cluster_name: description: - Desired cluster name where virtual machines are present for the DRS rule. required: true type: str affinity_rule: default: true description: - If set to V(true), the DRS rule will be an Affinity rule. - If set to V(false), the DRS rule will be an Anti-Affinity rule. - Effective only if O(state=present). type: bool drs_rule_name: description: - The name of the DRS rule to manage. 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
result: description: metadata about DRS VM and VM rule returned: when state is present sample: rule_enabled: false rule_key: 20 rule_mandatory: true rule_name: drs_rule_0014 rule_uuid: 525f3bc0-253f-825a-418e-2ec93bffc9ae rule_vms: - VM_65 - VM_146 type: dict