@@ -12,6 +12,7 @@ Terraform module for KVM/Libvirt Virtual Machine. This module will create a KVM
12
12
- one NIC per domain, connected to the network using the ** bridge interface**
13
13
- setup network interface using DHCP or static configuration
14
14
- cloud_init VM(s) configuration (Ubuntu+Netplan complient)
15
+ - optionally add multiple extra disks
15
16
- test the ssh connection
16
17
17
18
## Tested on
@@ -30,6 +31,7 @@ Terraform module for KVM/Libvirt Virtual Machine. This module will create a KVM
30
31
|index_start|From where the index start| 1
31
32
|vm_hostname_prefix|VM hostname prefix|vm
32
33
|memory|RAM in MB|1024
34
+ |additional_disk_ids|List of volume ids to be attached to domain| [ ]
33
35
|hugepages|Use Hugepages|false
34
36
|vcpu|Number of vCPUs|1
35
37
|pool|Storage pool name|default
@@ -70,7 +72,7 @@ provider "libvirt" {
70
72
71
73
module "vm" {
72
74
source = "MonolithProjects/vm/libvirt"
73
- version = "1.6 .0"
75
+ version = "1.8 .0"
74
76
75
77
vm_hostname_prefix = "server"
76
78
vm_count = 3
@@ -117,7 +119,7 @@ provider "libvirt" {
117
119
118
120
module "vm" {
119
121
source = "MonolithProjects/vm/libvirt"
120
- version = "1.6 .0"
122
+ version = "1.8 .0"
121
123
122
124
vm_hostname_prefix = "server"
123
125
vm_count = 3
@@ -157,7 +159,48 @@ output "outputs" {
157
159
}
158
160
```
159
161
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
+ ```
161
204
162
205
## Module output example
163
206
0 commit comments