| layout | page_title | sidebar_current | description |
|---|---|---|---|
opennebula |
OpenNebula: opennebula_template |
docs-opennebula-resource-template |
Provides an OpenNebula template resource. |
Provides an OpenNebula template resource.
This resource allows you to manage templates on your OpenNebula clusters. When applied, a new template is created. When destroyed, this template is removed.
resource "opennebula_template" "example" {
name = "template"
description = "VM template"
cpu = 1
vcpu = 1
memory = 1024
group = "terraform"
permissions = "660"
context = {
NETWORK = "YES"
HOSTNAME = "$NAME"
START_SCRIPT = "yum upgrade"
}
graphics {
type = "VNC"
listen = "0.0.0.0"
keymap = "fr"
}
os {
arch = "x86_64"
boot = "disk0"
}
cpumodel {
model = "host-passthrough"
}
disk {
image_id = opennebula_image.example.id
size = 10000
target = "vda"
driver = "qcow2"
}
nic {
model = "virtio"
network_id = var.vnetid
security_groups = [opennebula_security_group.example.id]
}
vmgroup {
vmgroup_id = 42
role = "vmgroup-role"
}
sched_requirements = "FREE_CPU > 60"
user_inputs = {
BLOG_TITLE = "M|text|Blog Title",
}
tags = {
environment = "example"
}
template_section {
name = "example"
elements = {
key1 = "value1"
}
}
}The following arguments are supported:
name- (Required) The name of the virtual machine template.description: (Optional) The description of the template.permissions- (Optional) Permissions applied on template. Defaults to the UMASK in OpenNebula (in UNIX Format: owner-group-other => Use-Manage-Admin).group- (Optional) Name of the group which owns the template. Defaults to the caller primary group.cpu- (Optional) Amount of CPU shares assigned to the VM. Mandatory iftemplate_****idis not set.vcpu- (Optional) Number of CPU cores presented to the VM.memory- (Optional) Amount of RAM assigned to the VM in MB. Mandatory iftemplate_****idis not set.features- (Optional) See Features parameters below for details.context- (Optional) Array of free form key=value pairs, rendered and added to the CONTEXT variables for the VM. Recommended to include:NETWORK = "YES"andSET_HOSTNAME = "$NAME".cpumodel- (Optional) See CPUmodel parameters below for details.graphics- (Optional) See Graphics parameters below for details.os- (Optional) See OS parameters below for details.disk- (Optional) Can be specified multiple times to attach several disks. See Disks parameters below for details.nic- (Optional) Can be specified multiple times to attach several NICs. See Nic parameters below for details.raw- (Optional) Allow to pass hypervisor level tuning content. See Raw parameters below for details.vmgroup- (Optional) See VM group parameters below for details. Changing this argument triggers a new resource.user_inputs- (Optional) Ask the user instantiating the template to define the values described.sched_requirements- (Optional) Scheduling requirements to deploy the resource following specific rulesched_ds_requirements- (Optional) Storage placement requirements to deploy the resource following specific rule.tags- (Optional) Map of tags (key=value) assigned to the resource. Override matching tags present in thedefault_tagsatribute when configured in theproviderblock. See tags usage related documentation for more information.template- (Deprecated) Text describing the OpenNebula template object, in Opennebula's XML string format.lock- (Optional) Lock the template with a specific lock level. Supported values:USE,MANAGE,ADMIN,ALLorUNLOCK.template_section- (Optional) Allow to add a custom vector. See Template section parameters
graphics supports the following arguments:
type- (Required) Generally set to VNC.listen- (Required) Binding address.port- (Optional) Binding Port.keymap- (Optional) Keyboard mapping.passwd- (Optional) VNC's password, conflicts with random_passwd.random_passwd- (Optional) Randomized VNC's password, conflicts with passwd.
os supports the following arguments:
arch- (Required) Hardware architecture of the Virtual machine. Must fit the host architecture.boot- (Optional)OSdisk to use to boot on.machine- (Optional) libvirt machine type.kernel- (Optional) Path to theOSkernel to boot the image in the host.kernel_ds- (Optional) Image to be used as kernel. (see !!)initrd- (Optional) Path to the initrd image in the host.initrd_ds- (Optional) Image to be used as ramdisk. (see !!)root- (Optional) Device to be mounted as root.kernel_cmd- (Optional) Arguments for the booting kernel.bootloader- (Optional) Path to the bootloader executable.sd_disk_bus- (Optional) Bus for disks with sd prefix, eitherscsiorsata, if attribute is missing, libvirt chooses itself.uuid- (Optional) Unique ID of the VM.firmware- (Optional) Firmware type or firmware path. Possible values:BIOSor path for KVM,BIOSorUEFIfor vCenter.firmware_secure- (Optional) Enable Secure Boot. (Can betrueorfalse).- (!!) Use one of
kernel_dsorkernel(andinitrdorinitrd_ds).
features supports the following arguments
pea- (Optional) Physical address extension mode allows 32-bit guests to address more than 4 GB of memory. (Can beYESorNO)acpi- (Optional) Useful for power management, for example, with KVM guests it is required for graceful shutdown to work. (Can beYESorNO)apic- (Optional) Enables the advanced programmable IRQ management. Useful for SMP machines. (Can beYESorNO)localtime- (Optional) The guest clock will be synchronized to the host’s configured timezone when booted. Useful for Windows VMs. (Can beYESorNO)hyperv- (Optional) Add hyperv extensions to the VM. The options can be configured in the driver configuration, HYPERV_OPTIONS.guest_agent- (Optional) Enables the QEMU Guest Agent communication. This only creates the socket inside the VM, the Guest Agent itself must be installed and started in the VM. (Can beYESorNO)virtio_scsi_queues- (Optional) Numer of vCPU queues for the virtio-scsi controller.iothreads- (Optional) umber of iothreads for virtio disks. By default threads will be assign to disk by round robin algorithm. Disk thread id can be forced by disk IOTHREAD attribute.
cpumodel supports the following argument:
model- (Required) CPU model to be used on the virtual machine.
disk supports the following arguments
image_id- (Optional) ID of the image to attach to the virtual machine. Conflicts withvolatile_typeandvolatile_format.size- (Optional) Size (in MB) of the image attached to the virtual machine. Not possible to change a cloned image size.target- (Optional) Target name device on the virtual machine. Depends of the imagedev_prefix.driver- (Optional) OpenNebula image driver.dev_prefix- (Optional) Prefix for the emulated device this image will be mounted at. For instance, attribute of the Image will be used.cache- (Optional) Selects the cache mechanism for the disk. Values are default, none, writethrough, writeback, directsync and unsafe.discard- (Optional) Controls what’s done with with trim commands to the disk, the values can be ignore or discard.io- (Optional) Set IO policy. Values are threads, native.volatile_type- (Optional) Type of the volatile disk:swaporfs. Typeswapis not supported in vcenter. Conflicts withimage_id.volatile_format- (Optional) Format of the volatile disk:raworqcow2. Conflicts withimage_id.
Minimum 1 item. Maximum 8 items.
nic supports the following arguments
network_id- (Optional) ID of the virtual network to attach to the virtual machine.ip- (Optional) IP of the virtual machine on this network.mac- (Optional) MAC of the virtual machine on this network.model- (Optional) Nic model driver. Example:virtio.physical_device- (Optional) Physical device hosting the virtual network.security_groups- (Optional) List of security group IDs to use on the virtual network.network_mode_auto- (Optional) A boolean letting the scheduler pick the Virtual Networks the VM NICs will be attached to.sched_requirements- (Optional) A boolean expression to select virtual networks (evaluates to true) to attach the NIC, whennetwork_mode_autois true.sched_rank- (Optional) Arithmetic expression to sort the suitable Virtual Networks for this NIC, whennetwork_mode_autois true.
Minimum 1 item. Maximum 8 items.
raw supports the following arguments:
type- (Required) - Hypervisor. Supported values:kvm,lxd,vmware.data- (Required) - Raw data to pass to the hypervisor.
vmgroup supports the following arguments:
vmgroup_id- (Required) ID of the VM group to use.role- (Required) role of the VM group to use.
template_section supports the following arguments:
name- (Optional) The vector name.elements- (Optional) Collection of custom tags.
The following attribute are exported:
id- ID of the template.uid- User ID whom owns the template.gid- Group ID which owns the template.uname- User Name whom owns the template.gname- Group Name which owns the template.reg_time- Registration time of the template.tags_all- Result of the applieddefault_tagsand then resourcetags.default_tags- Default tags defined in the provider configuration.
opennebula_template can be imported using its ID:
terraform import opennebula_template.example 123