vmware.vmware_rest.vcenter_vm_storage_policy module – Manage the storage policies associated with a virtual machine.
Note
This module is part of the vmware.vmware_rest collection (version 5.0.0).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install vmware.vmware_rest.
To use it in a playbook, specify: vmware.vmware_rest.vcenter_vm_storage_policy.
New in vmware.vmware_rest 5.0.0
Synopsis
Update the storage policy configuration of a virtual machine’s home directory and/or its virtual hard disks.
Assign a specific storage policy, or fall back to the default storage policy of the datastore.
Only entities that are supplied are reconfigured; entities left unset retain their current storage policy.
Parameters
Parameter |
Comments |
|---|---|
The storage policies to apply to the virtual machine’s virtual disks. A map keyed by the disk MOID, where each value is a storage policy specification for that disk. Each key must be an identifier (MOID) for the resource type Any disk that is not listed retains its current storage policy. When this option is specified, the module can never be idempotent. A change will always be reported. |
|
Timeout in seconds for the whole operation including connection establishment, request sending, and response. Default: |
|
The desired state of the resource. Use Choices:
|
|
The hostname or IP address of the vSphere vCenter. If the value is not specified in the task, the value of environment variable |
|
The vSphere vCenter password. If the value is not specified in the task, the value of environment variable |
|
The port number of the vSphere vCenter. If the value is not specified in the task, the value of environment variable |
|
Optional path to a log file for HTTP REST interaction. If the value is not specified in the task, the value of environment variable |
|
The vSphere vCenter username. If the value is not specified in the task, the value of environment variable |
|
Allows connection when SSL certificates are not valid. Set to If the value is not specified in the task, the value of environment variable Choices:
|
|
Identifier of the vm to manage. Must be an identifier (MOID) for a |
|
The storage policy to apply to the virtual machine’s home directory. If omitted, the current storage policy of the VM home directory is retained. When this option is specified, the module can never be idempotent. A change will always be reported. |
|
The storage policy to assign to the VM home directory. Only used, and required, when vm_home.type is Must be an identifier (MOID) for the resource type |
|
How to select the storage policy for the VM home directory. Use Use Choices:
|
Notes
Note
Generated from vSphere API spec 9.1.0.
Compatible with vSphere API 7.0.3.
Compatible with vSphere API 8.0.2.
Examples
- name: Look up the VM called test_vm1 in the inventory
register: search_result
vmware.vmware_rest.vcenter_vm_info:
filter_names:
- test_vm1
- name: Assign a specific storage policy to the VM home directory
vmware.vmware_rest.vcenter_vm_storage_policy:
vm: '{{ search_result.value[0].vm }}'
vm_home:
type: USE_SPECIFIED_POLICY
policy: aa6d5a82-1c88-45da-85d3-3d74b91a5bad
state: present
- name: Assign storage policies to the VM home directory and a virtual disk
vmware.vmware_rest.vcenter_vm_storage_policy:
vm: '{{ search_result.value[0].vm }}'
vm_home:
type: USE_DEFAULT_POLICY
disks:
'2000':
type: USE_SPECIFIED_POLICY
policy: aa6d5a82-1c88-45da-85d3-3d74b91a5bad
state: present
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
MOID of the managed virtual machine. Returned: When state is present, or when state is set to a supported action. Sample: |
|
The raw API response body from the vCenter storage policy update operation. Returned: On success Sample: |