@@ -12,6 +12,7 @@ Terraform module for KVM/Libvirt Virtual Machine. This module will create a KVM
1212- one NIC per domain, connected to the network using the ** bridge interface**
1313- setup network interface using DHCP or static configuration
1414- cloud_init VM(s) configuration (Ubuntu+Netplan complient)
15+ - optionally add multiple extra disks
1516- test the ssh connection
1617
1718## Tested on
@@ -30,6 +31,7 @@ Terraform module for KVM/Libvirt Virtual Machine. This module will create a KVM
3031|index_start|From where the index start| 1
3132|vm_hostname_prefix|VM hostname prefix|vm
3233|memory|RAM in MB|1024
34+ |additional_disk_ids|List of volume ids to be attached to domain| [ ]
3335|hugepages|Use Hugepages|false
3436|vcpu|Number of vCPUs|1
3537|pool|Storage pool name|default
@@ -70,7 +72,7 @@ provider "libvirt" {
7072
7173module "vm" {
7274 source = "MonolithProjects/vm/libvirt"
73- version = "1.6 .0"
75+ version = "1.8 .0"
7476
7577 vm_hostname_prefix = "server"
7678 vm_count = 3
@@ -117,7 +119,7 @@ provider "libvirt" {
117119
118120module "vm" {
119121 source = "MonolithProjects/vm/libvirt"
120- version = "1.6 .0"
122+ version = "1.8 .0"
121123
122124 vm_hostname_prefix = "server"
123125 vm_count = 3
@@ -157,7 +159,48 @@ output "outputs" {
157159}
158160```
159161
160- The shared directory from the example can be mounted inside the VM with command ` sudo mount -t 9p -o trans=virtio,version=9p2000.L,rw tmp /host/tmp `
162+ > The shared directory from the example can be mounted inside the VM with command ` sudo mount -t 9p -o trans=virtio,version=9p2000.L,rw tmp /host/tmp `
163+
164+ Create a VM with an extra disk
165+
166+ ```
167+ # Creates a 50GB extra-data-disk within vms pool
168+ resource "libvirt_volume" "data_volume" {
169+ pool = "vms"
170+ name = "extra-data-disk.qcow2"
171+ format = "qcow2"
172+ size = 1024*1024*1024*50
173+ }
174+
175+ module "vm" {
176+ source = "MonolithProjects/vm/libvirt"
177+ version = "1.8.0"
178+
179+ vm_hostname_prefix = "data-server"
180+ base_volume_name = "debian-11-base.qcow2"
181+ base_pool_name = "linked-images"
182+ vm_count = 1
183+ bridge = "bridge-dmz"
184+ memory = "4096"
185+ hugepages = false
186+ vcpu = 4
187+ pool = "vms"
188+ system_volume = 25
189+ additional_disk_ids = [ libvirt_volume.data_volume.id ]
190+
191+ dhcp = true
192+
193+ ssh_admin = "admin"
194+ ssh_keys = [
195+ chomp(file("~/.ssh/id_rsa.pub"))
196+ ]
197+ time_zone = "America/Argentina/Buenos_Aires"
198+ }
199+
200+ output "ip_addresses" {
201+ value = module.vm
202+ }
203+ ```
161204
162205## Module output example
163206
0 commit comments