blob: 4b9965db849440fae811490bdb20c44094f31a52 (
plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
terraform {
backend "http" {}
}
variable "machine_name" {
type = "string"
}
variable "uri" {
type = "string"
}
variable "vm_image_and_system" {
type = "string"
}
provider "libvirt" {
uri = "${var.uri}"
}
resource "libvirt_network" "vm_network" {
name = "vm_network"
addresses = ["10.0.1.0/24"]
}
# Create the machine
resource "libvirt_domain" "domain-ubuntu" {
name = "${var.machine_name}"
memory = "8196"
vcpu = 4
kernel = "${var.vm_image_and_system}/system/kernel/bzImage"
initrd = "${var.vm_image_and_system}/system/initrd"
cmdline {
"--root" = "/dev/vda1"
"--system" = "${var.vm_image_and_system}/system"
"--load" = "${var.vm_image_and_system}/system/boot"
}
filesystem {
source = "/gnu/store"
target = "TAG_gnu_store"
readonly = true
accessmode = "passthrough"
}
disk {
file = "${var.vm_image_and_system}/image"
readonly = true
}
network_interface {
network_name = "${libvirt_network.vm_network.name}"
}
console {
type = "pty"
target_port = "0"
target_type = "serial"
}
console {
type = "pty"
target_type = "virtio"
target_port = "1"
}
}
|