vmware.vmware_rest.vcenter_ovf_libraryitem module – Manage OVF packages in vCenter content libraries.

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_ovf_libraryitem.

New in vmware.vmware_rest 5.0.0

Synopsis

  • Create, deploy, and inspect OVF packages stored in VMware vCenter content libraries.

  • Use state=present to export a virtual machine or virtual appliance as an OVF package into a content library item.

  • Use state=deploy to deploy an OVF package from a content library item into a new virtual machine or virtual appliance on a target resource pool.

  • Use state=filter to retrieve deployment information from an OVF package, such as network and storage requirements, EULAs, and additional parameters needed before deploying.

Parameters

Parameter

Comments

create_spec

dictionary

Specification for creating the OVF package in the content library.

Allows overriding the name and description stored in the OVF descriptor.

Only used when state=present.

description

string

Description to use in the OVF descriptor stored in the library item.

If omitted, the server will use source’s current annotation.

flags

list / elements=string

Flags to use for OVF package creation.

If omitted, no flags will be used.

library_item_source_id

string

MOID of a source library item used for image identification.

This property was added in __vSphere API 9.1.0.0__.

If omitted, no source identifier will be used.

name

string

Name to use in the OVF descriptor stored in the library item.

If omitted, the server will use source’s current name.

deployment_spec

dictionary

Specification controlling how an OVF package is deployed to a resource pool.

Includes settings for naming, networking, storage, and EULA acceptance.

Only used when state=deploy.

accept_all_eula

boolean / required

Whether to accept all End User License Agreements included in the OVF package.

Use state=filter to retrieve the EULAs before deploying.

Choices:

  • false

  • true

additional_parameters

list / elements=dictionary

Additional OVF parameters that may be needed for the deployment.

These parameters may be required by the OVF descriptor of the OVF package. Use state=filter to discover which additional parameters are available.

Examples include deployment options, extra config, IP allocation, OVF properties, scale out, and vCenter extension parameters.

If omitted, the server will choose default settings for all parameters necessary for the deploy operation.

type

string

Unique identifier describing the type of the OVF parameters. The value is the name of the OVF parameters schema.

This property must be provided in the input parameters when deploying an OVF package. This property will always be present in the result when retrieving information about an OVF package.

annotation

string

Annotation assigned to the deployed target virtual machine or virtual appliance.

If omitted, the server will use the annotation from the OVF package.

default_datastore_id

string

MOID of the default datastore to use for all storage sections in the OVF descriptor.

If omitted, the server will choose the default datastore.

flags

list / elements=string

Flags to use for deployment.

If omitted, no flags will be used.

locale

string

The locale to use for parsing the OVF descriptor.

If omitted, the server locale will be used.

name

string

Name assigned to the deployed target virtual machine or virtual appliance.

If omitted, the server will use the name from the OVF package.

network_mappings

dictionary

Mapping of OVF network names to vCenter network MOIDs.

The key is the network name from the OVF descriptor and the value is the MOID of the target vCenter network.

If omitted, the server will choose a network mapping.

storage_mappings

dictionary

Mapping of OVF storage group names to target storage specifications.

The key is the storage group name from the OVF descriptor and the value is the target storage specification.

If omitted, the server will choose a storage mapping.

storage_profile_id

string

MOID of the default storage profile to use for all storage sections in the OVF descriptor.

If omitted, the server will choose the default profile.

storage_provisioning

string

Default storage provisioning type to use for all sections of type vmw:StorageSection in the OVF descriptor.

thin - A thin provisioned virtual disk has space allocated and zeroed on demand as the space is used.

thick - A thick provisioned virtual disk has all space allocated at creation time and the space is zeroed on demand as the space is used.

eagerZeroedThick - An eager zeroed thick provisioned virtual disk has all space allocated and wiped clean of any previous contents on the physical media at creation time.

Disks specified as eager zeroed thick may take longer time to create than disks specified with the other disk provisioning types.

If omitted, the server will choose the provisioning type.

Choices:

  • "thin"

  • "thick"

  • "eagerZeroedThick"

subnet_mappings

dictionary

Mapping of OVF network names to vCenter subnet folder MOIDs.

The key is the network name from the OVF descriptor and the value is the MOID of the target subnet folder. If set, this takes precedence over network_mappings.

This property was added in __vSphere API 9.1.0.0__.

If omitted, network_mappings will be used instead.

tag_params

dictionary

Tag parameters that contain the information required to attach tags to a VM during VM deployment.

This property was added in __vSphere API 9.1.0.0__.

This property is optional because it was added in a newer version than its parent node.

tags

list / elements=dictionary

List of tag parameters which contains information required to attach tags while deploying a VM.

This property was added in __vSphere API 9.1.0.0__.

This property is not used for the ‘create’ operation. It will always be present in the response of the ‘get’ or ‘list’ operations. It is not used for the ‘update’ operation.

type

string

Unique identifier describing the type of the OVF parameters. The value is the name of the OVF parameters schema.

This property must be provided in the input parameters when deploying an OVF package. This property will always be present in the result when retrieving information about an OVF package.

vm_config_spec

dictionary

Virtual machine configuration settings to use in place of those defined in the OVF descriptor.

When set, the OVF descriptor is used only for disk definitions, while hardware specifications come from this configuration.

Other deployment spec settings such as name, storage_mappings, storage_profile_id, storage_provisioning, and default_datastore_id still apply and are not overridden.

This property was added in __vSphere API 8.0.2.0__.

If omitted, the virtual machine specifications from the OVF descriptor will be used.

provider

string / required

The format provider for the VM configuration specification.

XML - A vim.vm.ConfigSpec serialized to XML and base64 encoded.

