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 2.3.1).
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
Creates a library item in content library from a virtual machine or virtual appliance. <p> This {@term 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. The OVF package may be stored as in a newly created library item or in an in an existing library item. For an existing library item whose content is updated by this {@term operation}, the original content is overwritten. Meta data such as name and description is not updated for the exisitng library item. </p>
Requirements
The below requirements are needed on the host that executes this module.
vSphere 7.0.2 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. |
|
Information used to create the OVF package from the source virtual machine or virtual appliance. Required with state=[‘present’] Valid attributes are:
|
|
Specification of how the OVF package should be deployed to the target. Required with state=[‘deploy’] Valid attributes are:
This key is required with [‘deploy’].
|
|
Identifier of the content library item containing the OVF package to be deployed. 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:
This key is required with [‘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 key is required with [‘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 run 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.2
Examples
- name: Create a VM
vmware.vmware_rest.vcenter_vm:
placement:
cluster: "{{ lookup('vmware.vmware_rest.cluster_moid', '/my_dc/host/my_cluster') }}"
datastore: "{{ lookup('vmware.vmware_rest.datastore_moid', '/my_dc/datastore/rw_datastore') }}"
folder: "{{ lookup('vmware.vmware_rest.folder_moid', '/my_dc/vm') }}"
resource_pool: "{{ lookup('vmware.vmware_rest.resource_pool_moid', '/my_dc/host/my_cluster/Resources') }}"
name: test_vm1
guest_OS: RHEL_7_64
hardware_version: VMX_11
memory:
hot_add_enabled: true
size_MiB: 1024
register: my_vm
- name: Create a content library pointing on a NFS share
vmware.vmware_rest.content_locallibrary:
name: my_library_on_nfs
description: automated
publish_info:
published: true
authentication_method: NONE
storage_backings:
- storage_uri: nfs://datastore.test/srv/share/content-library
type: OTHER
state: present
register: nfs_lib
- name: Export the VM as an OVF on the library
vmware.vmware_rest.vcenter_ovf_libraryitem:
session_timeout: 2900
source:
type: VirtualMachine
id: '{{ my_vm.id }}'
target:
library_id: '{{ nfs_lib.id }}'
create_spec:
name: golden_image
description: an OVF example
flags: []
state: present
register: ovf_item
- name: Get the list of items of the NFS library
vmware.vmware_rest.content_library_item_info:
library_id: '{{ nfs_lib.id }}'
register: lib_items
- name: Create a new VM from the OVF
vmware.vmware_rest.vcenter_ovf_libraryitem:
ovf_library_item_id: '{{ (lib_items.value|selectattr("name", "equalto", "golden_image")|first).id }}'
state: deploy
target:
resource_pool_id: "{{ lookup('vmware.vmware_rest.resource_pool_moid', '/my_dc/host/my_cluster/Resources') }}"
deployment_spec:
name: my_vm_from_ovf
accept_all_EULA: true
storage_provisioning: thin
- name: Create a new VM from the OVF and specify the host and folder
vmware.vmware_rest.vcenter_ovf_libraryitem:
ovf_library_item_id: '{{ (lib_items.value|selectattr("name", "equalto", "golden_image")|first).id }}'
state: deploy
target:
resource_pool_id: "{{ lookup('vmware.vmware_rest.resource_pool_moid', '/my_dc/host/my_cluster/Resources') }}"
folder_id: "{{ lookup('vmware.vmware_rest.folder_moid', '/my_dc/vm') }}"
host_id: "{{ lookup('vmware.vmware_rest.host_moid', '/my_dc/host/my_cluster/esxi1.test/test_vm1') }}"
deployment_spec:
name: my_vm_from_ovf_on_a_host
accept_all_EULA: true
storage_provisioning: thin
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Create a new VM from the OVF and specify the host and folder Returned: On success Sample: |