mnecas / mnecas.ovirt / 1.5.5 / module / ovirt_template Module to manage virtual machine templates in oVirt/RHV | "added in version" 1.0.0 of mnecas.ovirt" Authors: Ondra Machacek (@machacekondra), Martin Necas (@mnecas)mnecas.ovirt.ovirt_template (1.5.5) — module
Install with ansible-galaxy collection install mnecas.ovirt:==1.5.5
collections: - name: mnecas.ovirt version: 1.5.5
Module to manage virtual machine templates in oVirt/RHV.
# Examples don't contain auth parameter for simplicity, # look at ovirt_auth module to see how to reuse authentication: # Create template from vm - mnecas.ovirt.ovirt_template: cluster: Default name: mytemplate vm: rhel7 cpu_profile: Default description: Test
# Import template - mnecas.ovirt.ovirt_template: state: imported name: mytemplate export_domain: myexport storage_domain: mystorage cluster: mycluster
# Remove template - mnecas.ovirt.ovirt_template: state: absent name: mytemplate
# Change Template Name - mnecas.ovirt.ovirt_template: id: 00000000-0000-0000-0000-000000000000 name: "new_template_name"
# Register template - mnecas.ovirt.ovirt_template: state: registered storage_domain: mystorage cluster: mycluster name: mytemplate
# Register template using id - mnecas.ovirt.ovirt_template: state: registered storage_domain: mystorage cluster: mycluster id: 1111-1111-1111-1111
# Register template, allowing partial import - mnecas.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 - mnecas.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 - mnecas.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 - mnecas.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 - mnecas.ovirt.ovirt_template: cluster: mycluster name: mytemplate vm: rhel7 version: number: 2 name: subversion
# Create new template subversion - mnecas.ovirt.ovirt_template: cluster: mycluster name: mytemplate vm: rhel7 version: name: subversion
- name: Template with cloud init mnecas.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 mnecas.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 mnecas.ovirt.ovirt_template: cluster: MyCluster name: mytemplate vm: rhel8 timezone: America/Godthab memory_max: 2Gib nics: - name: nic1
- name: Template with sysprep mnecas.ovirt.ovirt_template: name: windows2012R2_AD cluster: Default vm: windows2012 memory: 3GiB sysprep: host_name: windowsad.example.com user_name: Administrator root_password: SuperPassword123
id: description: - ID of the template to be registered. type: str vm: description: - Name of the VM, which will be used to create template. type: str sso: description: - I(True) enable Single Sign On by Guest Agent, I(False) to disable it. By default is chosen by oVirt/RHV engine. type: bool auth: description: - 'Dictionary with values needed to create HTTP/HTTPS connection to oVirt:' required: true suboptions: ca_file: description: - A PEM file containing the trusted CA certificates. - The certificate presented by the server will be verified using these CA certificates. - If C(ca_file) parameter is not set, system wide CA certificate store is used. - Default value is set by C(OVIRT_CAFILE) environment variable. type: str compress: default: true description: Flag indicating if compression is used for connection. type: bool headers: description: - Dictionary of HTTP headers to be added to each API call. type: dict hostname: description: - A string containing the hostname of the server, usually something like `I(server.example.com)`. - Default value is set by C(OVIRT_HOSTNAME) environment variable. - Either C(url) or C(hostname) is required. type: str insecure: default: false description: - A boolean flag that indicates if the server TLS certificate and host name should be checked. type: bool kerberos: description: - A boolean flag indicating if Kerberos authentication should be used instead of the default basic authentication. type: bool password: description: - The password of the user. - Default value is set by C(OVIRT_PASSWORD) environment variable. required: true type: str timeout: description: Number of seconds to wait for response. type: int token: description: - Token to be used instead of login with username/password. - Default value is set by C(OVIRT_TOKEN) environment variable. type: str url: description: - A string containing the API URL of the server, usually something like `I(https://server.example.com/ovirt-engine/api)`. - Default value is set by C(OVIRT_URL) environment variable. - Either C(url) or C(hostname) is required. type: str username: description: - The name of the user, something like I(admin@internal). - Default value is set by C(OVIRT_USERNAME) environment variable. required: true type: str type: dict name: description: - Name of the template to manage. type: str nics: description: - List of NICs, which should be attached to Virtual Machine. NIC is described by following dictionary. elements: dict suboptions: interface: choices: - virtio - e1000 - rtl8139 default: virtio description: - Type of the network interface. mac_address: description: - Custom MAC address of the network interface, by default it's obtained from MAC pool. name: description: - Name of the NIC. profile_name: description: - Profile name where NIC should be attached. type: list seal: description: - '''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 I(true) subsequent virtual machines made from this template will avoid configuration inheritance.' - This parameter is used only when C(state) I(present). type: bool wait: default: true description: - C(yes) if the module should wait for the entity to get into desired state. type: bool state: choices: - present - absent - exported - imported - registered default: present description: - Should the template be present/absent/exported/imported/registered. When C(state) is I(registered) and the unregistered template's name belongs to an already registered in engine template in the same DC then we fail to register the unregistered template. type: str memory: description: - Amount of memory of the template. Prefix uses IEC 60027-2 standard (for example 1GiB, 1024MiB). type: str cluster: description: - Name of the cluster, where template should be created/imported. type: str sysprep: description: - Dictionary with values for Windows Virtual Machine initialization using sysprep. suboptions: active_directory_ou: description: - Active Directory Organizational Unit, to be used for login of user. custom_script: description: - A custom Sysprep definition in the format of a complete unattended installation answer file. domain: description: - Domain to be set to Windows Virtual Machine. host_name: description: - Hostname to be set to Virtual Machine when deployed. input_locale: description: - Input localization of the Windows Virtual Machine. org_name: description: - Organization name to be set to Windows Virtual Machine. root_password: description: - Password to be set for username to Windows Virtual Machine. system_locale: description: - System localization of the Windows Virtual Machine. timezone: description: - Timezone to be set to Windows Virtual Machine. ui_language: description: - UI language of the Windows Virtual Machine. user_name: description: - Username to be used for set password to Windows Virtual Machine. windows_license_key: description: - License key to be set to Windows Virtual Machine. type: dict timeout: default: 180 description: - The amount of time in seconds the module should wait for the instance to get into desired state. type: int version: description: - C(name) - The name of this version. - C(number) - The index of this version in the versions hierarchy of the template. Used for editing of sub template. type: dict timezone: description: - Sets time zone offset of the guest hardware clock. - For example C(Etc/GMT) type: str exclusive: description: - When C(state) is I(exported) this parameter indicates if the existing templates with the same name should be overwritten. type: bool clone_name: description: - Name for importing Template from storage domain. - If not defined, C(name) will be used. type: str cloud_init: description: - Dictionary with values for Unix-like Virtual Machine initialization using cloud init. suboptions: authorized_ssh_keys: description: - Use this SSH keys to login to Virtual Machine. custom_script: description: - 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: description: - DNS search domains to be configured on Virtual Machine. dns_servers: description: - DNS servers to be configured on Virtual Machine, maximum of two, space-separated. host_name: description: - Hostname to be set to Virtual Machine when deployed. nic_boot_protocol: choices: - none - dhcp - static description: - Set boot protocol of the network interface of Virtual Machine. nic_gateway: description: - If boot protocol is static, set this gateway to network interface of Virtual Machine. nic_ip_address: description: - If boot protocol is static, set this IP address to network interface of Virtual Machine. nic_name: description: - Set name to network interface of Virtual Machine. nic_netmask: description: - If boot protocol is static, set this netmask to network interface of Virtual Machine. regenerate_ssh_keys: description: - If I(True) SSH keys will be regenerated on Virtual Machine. type: bool root_password: description: - Password to be set for user specified by C(user_name) parameter. timezone: description: - Timezone to be set to Virtual Machine when deployed. user_name: description: - Username to be used to set password to Virtual Machine when deployed. type: dict image_disk: aliases: - glance_image_disk_name description: - When C(state) is I(imported) and C(image_provider) is used this parameter specifies the name of disk to be imported as template. type: str io_threads: description: - Number of IO threads used by virtual machine. I(0) means IO threading disabled. type: int memory_max: description: - Upper bound of template memory up to which memory hot-plug can be performed. Prefix uses IEC 60027-2 standard (for example 1GiB, 1024MiB). type: str cpu_profile: description: - CPU profile to be set to template. type: str description: description: - Description of the template. type: str usb_support: description: - I(True) enable USB support, I(False) to disable it. By default is chosen by oVirt/RHV engine. type: bool fetch_nested: default: false description: - If I(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 C(nested_attributes). type: bool export_domain: description: - When C(state) is I(exported) or I(imported) this parameter specifies the name of the export storage domain. type: str poll_interval: default: 3 description: - Number of the seconds the module waits until another poll request on entity status is sent. type: int role_mappings: description: - 'Mapper which maps role name between Template''s OVF and the destination role this Template should be registered to, relevant when C(state) is registered. Role mapping is described by the following dictionary:' elements: dict suboptions: dest_name: description: - The name of the destination role. source_name: description: - The name of the source role. type: list image_provider: description: - When C(state) is I(imported) this parameter specifies the name of the image provider to be used. type: str storage_domain: description: - When C(state) is I(imported) this parameter specifies the name of the destination data storage domain. When C(state) is I(registered) this parameter specifies the name of the data storage domain of the unregistered template. type: str cloud_init_nics: description: - 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 C(cloud_init) I(nic_*) parameters. C(cloud_init) I(nic_*) parameters are merged with C(cloud_init_nics) parameters. elements: dict suboptions: nic_boot_protocol: description: - Set boot protocol of the network interface of Virtual Machine. Can be one of C(none), C(dhcp) or C(static). nic_gateway: description: - If boot protocol is static, set this gateway to network interface of Virtual Machine. nic_ip_address: description: - If boot protocol is static, set this IP address to network interface of Virtual Machine. nic_name: description: - Set name to network interface of Virtual Machine. nic_netmask: description: - If boot protocol is static, set this netmask to network interface of Virtual Machine. type: list domain_mappings: description: - 'Mapper which maps aaa domain name between Template''s OVF and the destination aaa domain this Template should be registered to, relevant when C(state) is registered. The aaa domain mapping is described by the following dictionary:' elements: dict suboptions: dest_name: description: - The name of the destination aaa domain. source_name: description: - The name of the source aaa domain. type: list cluster_mappings: description: - 'Mapper which maps cluster name between Template''s OVF and the destination cluster this Template should be registered to, relevant when C(state) is registered. Cluster mapping is described by the following dictionary:' elements: dict suboptions: dest_name: description: - The name of the destination cluster. source_name: description: - The name of the source cluster. type: list operating_system: description: - Operating system of the template, for example 'rhel_8x64'. - Default value is set by oVirt/RHV engine. - Use the M(ovirt_vm_os_info) module to obtain the current list. type: str clone_permissions: description: - If I(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 C(state) I(present). type: bool memory_guaranteed: description: - Amount of minimal guaranteed memory of the template. Prefix uses IEC 60027-2 standard (for example 1GiB, 1024MiB). - C(memory_guaranteed) parameter can't be lower than C(memory) parameter. type: str nested_attributes: description: - Specifies list of the attributes which should be fetched from the API. - This parameter apply only when C(fetch_nested) is I(true). elements: str type: list smartcard_enabled: description: - If I(true), use smart card authentication. type: bool soundcard_enabled: description: - If I(true), the sound card is added to the virtual machine. type: bool ballooning_enabled: description: - If I(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. type: bool allow_partial_import: description: - Boolean indication whether to allow partial registration of a template when C(state) is registered. type: bool vnic_profile_mappings: description: - 'Mapper which maps an external virtual NIC profile to one that exists in the engine when C(state) is registered. vnic_profile is described by the following dictionary:' elements: dict suboptions: source_network_name: description: - The network name of the source network. source_profile_name: description: - The profile name related to the source network. target_profile_id: description: - The id of the target profile id to be mapped to in the engine. type: list template_image_disk_name: description: - When C(state) is I(imported) and C(image_provider) is used this parameter specifies the new name for imported disk, if omitted then I(image_disk) name is used by default. This parameter is used only in case of importing disk image from Glance domain. type: str
id: description: ID of the template which is managed returned: On success if template is found. sample: 7de90f31-222c-436c-a1ca-7e655bd5b60c type: str template: description: '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. type: dict