This property was added in __vSphere API 8.0.2.0__.

Choices:

  • "XML"

xml

string

A vim.vm.ConfigSpec serialized to XML and base64 encoded.

This property was added in __vSphere API 8.0.2.0__.

Only relevant when provider is set to XML.

ovf_library_item_id

string

Identifier of the OVF library item to manage.

Required when state=deploy or state=filter.

session_timeout

float

Timeout in seconds for the whole operation including connection establishment, request sending, and response.

Default: 300.0

source

dictionary

The virtual machine or virtual appliance to export as an OVF package.

Required when state=present.

id

string / required

MOID of the source virtual machine or virtual appliance to export.

type

string / required

Type of the source resource to export.

Must be one of VirtualMachine or VirtualApp.

state

string

The desired state of the resource.

Use present to create or update the resource.

Use deploy to perform the deploy action.

Use filter to perform the filter action.

Only present supports idempotence.

Choices:

  • "present" ← (default)

  • "deploy"

  • "filter"

target

dictionary

The destination for the operation.

When state=present, specifies the content library and optional library item to store the OVF package.

When state=deploy, specifies the resource pool, host, and folder where the VM or vApp will be created.

When state=filter, specifies the resource pool used to evaluate deployment requirements.

folder_id

string

MOID of the vCenter folder that should contain the virtual machine or virtual appliance. The folder must be a virtual machine folder.

If omitted, the server will choose the deployment folder.

host_id

string

MOID of the target host on which the virtual machine or virtual appliance will run.

The target host must be a member of the cluster that contains the resource pool identified by resource_pool_id.

If omitted, the server will automatically select a target host from the resource pool when it is a stand-alone host or a cluster with DRS enabled.

library_id

string

MOID of the content library in which a new library item should be created.

Not used if library_item_id is specified.

This property is currently required when state=present.

library_item_id

string

MOID of an existing library item to update with the new OVF package.

If omitted, a new library item will be created. library_id must be specified if this property is set.

resource_pool_id

string

MOID of the resource pool to which the virtual machine or virtual appliance should be deployed.

vcenter_hostname

string / required

The hostname or IP address of the vSphere vCenter.

If the value is not specified in the task, the value of environment variable VMWARE_HOST will be used instead.

vcenter_password

string / required

The vSphere vCenter password.

If the value is not specified in the task, the value of environment variable VMWARE_PASSWORD will be used instead.

vcenter_port

integer

The port number of the vSphere vCenter.

If the value is not specified in the task, the value of environment variable VMWARE_PORT will be used instead.

vcenter_rest_log_file

string

Optional path to a log file for HTTP REST interaction.

If the value is not specified in the task, the value of environment variable VMWARE_REST_LOG_FILE will be used instead.

vcenter_username

string / required

The vSphere vCenter username.

If the value is not specified in the task, the value of environment variable VMWARE_USER will be used instead.

vcenter_validate_certs

boolean

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.

Choices:

  • false

  • true ← (default)

Notes

Note

  • Generated from vSphere API spec 9.1.0.

  • Not compatible with vSphere API 7.0.3.

  • Not compatible with vSphere API 8.0.2.

Examples

- name: Export a virtual machine to a content library as an OVF package
  vmware.vmware_rest.vcenter_ovf_libraryitem:
    source:
      type: VirtualMachine
      id: vm-123
    target:
      library_id: lib-456
    create_spec:
      name: my-vm-template
      description: OVF export of my production web server
    state: present

- name: Export a virtual machine into an existing library item
  vmware.vmware_rest.vcenter_ovf_libraryitem:
    source:
      type: VirtualMachine
      id: vm-123
    target:
      library_id: lib-456
      library_item_id: item-789
    create_spec:
      name: my-vm-template
    state: present

- name: Deploy an OVF package from a content library item
  vmware.vmware_rest.vcenter_ovf_libraryitem:
    ovf_library_item_id: item-789
    target:
      resource_pool_id: resgroup-1001
      folder_id: group-v1002
      host_id: host-1003
    deployment_spec:
      name: deployed-vm
      accept_all_eula: true
      storage_provisioning: thin
      network_mappings:
        VM Network: network-1004
    state: deploy

- name: Deploy an OVF package with a specific datastore and storage profile
  vmware.vmware_rest.vcenter_ovf_libraryitem:
    ovf_library_item_id: item-789
    target:
      resource_pool_id: resgroup-1001
    deployment_spec:
      name: deployed-vm-custom-storage
      accept_all_eula: true
      default_datastore_id: datastore-1005
      storage_profile_id: storageprofile-1006
      storage_provisioning: eagerZeroedThick
    state: deploy

- name: Retrieve OVF deployment information before deploying
  vmware.vmware_rest.vcenter_ovf_libraryitem:
    ovf_library_item_id: item-789
    target:
      resource_pool_id: resgroup-1001
    state: filter

Return Values

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

Key

Description

id

string

Identifier of the managed resource.

When state=present, this is the content library item identifier.

When state=deploy, this is the identifier of the deployed virtual machine or virtual appliance.

When state=filter, this is the OVF library item identifier that was queried.

Returned: When state is present, or when state is set to a supported action

Sample: "item-789"

value

any

The full API response body returned by the vCenter OVF library item operation.

When state=present, contains the operation result including library item ID and whether the operation succeeded.

When state=deploy, contains deployment result details including whether the operation succeeded, any errors, and resource references.

When state=filter, contains OVF deployment information such as network and storage requirements, EULAs, and additional parameters needed for deployment.

Returned: On success

Sample: {"resource_id": {"id": "vm-123", "type": "VirtualMachine"}, "succeeded": true}

Authors

  • Ansible Eco Content Team (@eco-ansible-content)