vmware.vmware_rest.vcenter_ovf_libraryitem module – Creates a library item in content library from a virtual machine or virtual appliance
Note
This module is part of the vmware.vmware_rest collection (version 4.4.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
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: vmware.vmware_rest.vcenter_ovf_libraryitem
.
New in vmware.vmware_rest 2.0.0
Synopsis
This operation creates a library item in content library whose content is an OVF package derived from a source virtual machine or virtual appliance, using the supplied create specification. For an existing library item whose content is updated by this operation, the original content is overwritten. Meta data such as name and description is not updated for the existing library item. PLease see the examples for a workaround if you need to update the description.
Requirements
The below requirements are needed on the host that executes this module.
vSphere 7.0.3 or greater
python >= 3.6
aiohttp
Parameters
Parameter |
Comments |
---|---|
Client-generated token used to retry a request if the client fails to get a response from the server. If the original request succeeded, the result of that request will be returned, otherwise the operation will be retried. If unset, the server will create a token. |
|
Information used to create the OVF package from the source virtual machine or virtual appliance. Required with state=[‘present’] Valid attributes are:
If unset, the server will use source’s current name. ([‘present’])
If unset, the server will use source’s current annotation. ([‘present’])
If unset, no flags will be used. ([‘present’]) |
|
Specification of how the OVF package should be deployed to the target. Required with state=[‘deploy’] Valid attributes are:
If unset, the server will use the name from the OVF package. ([‘deploy’])
If unset, the server will use the annotation from the OVF package. ([‘deploy’])
This key is required with [‘deploy’].
If unset, the server will choose a network mapping. When clients pass a value of this structure as a parameter, the value in the field map must be the id of a resource returned by vmware.vmware_rest.vcenter_network_info. ([‘deploy’])
If unset, the server will choose a storage mapping. ([‘deploy’])
If unset, the server will choose the default profile. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.vcenter_storage_policies_info. ([‘deploy’])
If unset, the server locale will be used. ([‘deploy’])
If unset, no flags will be used. ([‘deploy’])
If unset, the server will choose default settings for all parameters necessary for the LibraryItem.deploy operation. See LibraryItem.deploy. When clients pass a value of this structure as a parameter, the field must contain all the attributes defined in OvfParams. ([‘deploy’])
If unset, the server will choose the default datastore. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.vcenter_datastore_info. ([‘deploy’])
If unset, the relevant virtual machine specifications in the OVF descriptor of the OVF template will be used. ([‘deploy’])
Accepted value for this field:
This field is optional and it is only relevant when the value of provider is XML. |
|
Identifier of the content library item containing the OVF package to be deployed. The parameter must be the id of a resource returned by vmware.vmware_rest.content_library_item_info. Required with state=[‘deploy’, ‘filter’] |
|
Timeout settings for client session. The maximal number of seconds for the whole operation including connection establishment, request sending and response. The default value is 300s. |
|
Identifier of the virtual machine or virtual appliance to use as the source. Required with state=[‘present’] Valid attributes are:
When clients pass a value of this structure as a parameter, the field must be one of VirtualMachine or VirtualApp. ([‘present’]) This key is required with [‘present’].
When clients pass a value of this structure as a parameter, the field must be an identifier for one of these resource types: VirtualMachine or VirtualApp. ([‘present’]) This key is required with [‘present’]. |
|
Choices:
|
|
Specification of the target content library and library item. This parameter is mandatory. Valid attributes are:
This field is currently required. In the future, if unset, the library_item_id field must be specified. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.content_library_info. ([‘present’])
If unset, a new library item will be created. The library_id field must be specified if this field is set. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.content_library_item_info. ([‘present’])
When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.vcenter_resourcepool_info. ([‘deploy’, ‘filter’]) This key is required with [‘deploy’, ‘filter’].
If unset, the server will automatically select a target host from the resource pool if resource_pool_id is a stand-alone host or a cluster with Distributed Resource Scheduling (DRS) enabled. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.vcenter_host_info. ([‘deploy’, ‘filter’])
If unset, the server will choose the deployment folder. When clients pass a value of this structure as a parameter, the field must be the id of a resource returned by vmware.vmware_rest.vcenter_folder_info. ([‘deploy’, ‘filter’]) |
|
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 |
|
You can use this optional parameter to set the location of a log file. This file will be used to record the HTTP REST interaction. The file will be stored on the host that runs the module. 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:
|
Notes
Note
Tested on vSphere 7.0.3
Examples
---
- name: Export the VM as an OVF on the library
vmware.vmware_rest.vcenter_ovf_libraryitem:
session_timeout: 2900
source:
type: VirtualMachine
id: "{{ lookup('vmware.vmware_rest.vm_moid', 'My VM') }}"
target:
library_id: 1111111-1111111-1111111-111111
create_spec:
name: Golden Image
description: A golden image for templating
flags: []
state: present
# Due to an issue with the generated module code and the REST API limitations,
# updating existing template descriptions must be done by removing the create_spec.name
# attribute.
#
# Note that omitting the create_spec.name attribute will force the OVF template to be replaced.
# Thus, the second task will always report as changed
- name: Export the VM as an OVF on the library
vmware.vmware_rest.vcenter_ovf_libraryitem:
session_timeout: 2900
source:
type: VirtualMachine
id: "{{ lookup('vmware.vmware_rest.vm_moid', 'My VM') }}"
target:
library_id: 1111111-1111111-1111111-111111
create_spec:
name: Golden Image
description: Some unhelpful description
flags: []
state: present
register: _ovf_item
- name: Update The Template Description
vmware.vmware_rest.vcenter_ovf_libraryitem:
session_timeout: 2900
source:
type: VirtualMachine
id: "{{ lookup('vmware.vmware_rest.vm_moid', 'My VM') }}"
target:
library_id: 1111111-1111111-1111111-111111
library_item_id: "{{ _ovf_item.value.ovf_library_item_id }}"
create_spec:
description: A much better description for this template
flags: []
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The ID of the OVF template Returned: On success and not changed Sample: |
|
Details about the OVF if it was created, or an ID if the OVF was updated Returned: On success Sample: |