Compare commits

...

5 Commits

Author SHA1 Message Date
Lukas Greve
8d451e12d2 remove unnecessary file 2025-09-10 20:54:28 +02:00
Lukas Greve
c68ca02018 add another output, but does not seem to return anything for the moment 2025-09-10 20:54:10 +02:00
Lukas Greve
727903412f ssh public key now defined as variable. User can define it under the main deployment file 2025-09-10 20:53:54 +02:00
Lukas Greve
af31f8c4b2 ignore aider-related files 2025-09-10 20:52:24 +02:00
Lukas Greve
3498b877c8 feat: add ssh_key variable support to cloud-init module 2025-09-10 20:40:25 +02:00
8 changed files with 42 additions and 23 deletions

16
.gitignore vendored Normal file
View File

@@ -0,0 +1,16 @@
# Terraform
.terraform/
.terraform.lock.hcl
*.tfstate
*.tfstate.backup
*.tfstate.lock.info
terraform.tfvars
terraform.tfvars.example
# Terraform plan and output files
*.tfplan
*.tfout
# Aider files
*.aider*

View File

@@ -1,11 +0,0 @@
#cloud-config
disable_root: true
users:
- name: groot
sudo: ALL=(ALL) NOPASSWD:ALL
groups: wheel,sudo,adm
shell: /bin/bash
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDMSuVlvOsMqx9qOrKKB1295FjCf2QhHfR1qola9brGkUcFL9dAztG2qdQnpiuPQ4OJpkedrO3C/ixEw1MLTL8l12SvYy/Q9QFguwylp35Nbw1p8h7jrX1FcNLRYltxkMgVhCs1InT5m0lf56bu1h7JfsMs7Ovsy3lU5OdK4h2MysTSKOLctsE4jDJ+XbJYQzj4rbfB/U7/9ple366cGl6xlaHxVfI4BUFWUOiVU4HWvZjrOM5fqPt+AUFRx1l2D7hLUZgOdVQwgO8GFn0sCyCIw0NCXbDn/H05pvWtTUPnyhj5TiseF8qW1byrrT5G8saxwvx8nbIK2tpPfKFdIiL7aj9bYQdltn1knJtvk3hpTPy4QvAbaoGfnfrPAsyU1A/CTw9SD/idvDT2wt1hVsm8EsnpovF7WT5z22fcgoFLDo+QCQrp7t1Wx0/Djay2nThi3FO3N051y5fQWoKOvTsm+rRhrzpDoc+Wtrtss3ua54qnQxHRx3YC0M5Xl9DINkwrcunbZBhozsDG2DzX9qcyzJsSfm9Zt5yM2lpcq+dGPRO1wedw4ogoOpobRr9Cja9W/lJvxmjgIiHz2HbSFPtk/VGjL6M7aQor/GDNN3ugSsfUoTTmNaS9+lWeg+tQWcFUPhYQtQB4/gHQ2u7+mQ0H3hVybsIKIh5XBpAdHQ7pww== lukas@home
ssh_pwauth: false

View File

@@ -17,4 +17,5 @@ module "shared_modules" {
vm_name = "ubuntu-cloud-server-2404-bios"
image_location = "/var/lib/libvirt/images/noble-server-cloudimg-amd64.img"
ssh_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDMSuVlvOsMqx9qOrKKB1295FjCf2QhHfR1qola9brGkUcFL9dAztG2qdQnpiuPQ4OJpkedrO3C/ixEw1MLTL8l12SvYy/Q9QFguwylp35Nbw1p8h7jrX1FcNLRYltxkMgVhCs1InT5m0lf56bu1h7JfsMs7Ovsy3lU5OdK4h2MysTSKOLctsE4jDJ+XbJYQzj4rbfB/U7/9ple366cGl6xlaHxVfI4BUFWUOiVU4HWvZjrOM5fqPt+AUFRx1l2D7hLUZgOdVQwgO8GFn0sCyCIw0NCXbDn/H05pvWtTUPnyhj5TiseF8qW1byrrT5G8saxwvx8nbIK2tpPfKFdIiL7aj9bYQdltn1knJtvk3hpTPy4QvAbaoGfnfrPAsyU1A/CTw9SD/idvDT2wt1hVsm8EsnpovF7WT5z22fcgoFLDo+QCQrp7t1Wx0/Djay2nThi3FO3N051y5fQWoKOvTsm+rRhrzpDoc+Wtrtss3ua54qnQxHRx3YC0M5Xl9DINkwrcunbZBhozsDG2DzX9qcyzJsSfm9Zt5yM2lpcq+dGPRO1wedw4ogoOpobRr9Cja9W/lJvxmjgIiHz2HbSFPtk/VGjL6M7aQor/GDNN3ugSsfUoTTmNaS9+lWeg+tQWcFUPhYQtQB4/gHQ2u7+mQ0H3hVybsIKIh5XBpAdHQ7pww=="
}

View File

@@ -1,6 +1,8 @@
resource "libvirt_cloudinit_disk" "commoninit" {
name = var.cloudinit_filename
user_data = templatefile("${path.module}/../environments/cloud_init.yaml", {})
pool = var.pool_name
name = var.cloudinit_filename
user_data = templatefile("${path.module}/cloud_init.yaml", {
ssh_key = var.ssh_key
})
pool = var.pool_name
depends_on = [libvirt_pool.tf_tmp_storage]
}

View File

@@ -0,0 +1,10 @@
#cloud-config
disable_root: true
users:
- name: groot
sudo: ALL=(ALL) NOPASSWD:ALL
groups: wheel,sudo,adm
shell: /bin/bash
ssh_authorized_keys:
- ${ssh_key}
ssh_pwauth: false

View File

@@ -38,3 +38,7 @@ output "volume_ids" {
output "instance_count" {
value = var.instance_count
}
output "cloud_init_rendered" {
value = templatefile("${path.module}/cloud_init.yaml", {ssh_key = var.ssh_key})
}

View File

@@ -1,9 +0,0 @@
terraform {
required_version = ">= 0.13"
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "0.8.3"
}
}
}

View File

@@ -39,6 +39,12 @@ variable "cloudinit_filename" {
type = string
default = "commoninit.iso"
}
variable "ssh_key" {
description = "SSH authorized keys for cloud-init"
type = string
}
variable "user_data" {
description = "User data for cloud-init"
type = string