@@ -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
@@ -80,6 +81,7 @@ No modules.
8081| <a name =" output_ip_address " ></a > [ ip\_ address] ( #output\_ ip\_ address ) | n/a |
8182| <a name =" output_name " ></a > [ name] ( #output\_ name ) | n/a |
8283<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
84+
8385## Example
8486
8587Example with enable HugePages, Attached USB device, changed USB controller model... :
@@ -100,7 +102,7 @@ provider "libvirt" {
100102
101103module "vm" {
102104 source = "MonolithProjects/vm/libvirt"
103- version = "1.6 .0"
105+ version = "1.8 .0"
104106
105107 vm_hostname_prefix = "server"
106108 vm_count = 3
@@ -158,7 +160,7 @@ provider "libvirt" {
158160
159161module "vm" {
160162 source = "MonolithProjects/vm/libvirt"
161- version = "1.6 .0"
163+ version = "1.8 .0"
162164
163165 vm_hostname_prefix = "server"
164166 vm_count = 3
@@ -197,7 +199,45 @@ output "outputs" {
197199}
198200```
199201
200- 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 `
202+ > 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 `
203+
204+ Create a VM with an extra disk
205+
206+ ```
207+ # Creates a 50GB extra-data-disk within vms pool
208+ resource "libvirt_volume" "data_volume" {
209+ pool = "vms"
210+ name = "extra-data-disk.qcow2"
211+ format = "qcow2"
212+ size = 1024*1024*1024*50
213+ }
214+
215+ module "vm" {
216+ source = "MonolithProjects/vm/libvirt"
217+ version = "1.8.0"
218+
219+ vm_hostname_prefix = "data-server"
220+ base_volume_name = "debian-11-base.qcow2"
221+ base_pool_name = "linked-images"
222+ vm_count = 1
223+ bridge = "bridge-dmz"
224+ memory = "4096"
225+ vcpu = 4
226+ pool = "vms"
227+ system_volume = 25
228+ additional_disk_ids = [ libvirt_volume.data_volume.id ]
229+ dhcp = true
230+ ssh_admin = "admin"
231+ ssh_keys = [
232+ chomp(file("~/.ssh/id_rsa.pub"))
233+ ]
234+ time_zone = "America/Argentina/Buenos_Aires"
235+ }
236+
237+ output "ip_addresses" {
238+ value = module.vm
239+ }
240+ ```
201241
202242## Module output example
203243
0 commit comments