Skip to content
Corey Melanson edited this page Jul 19, 2018 · 1 revision

Resource Parameters

The opennebula_image resource accepts the following parameters:

Parameter Optional Description
name Required Name of the image
description Optional Description for the image
permissions Optional Chmod the image, defaults to the UMASK in OpenNebula
clone_from_image Optional ID or name of the image to clone from
datastore_id Required ID of the datastore to create on or clone to
persistent Optional Whether the image should be persistent (true/false)
path Optional Path for the new image (eg /path/on/one/server.qcow2 or http://server/image.qcow2)
type Optional Type of the new image: OS, CDROM, DATABLOCK, KERNEL, RAMDISK, CONTEXT
size Optional Size of the new datablock image in MB
dev_prefix Optional Device prefix, normally one of: hd, sd, vd
driver Optional Driver to use, normally "raw" or "qcow2"

Please Note! While most parameters are listed as optional, OpenNebula will require certain parameters be supplied depending on which operation you are doing! For example, new datablock images require a size to be supplied. If unsure, reference the examples below or https://docs.opennebula.org/5.4/operation/references/img_template.html.

Examples

Clone an existing image and make it persistent:

resource "opennebula_image" "osimageclone" {
    clone_from_image = 12937
    name = "terraclone-image"
    datastore_id = 113
    persistent = true
}

Allocate a new OS image using a URL:

resource "opennebula_image" "osimage" {
    name = "Ubuntu 18.04"
    description = "Terraform image"
    datastore_id = 103
    persistent = false
    path = "http://marketplace.opennebula.org/appliance/ca5c3632-359a-429c-ac5b-b86178ee2390/download/0"
    dev_prefix = "vd"
    driver = "qcow2"
}

Allocate a new persistent 1GB datablock image:

resource "opennebula_image" "datablockimage" {
    name = "terra-datablock"
   description = "Terraform datablock"
   datastore_id = 103
   persistent = true
   type = "DATABLOCK"
   size = "1000"
}

Allocate a new context file:

resource "opennebula_image" "contextfile" {
    name = "terra-contextfile"
    description = "Terraform context"
    datastore_id = 2
    type = "CONTEXT"
    path = "http://server/myscript.sh"
}

Allocate a new CDROM image:

resource "opennebula_image" "cdimage" {
    name = "terra-cdimage"
    description = "Terraform cdrom"
    datastore_id = 103
    type = "CDROM"
    path = "http://server/mini.iso"
}
Clone this wiki locally