vmware.vmware.deploy_content_library_ovf module – Deploy a virtual machine from an OVF in a content library.

Note

This module is part of the vmware.vmware collection (version 1.11.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. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: vmware.vmware.deploy_content_library_ovf.

Synopsis

  • Create a VM based on an OVF in a content library.

  • The module basis idempotentency on if the deployed VM exists or not, not the storage or deployment spec applied at deployment time.

Requirements

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

  • vSphere Automation SDK

  • aiohttp

Parameters

Parameter

Comments

cluster

aliases: cluster_name

string

The name of the cluster where the VM should be deployed.

Changing this option will not result in the VM being redeployed (it does not affect idempotency).

One and only one of resource_pool or cluster is required.

datacenter

aliases: datacenter_name

string / required

The name of the datacenter to use when searching for and deploying resources.

datastore

string

Name of the datastore to store deployed VM and disk.

datastore and datastore_cluster are mutually exclusive.

datastore_cluster

string

Name of the datastore cluster to store deployed VM and disk.

Please make sure Storage DRS is active for recommended datastore from the given datastore cluster.

If Storage DRS is not enabled, datastore with largest free storage space is selected.

datastore and datastore_cluster are mutually exclusive.

hostname

string

The hostname or IP address of the vSphere vCenter server.

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

library_id

string

The ID of the content library where the template exists.

This is an optional parameter, but may be required if you use template_name and have multiple templates in different libraries with the same name.

This option is mutually exclusive with library_name.

library_item_id

aliases: template_id

string

The ID of content library template to use when deploying the VM.

This option is mutually exclusive with library_item_name.

One of either library_item_name or library_item_id is required.

library_item_name

aliases: template_name

string

The name of content library template to use when deploying the VM.

This option is mutually exclusive with library_item_id.

One of either library_item_name or library_item_id is required.

library_name

string

The name of the content library where the template exists.

This is an optional parameter, but may be required if you use template_name and have multiple templates in different libraries with the same name.

This option is mutually exclusive with library_id.

password

aliases: pass, pwd

string

The password of the vSphere vCenter server.

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

port

integer

The port number of the vSphere vCenter server.

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

Default: 443

proxy_host

string

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

proxy_port

integer

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

proxy_protocol

aliases: protocol

string

The proxy connection protocol to use.

This option is used if the correct proxy protocol cannot be automatically determined.

Choices:

  • "http"

  • "https" ← (default)

resource_pool

string

The name of a resource pool into which the virtual machine should be deployed.

Changing this option will not result in the VM being redeployed (it does not affect idempotency).

One and only one of resource_pool or cluster is required.

storage_provisioning

string

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

Choices:

  • "thin" ← (default)

  • "thick"

  • "eagerZeroedThick"

  • "eagerzeroedthick"

username

aliases: admin, user

string

The username of the vSphere vCenter server.

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

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)

vm_folder

aliases: folder

string

Virtual machine folder into which the virtual machine should be deployed.

This can be the absolute folder path, or a relative folder path under /<datacenter>/vm/. See the examples for more info.

This option is required if you have more than one VM with the same name in the datacenter.

Changing this option will result in the VM being redeployed, since it affects where the module looks for the deployed VM.

If not provided, the /<datacenter>/vm/ folder is used.

vm_name

string / required

The name of the VM to deploy.

If you have multiple VMs with the same name, you should also supply vm_folder

Notes

Note

  • All modules require API write access and hence are not supported on a free ESXi license.

  • All variables and VMware object names are case sensitive.

  • Modules may rely on the ‘requests’ python library, which does not use the system certificate store by default. You can specify the certificate store by setting the REQUESTS_CA_BUNDLE environment variable. Example: ‘export REQUESTS_CA_BUNDLE=/path/to/your/ca_bundle.pem’

See Also

See also

vmware.vmware.deploy_content_library_template

Deploy a virtual machine from a template in a content library.

vmware.vmware.deploy_folder_template

Deploy a VM from a template located in a folder.

Examples

- name: Create Virtual Machine From OVF Template
  vmware.vmware.deploy_content_library_ovf:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    library_item_name: mytemplate
    library_name: mylibrary
    vm_name: myvm
    datacenter: DC01
    datastore: DS01
    resource_pool: RP01


- name: Create Virtual Machine Using Absolute Folder Destination
  vmware.vmware.deploy_content_library_ovf:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    library_item_name: mytemplate
    library_name: mylibrary
    vm_name: myvm
    datacenter: DC01
    datastore: DS01
    folder: /DC01/vm/my/deploys

- name: Create Virtual Machine Using Relative Folder Destination
  vmware.vmware.deploy_content_library_ovf:
    hostname: '{{ vcenter_hostname }}'
    username: '{{ vcenter_username }}'
    password: '{{ vcenter_password }}'
    library_item_name: mytemplate
    library_name: mylibrary
    vm_name: myvm
    datacenter: DC01
    datastore: DS01
    folder: my/deploys

Return Values

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

Key

Description

vm_moid

string

The MOID of the deployed VM

Returned: when state is present

Sample: "vm-1000"

vm_name

string

The name of the vm, as specified by the input parameter vm_name

Returned: always

Sample: "myvm"

Authors

  • Ansible Cloud Team (@ansible-collections)