From 49fd2ba307cec319f16fb67b7e0e6b7d5cdfaf21 Mon Sep 17 00:00:00 2001 From: kasun Date: Sun, 22 Nov 2026 18:08:02 +0100 Subject: [PATCH] feature(proxmox-infra): add Ansible control node LXC Fix the container's MAC so its pfSense DHCP reservation exists before first boot. Otherwise the first lease could come from the dynamic pool. --- 01-proxmox-infra/index.ts | 76 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/01-proxmox-infra/index.ts b/01-proxmox-infra/index.ts index 3113c32..c1f0b24 100644 --- a/01-proxmox-infra/index.ts +++ b/01-proxmox-infra/index.ts @@ -25,6 +25,8 @@ const worker1Ip = config.requireSecret("worker1Ip"); const worker2Ip = config.requireSecret("worker2Ip"); const worker3Ip = config.requireSecret("worker3Ip"); +const ansibleIp = config.requireSecret("ansibleIp"); + // --------------------------------------------------------------------------- // VM templates — one per node, cloned from the downloaded cloud image. // Templates are not started and have no cloud-init config; that is applied @@ -35,6 +37,7 @@ const templateSettings = { template: true, protection: true, started: false, + operatingSystem: { type: "l26" }, stopOnDestroy: true, scsiHardware: "virtio-scsi-pci", cdrom: { fileId: "none" }, @@ -323,6 +326,79 @@ k3sVms.forEach((vmResource, i) => { ); }); +// --------------------------------------------------------------------------- +// Ansible control node — unprivileged LXC with a pfSense DHCP reservation. +// The MAC is fixed so the reservation can exist before the container's first +// boot; otherwise its first DHCP lease could come from the dynamic pool. +// --------------------------------------------------------------------------- + +const ansibleHost = hostFor("pve-b550"); +const ansibleMac = "02:A5:1B:00:01:54"; + +const ansibleTemplate = new proxmox.download.File( + "ubuntu-resolute-lxc-pve-b550", + { + nodeName: ansibleHost.nodeName, + datastoreId: ansibleHost.isoStore, + contentType: "vztmpl", + fileName: "ubuntu-26.04-standard_26.04-1_amd64.tar.zst", + url: "https://download.proxmox.com/images/system/ubuntu-26.04-standard_26.04-1_amd64.tar.zst", + overwrite: false, + overwriteUnmanaged: true, + }, + { provider: ansibleHost.provider }, +); + +const ansibleDhcp = new pfsense.Dhcpv4Staticmapping( + "ansible-dhcp", + { + interface: "lan", + macAddress: ansibleMac, + ipAddress: ansibleIp, + hostname: "ansible", + }, + { provider: pfSenseProvider }, +); + +new proxmox.ContainerLegacy( // NOSONAR typescript:S1848 + "ansible", + { + nodeName: ansibleHost.nodeName, + description: "Ansible control node — managed by Pulumi", + tags: ["ansible"], + unprivileged: true, + features: { nesting: true }, + operatingSystem: { + templateFileId: ansibleTemplate.id, + type: "ubuntu", + }, + cpu: { cores: 1 }, + memory: { dedicated: 1024, swap: 0 }, + disk: { datastoreId: ansibleHost.dataStore, size: 8 }, + networkInterfaces: [ + { name: "eth0", bridge: "vmbr0", macAddress: ansibleMac }, + ], + initialization: { + hostname: "ansible", + ipConfigs: [{ ipv4: { address: "dhcp" } }], + userAccount: { + keys: [ + pve1SshPublicKey.apply((k) => k.trim()), + pve2SshPublicKey.apply((k) => k.trim()), + pve3SshPublicKey.apply((k) => k.trim()), + ], + }, + }, + started: true, + startOnBoot: true, + }, + { + provider: ansibleHost.provider, + dependsOn: ansibleDhcp, + retainOnDelete: true, + }, +); + export const vmIds = { master1: k3sVms[0].vmId, master2: k3sVms[1].vmId, -- 2.54.1