-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
67 lines (51 loc) · 1.42 KB
/
main.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
data "harvester_image" "img" {
display_name = var.img_display_name
namespace = "harvester-public"
}
data "harvester_ssh_key" "mysshkey" {
name = var.public_key
namespace = var.namespace
}
resource "random_id" "secret" {
byte_length = 5
}
resource "harvester_cloudinit_secret" "cloud-config" {
name = "cloud-config-${random_id.secret.hex}"
namespace = var.namespace
user_data = templatefile("cloud-init.tmpl.yml", {
public_key_openssh = data.harvester_ssh_key.mysshkey.public_key
})
}
resource "harvester_virtualmachine" "vm" {
count = var.vm_count
name = "${var.prefix}${format("%02d", count.index + 1)}"
namespace = var.namespace
restart_after_update = true
description = "Demo VM"
cpu = 2
memory = "4Gi"
efi = true
secure_boot = true
run_strategy = "RerunOnFailure"
hostname = "${var.prefix}${format("%02d", count.index + 1)}"
reserved_memory = "100Mi"
machine_type = "q35"
network_interface {
name = "nic-1"
wait_for_lease = true
type = "bridge"
network_name = var.network_name
}
disk {
name = "rootdisk"
type = "disk"
size = "30Gi"
bus = "virtio"
boot_order = 1
image = data.harvester_image.img.id
auto_delete = true
}
cloudinit {
user_data_secret_name = harvester_cloudinit_secret.cloud-config.name
}
}