-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkvm3.tf
43 lines (34 loc) · 916 Bytes
/
kvm3.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
provider "libvirt" {
alias = "kvm3"
uri = "qemu+ssh://${data.sops_file.hypervisors.data["kvm3.user"]}@${data.sops_file.hypervisors.data["kvm3.address"]}/system"
}
resource "libvirt_pool" "kvm3" {
provider = libvirt.kvm3
name = "default"
type = "dir"
path = "/var/lib/libvirt/images"
}
resource "libvirt_network" "kvm3" {
provider = libvirt.kvm3
name = "default"
mode = "nat"
domain = "default"
addresses = ["0.0.0.0/0"]
autostart = true
}
resource "libvirt_volume" "kvm3_os_images" {
for_each = var.os_images
provider = libvirt.kvm3
name = "${replace(each.key, "_", "-")}.${var.os_image_format}"
pool = libvirt_pool.kvm3.name
source = each.value
format = var.os_image_format
}
output "kvm3_pool_name" {
value = libvirt_pool.kvm3.name
}
output "kvm3_os_images" {
value = {
for os, volume in libvirt_volume.kvm3_os_images : os => volume.id
}
}