mirror of
https://github.com/Noratrieb/vmlab.git
synced 2026-01-14 16:45:11 +01:00
bad things
This commit is contained in:
parent
0b4e5f1e27
commit
0b152a9001
10 changed files with 142 additions and 1 deletions
42
vm-setup/vm.tf
Normal file
42
vm-setup/vm.tf
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
locals {
|
||||
cloudinit_user_data = file("${path.module}/user-data")
|
||||
}
|
||||
|
||||
resource "libvirt_cloudinit_disk" "user_data" {
|
||||
name = "commoninit.iso"
|
||||
user_data = local.cloudinit_user_data
|
||||
}
|
||||
|
||||
resource "local_file" "debian-node-disk" {
|
||||
count = local.vm_count
|
||||
|
||||
content = ""
|
||||
filename = "${path.module}/state/debian-node-${count.index}.qcow2.stamp"
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = <<EOT
|
||||
cp "${path.module}/tmp/debian-12-generic-amd64-bigger.qcow2" "${path.module}/state/debian-node-${count.index}.qcow2"
|
||||
chmod 777 "${path.module}/state/debian-node-${count.index}.qcow2"
|
||||
EOT
|
||||
}
|
||||
}
|
||||
|
||||
resource "libvirt_domain" "debian-node" {
|
||||
count = local.vm_count
|
||||
name = "debian-node-${count.index}"
|
||||
|
||||
memory = "2048"
|
||||
vcpu = 2
|
||||
|
||||
cloudinit = libvirt_cloudinit_disk.user_data.id
|
||||
|
||||
network_interface {
|
||||
network_id = libvirt_network.lab.id
|
||||
hostname = "debian-node-${count.index}"
|
||||
addresses = ["10.0.1.${count.index+1}"]
|
||||
}
|
||||
|
||||
disk {
|
||||
file = "${abspath(path.module)}/state/debian-node-${count.index}.qcow2"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue