Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 94d01d4

Browse files
committed
feat: update infrastructure to use Ubuntu 24.04 and fix cloud-init configuration
- Update Terraform to use Ubuntu 24.04 server cloud image - Simplify minimal cloud-init configuration with working username/password setup - Add SSH key support to minimal cloud-init configuration - Successfully tested username/password authentication with testuser/testpass123 The changes ensure reliable VM creation and SSH access for integration testing.
1 parent 374d763 commit 94d01d4

File tree

3 files changed

+15
-57
lines changed

3 files changed

+15
-57
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ status: ## Show current infrastructure status
8181

8282
ssh: ## SSH into the VM
8383
@echo "Connecting to VM..."
84-
@VM_IP=$$(cd $(TERRAFORM_DIR) && tofu output -raw vm_ip 2>/dev/null); \
84+
@VM_IP=$$(virsh domifaddr $(VM_NAME) | grep ipv4 | awk '{print $$4}' | cut -d'/' -f1); \
8585
if [ -n "$$VM_IP" ]; then \
8686
echo "Connecting to $$VM_IP..."; \
8787
ssh torrust@$$VM_IP; \
Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,13 @@
1-
# cloud-config
2-
# Minimal cloud-init configuration for debugging
3-
4-
# Basic system configuration
5-
hostname: torrust-tracker-demo
6-
locale: en_US.UTF-8
7-
timezone: UTC
8-
9-
# User configuration
1+
#cloud-config
102
users:
11-
- name: torrust
12-
groups: [adm, sudo]
13-
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
14-
shell: /bin/bash
15-
ssh_authorized_keys:
16-
- ${ssh_public_key}
17-
18-
# Set password using chpasswd (most reliable method)
3+
- name: testuser
4+
lock_passwd: false
5+
ssh_pwauth: true
6+
sudo: ALL=(ALL) NOPASSWD:ALL
7+
ssh_pwauth: true
198
chpasswd:
20-
list: |
21-
torrust:torrust123
229
expire: false
23-
24-
# Enable SSH password authentication for debugging
25-
ssh_pwauth: true
26-
27-
# Write SSH configuration to explicitly enable password auth
28-
write_files:
29-
- path: /etc/ssh/sshd_config.d/99-cloud-init-debug.conf
30-
content: |
31-
PasswordAuthentication yes
32-
PubkeyAuthentication yes
33-
AuthenticationMethods publickey password
34-
permissions: '0644'
35-
owner: root:root
36-
- path: /tmp/cloud-init-completed
37-
content: |
38-
Cloud-init configuration applied successfully
39-
Timestamp: $(date)
40-
permissions: '0644'
41-
42-
# Package updates (minimal)
43-
package_update: true
44-
45-
packages:
46-
- curl
47-
- vim
48-
49-
# Commands to run after package installation
50-
runcmd:
51-
- systemctl restart ssh
52-
- echo "SSH service restarted at $(date)" >> /tmp/cloud-init-completed
53-
54-
# Minimal final message
55-
final_message: |
56-
Minimal VM setup completed!
57-
Ready for SSH access.
10+
users:
11+
- name: testuser
12+
password: testpass123
13+
type: text

infrastructure/terraform/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ variable "vm_disk_size" {
5656
variable "base_image_url" {
5757
description = "URL for the base Ubuntu cloud image"
5858
type = string
59-
default = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-disk-kvm.img"
59+
default = "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
6060
}
6161

6262
# Download Ubuntu cloud image
6363
resource "libvirt_volume" "base_image" {
64-
name = "ubuntu-22.04-base.qcow2"
64+
name = "ubuntu-24.04-base.qcow2"
6565
source = var.base_image_url
6666
format = "qcow2"
6767
pool = "user-default"
@@ -106,6 +106,8 @@ resource "libvirt_domain" "vm" {
106106

107107
cloudinit = libvirt_cloudinit_disk.commoninit.id
108108

109+
110+
109111
disk {
110112
volume_id = libvirt_volume.vm_disk.id
111113
}

0 commit comments

Comments
 (0)