community.vmware.vmware_vm_storage_policy – Create vSphere storage policies

Note

This plugin is part of the community.vmware collection (version 1.9.0).

To install it use: ansible-galaxy collection install community.vmware.

To use it in a playbook, specify: community.vmware.vmware_vm_storage_policy.

New in version 1.0.0: of community.vmware

Synopsis

  • A vSphere storage policy defines metadata that describes storage requirements for virtual machines and storage capabilities of storage providers.

  • Currently, only tag-based storage policy creation is supported.

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 2.7

  • PyVmomi

Parameters

Parameter Choices/Defaults Comments
description
string
Description of the storage policy to create or update.
This parameter is ignored when state=absent.
hostname
string
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 VMWARE_HOST will be used instead.
Environment variable support added in Ansible 2.6.
name
string / required
Name of the storage policy to create, update, or delete.
password
string
The password of the vSphere vCenter or ESXi server.
If the value is not specified in the task, the value of environment variable VMWARE_PASSWORD will be used instead.
Environment variable support added in Ansible 2.6.

aliases: pass, pwd
port
integer
Default:
443
The port number of the vSphere vCenter or ESXi server.
If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead.
Environment variable support added in Ansible 2.6.
proxy_host
string
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 VMWARE_PROXY_HOST will be used instead.
This feature depends on a version of pyvmomi greater than v6.7.1.2018.12
proxy_port
integer
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 VMWARE_PROXY_PORT will be used instead.
state
string
    Choices:
  • absent
  • present ←
State of storage policy.
If set to present, the storage policy is created.
If set to absent, the storage policy is deleted.
tag_affinity
boolean
    Choices:
  • no
  • yes ←
If set to true, the storage policy enforces that virtual machines require the existence of a tag for datastore placement.
If set to false, the storage policy enforces that virtual machines require the absence of a tag for datastore placement.
This parameter is ignored when state=absent.
tag_category
string
Name of the pre-existing tag category to assign to the storage policy.
This parameter is ignored when state=absent.
This parameter is required when state=present.
tag_name
string
Name of the pre-existing tag to assign to the storage policy.
This parameter is ignored when state=absent.
This parameter is required when state=present.
username
string
The username of the vSphere vCenter or ESXi server.
If the value is not specified in the task, the value of environment variable VMWARE_USER will be used instead.
Environment variable support added in Ansible 2.6.

aliases: admin, user
validate_certs
boolean
    Choices:
  • no
  • yes ←
Allows connection when SSL certificates are not valid. Set to false when certificates are not trusted.
If the value is not specified in the task, the value of environment variable VMWARE_VALIDATE_CERTS will be used instead.
Environment variable support added in Ansible 2.6.
If set to true, please make sure Python >= 2.7.9 is installed on the given machine.

Notes

Note

  • Tested on vSphere 6.5

Examples

- name: Create or update a vSphere tag-based storage policy
  community.vmware.vmware_vm_storage_policy:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    name: "vSphere storage policy"
    description: "vSphere storage performance policy"
    tag_category: "performance_tier"
    tag_name: "gold"
    tag_affinity: true
    state: "present"
  delegate_to: localhost

- name: Remove a vSphere tag-based storage policy
  community.vmware.vmware_vm_storage_policy:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    name: "vSphere storage policy"
    state: "absent"
  delegate_to: localhost

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
vmware_vm_storage_policy
dictionary
success
dictionary of information for the storage policy

Sample:
{'vmware_vm_storage_policy': {'description': 'Storage policy for gold-tier storage', 'id': 'aa6d5a82-1c88-45da-85d3-3d74b91a5bad', 'name': 'gold'}}


Authors

  • Dustin Scott (@scottd018)