Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49fd2ba307 | ||
|
|
85ce271fd6 | ||
|
|
7548402542 | ||
|
|
9e0ce35712 | ||
|
|
c1e409780d | ||
|
|
5a2d32ea84 | ||
|
|
e3fab0e151 | ||
|
|
a1867b18c8 |
No files matched your search
@@ -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
|
||||
@@ -33,7 +35,9 @@ const worker3Ip = config.requireSecret("worker3Ip");
|
||||
|
||||
const templateSettings = {
|
||||
template: true,
|
||||
protection: true,
|
||||
started: false,
|
||||
operatingSystem: { type: "l26" },
|
||||
stopOnDestroy: true,
|
||||
scsiHardware: "virtio-scsi-pci",
|
||||
cdrom: { fileId: "none" },
|
||||
@@ -292,6 +296,7 @@ const k3sVms = nodeConfigs.map(
|
||||
{
|
||||
provider: node.host.provider,
|
||||
retainOnDelete: true,
|
||||
protect: true,
|
||||
ignoreChanges: [
|
||||
"clone",
|
||||
"started",
|
||||
@@ -321,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,
|
||||
|
||||
@@ -3,6 +3,20 @@ import * as command from "@pulumi/command";
|
||||
|
||||
const config = new pulumi.Config();
|
||||
|
||||
// Bootstrap commands run once, on a fresh install. Without this, a changed VM
|
||||
// ID or command would re-run the k3s installer on the live cluster. After
|
||||
// recreating a VM, re-run its commands explicitly with --target-replace.
|
||||
pulumi.runtime.registerResourceTransform((args) =>
|
||||
args.type.startsWith("command:")
|
||||
? {
|
||||
props: args.props,
|
||||
opts: pulumi.mergeOptions(args.opts, {
|
||||
ignoreChanges: ["create", "triggers"],
|
||||
}),
|
||||
}
|
||||
: undefined,
|
||||
);
|
||||
|
||||
const infraRef = new pulumi.StackReference(
|
||||
`${pulumi.getOrganization()}/proxmox-infra/dev`,
|
||||
);
|
||||
@@ -77,7 +91,7 @@ const startMaster1 = new command.local.Command("start-master-1", {
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
const startMaster2 = new command.local.Command("start-master-2", {
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve1ApiToken}" "${pve1Endpoint}/api2/json/nodes/pve/qemu/${master2VmId}/status/start" 2>/dev/null || true`,
|
||||
create: pulumi.interpolate`curl -sf -k -X POST -H "Authorization: PVEAPIToken=${pve3ApiToken}" "${pve3Endpoint}/api2/json/nodes/pve/qemu/${master2VmId}/status/start" 2>/dev/null || true`,
|
||||
triggers: [master2VmId],
|
||||
interpreter: ["/bin/bash", "-c"],
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user