Add support for Ubuntu containers and WSL verification

- Implemented tasks for managing Ubuntu containers using Podman, including inspection, creation, starting, and SSH setup.
- Added verification tasks for WSL and Podman installation, machine existence, and NSSM service status.
- Created PowerShell scripts for Podman auto-start on Windows boot.
- Introduced Prometheus role with default configurations and installation tasks.
- Updated Windows SSH role to improve authorized_keys management and permissions handling.
- Modified inventory to include Windows containers host.
- Updated Grafana datasource configurations with direct IP addresses for Prometheus instances.
This commit is contained in:
2026-06-07 20:35:59 +02:00
parent 3775fa4b6e
commit 25d3eafa5b
34 changed files with 1475 additions and 155 deletions
@@ -0,0 +1,2 @@
@echo off
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0auto-start-podman.ps1"
@@ -0,0 +1,71 @@
# Podman auto-start on Windows boot
# Runs as {{ windows_containers_service_user }} (set via NSSM ObjectName)
$ErrorActionPreference = "Stop"
$LogDir = "C:\Logs\Podman"
$LogTimestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
$MachineName = "{{ windows_containers_machine_name }}"
function Write-Log {
param([string]$LogName, [System.Collections.ArrayList]$Messages)
$Log = Join-Path $LogDir "$LogName-$LogTimestamp.log"
$lines = @()
foreach ($m in $Messages) {
$lines += "$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') $m"
}
[System.IO.File]::WriteAllText($Log, ($lines -join "`r`n") + "`r`n", [System.Text.Encoding]::UTF8)
}
try {
$bootMessages = [System.Collections.ArrayList]::new()
$bootMessages.Add("Starting Podman auto-start process") > $null
# Check if machine is already running
$listOutput = & "{{ windows_containers_install_dir }}\podman.exe" @('machine', 'list', '--format', 'table {{ '{{' }}.Name{{ '}}' }}\t{{ '{{' }}.Running{{ '}}' }}') 2>&1 | Out-String
$listExit = $LASTEXITCODE
$bootMessages.Add("Machine list exit code: $listExit") > $null
$bootMessages.Add("Machine list output: $listOutput") > $null
$running = ($listOutput -match "$MachineName\s+true")
if ($running) {
$bootMessages.Add("Machine is already running") > $null
} else {
$startOutput = & "{{ windows_containers_install_dir }}\podman.exe" @('machine', 'start', $MachineName) 2>&1 | Out-String
$bootMessages.Add("Machine start output: $startOutput") > $null
if ($LASTEXITCODE -ne 0) {
Write-Log "auto-start" $bootMessages
exit 1
}
}
# Wait for the machine to be ready (poll podman info)
$bootMessages.Add("Waiting for machine to be ready...") > $null
$ready = $false
for ($i = 0; $i -lt 90; $i++) {
$infoOutput = & "{{ windows_containers_install_dir }}\podman.exe" @('info', '--format', 'json') 2>&1 | Out-String
if ($LASTEXITCODE -eq 0 -and $infoOutput -and $infoOutput.Trim()) {
$ready = true
$bootMessages.Add("Machine is ready after $(($i + 1) * 2) seconds") > $null
break
}
Start-Sleep -Seconds 2
}
if (-not $ready) {
Write-Log "auto-start" $bootMessages
exit 1
}
# Start any stopped containers
$startContainersOutput = & "{{ windows_containers_install_dir }}\podman.exe" @('start', '-a') 2>&1 | Out-String
$bootMessages.Add("Container start output: $startContainersOutput") > $null
$bootMessages.Add("Podman auto-start complete") > $null
Write-Log "auto-start" $bootMessages
} catch {
$errMessages = [System.Collections.ArrayList]::new()
$errMessages.Add("Podman auto-start failed: $_") > $null
$errMessages.Add("Stack trace: $($_.ScriptStackTrace)") > $null
Write-Log "auto-start-ERROR" $errMessages
exit 1
}