summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJ. Eduardo <j.eduardo@gmail.com>2017-06-19 23:35:07 +0200
committerFlavio Castelli <flavio@castelli.me>2017-07-02 22:16:19 +0200
commit65bc2689d50f3238a052389e30d81730ad2c601d (patch)
treeb20bfd743f0ad9d42cfe27de52efd6eb9b6d2aba /examples
parent8b8c66e3bd53aeab3806179aefaec2b453dbd4ad (diff)
downloadterraform-provider-libvirt-65bc2689d50f3238a052389e30d81730ad2c601d.tar
terraform-provider-libvirt-65bc2689d50f3238a052389e30d81730ad2c601d.tar.gz
Added support for using raw volumes and an example using the functionality.
Diffstat (limited to 'examples')
-rw-r--r--examples/format/libvirt.tf72
1 files changed, 72 insertions, 0 deletions
diff --git a/examples/format/libvirt.tf b/examples/format/libvirt.tf
new file mode 100644
index 00000000..1a0cc0e8
--- /dev/null
+++ b/examples/format/libvirt.tf
@@ -0,0 +1,72 @@
+provider "libvirt" {
+ uri = "qemu:///system"
+}
+
+resource "libvirt_network" "tf" {
+ name = "tf"
+ domain = "tf.local"
+ mode = "nat"
+ addresses = ["10.0.100.0/24"]
+}
+
+# raw image from file
+resource "libvirt_volume" "debian8-raw" {
+ name = "debian8-raw"
+ format = "raw"
+ source = "http://localhost:8000/debian8.img"
+}
+
+# qcow2 image from file
+resource "libvirt_volume" "debian8-qcow2" {
+ name = "debian8-qcow2"
+ source = "http://localhost:8000/debian8.qcow2"
+}
+
+# volume with raw backing storage
+resource "libvirt_volume" "vol-debian8-raw" {
+ name = "vol-debian8-raw"
+ base_volume_id = "${libvirt_volume.debian8-raw.id}"
+ base_volume_format = "raw"
+}
+
+# volume with qcow2 backing storage
+resource "libvirt_volume" "vol-debian8-qcow2" {
+ name = "vol-debian8-qcow2"
+ base_volume_id = "${libvirt_volume.debian8-qcow2.id}"
+}
+
+# domain using raw-backed volume
+resource "libvirt_domain" "domain-debian8-raw" {
+ name = "domain-debian8-raw"
+ memory = "256"
+ vcpu = 1
+ network_interface {
+ network_name = "tf"
+ }
+ disk {
+ volume_id = "${libvirt_volume.vol-debian8-raw.id}"
+ }
+ graphics {
+ type = "spice"
+ listen_type = "address"
+ autoport = true
+ }
+}
+
+# domain using qcow2-backed volume
+resource "libvirt_domain" "domain-debian8-qcow2" {
+ name = "domain-debian8-qcow2"
+ memory = "256"
+ vcpu = 1
+ network_interface {
+ network_name = "tf"
+ }
+ disk {
+ volume_id = "${libvirt_volume.vol-debian8-qcow2.id}"
+ }
+ graphics {
+ type = "spice"
+ listen_type = "address"
+ autoport = true
+ }
+}