ovirt.ovirt.ovirt_template module – Module to manage virtual machine templates in oVirt/RHV
Note
This module is part of the ovirt.ovirt collection (version 3.2.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 ovirt.ovirt
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: ovirt.ovirt.ovirt_template
.
New in ovirt.ovirt 1.0.0
Synopsis
Module to manage virtual machine templates in oVirt/RHV.
Requirements
The below requirements are needed on the host that executes this module.
python >= 2.7
ovirt-engine-sdk-python >= 4.4.0
Parameters
Parameter |
Comments |
---|---|
Boolean indication whether to allow partial registration of a template when Choices:
|
|
Dictionary with values needed to create HTTP/HTTPS connection to oVirt: |
|
A PEM file containing the trusted CA certificates. The certificate presented by the server will be verified using these CA certificates. If Default value is set by |
|
Flag indicating if compression is used for connection. Choices:
|
|
Dictionary of HTTP headers to be added to each API call. |
|
A string containing the hostname of the server, usually something like `server.example.com`. Default value is set by Either |
|
A boolean flag that indicates if the server TLS certificate and host name should be checked. Choices:
|
|
A boolean flag indicating if Kerberos authentication should be used instead of the default basic authentication. Choices:
|
|
The password of the user. Default value is set by |
|
Number of seconds to wait for response. |
|
Token to be used instead of login with username/password. Default value is set by |
|
A string containing the API URL of the server, usually something like `https://server.example.com/ovirt-engine/api`. Default value is set by Either |
|
The name of the user, something like admin@internal. Default value is set by |
|
If true, use memory ballooning. Memory balloon is a guest device, which may be used to re-distribute / reclaim the host memory based on VM needs in a dynamic way. In this way it’s possible to create memory over commitment states. Choices:
|
|
Set bios type, necessary for some operating systems and secure boot. If no value is passed, default value is set from cluster. NOTE - Supported since oVirt 4.3. Choices:
|
|
True enable menu to select boot device, False to disable it. By default is chosen by oVirt/RHV engine. Choices:
|
|
Name for importing Template from storage domain. If not defined, |
|
If True then the permissions of the VM (only the direct ones, not the inherited ones) will be copied to the created template. This parameter is used only when Choices:
|
|
Dictionary with values for Unix-like Virtual Machine initialization using cloud init. |
|
Use this SSH keys to login to Virtual Machine. |
|
Cloud-init script which will be executed on Virtual Machine when deployed. This is appended to the end of the cloud-init script generated by any other options. For further information, refer to cloud-init User-Data documentation. |
|
DNS search domains to be configured on Virtual Machine. |
|
DNS servers to be configured on Virtual Machine, maximum of two, space-separated. |
|
Hostname to be set to Virtual Machine when deployed. |
|
Set boot protocol of the network interface of Virtual Machine. Choices:
|
|
If boot protocol is static, set this gateway to network interface of Virtual Machine. |
|
If boot protocol is static, set this IP address to network interface of Virtual Machine. |
|
Set name to network interface of Virtual Machine. |
|
If boot protocol is static, set this netmask to network interface of Virtual Machine. |
|
If True SSH keys will be regenerated on Virtual Machine. Choices:
|
|
Password to be set for user specified by |
|
Timezone to be set to Virtual Machine when deployed. |
|
Username to be used to set password to Virtual Machine when deployed. |
|
List of dictionaries representing network interfaces to be setup by cloud init. This option is used, when user needs to setup more network interfaces via cloud init. If one network interface is enough, user should use |
|
Set boot protocol of the network interface of Virtual Machine. Can be one of |
|
If boot protocol is static, set this gateway to network interface of Virtual Machine. |
|
If boot protocol is static, set this IP address to network interface of Virtual Machine. |
|
Set name to network interface of Virtual Machine. |
|
If boot protocol is static, set this netmask to network interface of Virtual Machine. |
|
Name of the cluster, where template should be created/imported. |
|
Mapper which maps cluster name between Template’s OVF and the destination cluster this Template should be registered to, relevant when |
|
The name of the destination cluster. |
|
The name of the source cluster. |
|
CPU profile to be set to template. |
|
Description of the template. |
|
Mapper which maps aaa domain name between Template’s OVF and the destination aaa domain this Template should be registered to, relevant when |
|
The name of the destination aaa domain. |
|
The name of the source aaa domain. |
|
When Choices:
|
|
When |
|
If True the module will fetch additional data from the API. It will fetch IDs of the VMs disks, snapshots, etc. User can configure to fetch other attributes of the nested entities by specifying Choices:
|
|
ID of the template to be registered. |
|
When |
|
When |
|
Number of IO threads used by virtual machine. 0 means IO threading disabled. |
|
Dictionary of values to be used to connect to kvm and import a template to oVirt. |
|
Indicates if the identifiers of the imported template should be regenerated. |
|
The host name from which the template will be imported. |
|
Specifies the target storage domain for converted disks. This is required parameter. |
|
The URL to be passed to the virt-v2v tool for conversion. For example qemu:///system. This is required parameter. |
|
Amount of memory of the template. Prefix uses IEC 60027-2 standard (for example 1GiB, 1024MiB). |
|
Amount of minimal guaranteed memory of the template. Prefix uses IEC 60027-2 standard (for example 1GiB, 1024MiB).
|
|
Upper bound of template memory up to which memory hot-plug can be performed. Prefix uses IEC 60027-2 standard (for example 1GiB, 1024MiB). |
|
Name of the template to manage. |
|
Specifies list of the attributes which should be fetched from the API. This parameter apply only when |
|
List of NICs, which should be attached to Virtual Machine. NIC is described by following dictionary. |
|
Type of the network interface. Choices:
|
|
Custom MAC address of the network interface, by default it’s obtained from MAC pool. |
|
Name of the NIC. |
|
Profile name where NIC should be attached. |
|
Operating system of the template, for example ‘rhel_8x64’. Default value is set by oVirt/RHV engine. Use the ovirt.ovirt.ovirt_vm_os_info module to obtain the current list. |
|
Number of the seconds the module waits until another poll request on entity status is sent. Default: |
|
Mapper which maps role name between Template’s OVF and the destination role this Template should be registered to, relevant when |
|
The name of the destination role. |
|
The name of the source role. |
|
‘Sealing’ is an operation that erases all machine-specific configurations from a filesystem: This includes SSH keys, UDEV rules, MAC addresses, system ID, hostname, etc. If true subsequent virtual machines made from this template will avoid configuration inheritance. This parameter is used only when Choices:
|
|
If true, use smart card authentication. Choices:
|
|
If true, the sound card is added to the virtual machine. Choices:
|
|
True enable Single Sign On by Guest Agent, False to disable it. By default is chosen by oVirt/RHV engine. Choices:
|
|
Should the template be present/absent/exported/imported/registered. When Choices:
|
|
When |
|
Dictionary with values for Windows Virtual Machine initialization using sysprep. |
|
Active Directory Organizational Unit, to be used for login of user. |
|
A custom Sysprep definition in the format of a complete unattended installation answer file. |
|
Domain to be set to Windows Virtual Machine. |
|
Hostname to be set to Virtual Machine when deployed. |
|
Input localization of the Windows Virtual Machine. |
|
Organization name to be set to Windows Virtual Machine. |
|
Password to be set for username to Windows Virtual Machine. |
|
System localization of the Windows Virtual Machine. |
|
Timezone to be set to Windows Virtual Machine. |
|
UI language of the Windows Virtual Machine. |
|
Username to be used for set password to Windows Virtual Machine. |
|
License key to be set to Windows Virtual Machine. |
|
When |
|
The amount of time in seconds the module should wait for the instance to get into desired state. Default: |
|
Sets time zone offset of the guest hardware clock. For example |
|
True enable USB support, False to disable it. By default is chosen by oVirt/RHV engine. Choices:
|
|
|
|
Name of the VM, which will be used to create template. |
|
Mapper which maps an external virtual NIC profile to one that exists in the engine when |
|
The network name of the source network. |
|
The profile name related to the source network. |
|
The id of the target profile id to be mapped to in the engine. |
|
Choices:
|
Notes
Note
In order to use this module you have to install oVirt Python SDK. To ensure it’s installed with correct version you can create the following task: pip: name=ovirt-engine-sdk-python version=4.4.0
Examples
# Examples don't contain auth parameter for simplicity,
# look at ovirt_auth module to see how to reuse authentication:
# Create template from vm
- ovirt.ovirt.ovirt_template:
cluster: Default
name: mytemplate
vm: rhel7
cpu_profile: Default
description: Test
# Import template
- ovirt.ovirt.ovirt_template:
state: imported
name: mytemplate
export_domain: myexport
storage_domain: mystorage
cluster: mycluster
# Remove template
- ovirt.ovirt.ovirt_template:
state: absent
name: mytemplate
# Change Template Name
- ovirt.ovirt.ovirt_template:
id: 00000000-0000-0000-0000-000000000000
name: "new_template_name"
# Register template
- ovirt.ovirt.ovirt_template:
state: registered
storage_domain: mystorage
cluster: mycluster
name: mytemplate
# Register template using id
- ovirt.ovirt.ovirt_template:
state: registered
storage_domain: mystorage
cluster: mycluster
id: 1111-1111-1111-1111
# Register template, allowing partial import
- ovirt.ovirt.ovirt_template:
state: registered
storage_domain: mystorage
allow_partial_import: "True"
cluster: mycluster
id: 1111-1111-1111-1111
# Register template with vnic profile mappings
- ovirt.ovirt.ovirt_template:
state: registered
storage_domain: mystorage
cluster: mycluster
id: 1111-1111-1111-1111
vnic_profile_mappings:
- source_network_name: mynetwork
source_profile_name: mynetwork
target_profile_id: 3333-3333-3333-3333
- source_network_name: mynetwork2
source_profile_name: mynetwork2
target_profile_id: 4444-4444-4444-4444
# Register template with mapping
- ovirt.ovirt.ovirt_template:
state: registered
storage_domain: mystorage
cluster: mycluster
id: 1111-1111-1111-1111
role_mappings:
- source_name: Role_A
dest_name: Role_B
domain_mappings:
- source_name: Domain_A
dest_name: Domain_B
cluster_mappings:
- source_name: cluster_A
dest_name: cluster_B
# Import image from Glance s a template
- ovirt.ovirt.ovirt_template:
state: imported
name: mytemplate
image_disk: "centos7"
template_image_disk_name: centos7_from_glance
image_provider: "glance_domain"
storage_domain: mystorage
cluster: mycluster
# Edit template subversion
- ovirt.ovirt.ovirt_template:
cluster: mycluster
name: mytemplate
vm: rhel7
version:
number: 2
name: subversion
# Create new template subversion
- ovirt.ovirt.ovirt_template:
cluster: mycluster
name: mytemplate
vm: rhel7
version:
name: subversion
- name: Template with cloud init
ovirt.ovirt.ovirt_template:
name: mytemplate
cluster: Default
vm: rhel8
memory: 1GiB
cloud_init:
dns_servers: '8.8.8.8 8.8.4.4'
nic_boot_protocol: static
nic_ip_address: 10.34.60.86
nic_netmask: 255.255.252.0
nic_gateway: 10.34.63.254
nic_name: eth1
host_name: example.com
custom_script: |
write_files:
- content: |
Hello, world!
path: /tmp/greeting.txt
permissions: '0644'
user_name: root
root_password: super_password
- name: Template with cloud init, with multiple network interfaces
ovirt.ovirt.ovirt_template:
name: mytemplate
cluster: mycluster
vm: rhel8
cloud_init_nics:
- nic_name: eth0
nic_boot_protocol: dhcp
- nic_name: eth1
nic_boot_protocol: static
nic_ip_address: 10.34.60.86
nic_netmask: 255.255.252.0
nic_gateway: 10.34.63.254
- name: Template with timezone and nic
ovirt.ovirt.ovirt_template:
cluster: MyCluster
name: mytemplate
vm: rhel8
timezone: America/Godthab
memory_max: 2Gib
nics:
- name: nic1
- name: Template with sysprep
ovirt.ovirt.ovirt_template:
name: windows2012R2_AD
cluster: Default
vm: windows2012
memory: 3GiB
sysprep:
host_name: windowsad.example.com
user_name: Administrator
root_password: SuperPassword123
- name: Import external ova template
ovirt.ovirt.ovirt_template:
cluster: mycluster
name: mytemplate
state: present
timeout: 1800
poll_interval: 30
kvm:
host: myhost
url: ova:///tmp/test.ova
storage_domain: mystorage
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
ID of the template which is managed Returned: On success if template is found. Sample: |
|
Dictionary of all the template attributes. Template attributes can be found on your oVirt/RHV instance at following url: http://ovirt.github.io/ovirt-engine-api-model/master/#types/template. Returned: On success if template is found. |