- PowerShell 44.3%
- Jinja 37.5%
- RouterOS Script 18.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
The sentence about orange's separate AMT address (.232) read as the current state and said the containers were "on the same NIC", which is no longer true. Reword it as the reason AMT shares the OS address, with the unconfirmed mechanism, and note that both hosts now keep containers and VMs off the AMT NIC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K6mwbKNCvktDruXkhYPPQ5 |
||
| inventory | ||
| network | ||
| playbooks | ||
| roles | ||
| .gitignore | ||
| ansible.cfg | ||
| pyproject.toml | ||
| README.md | ||
| requirements.yml | ||
| uv.lock | ||
picorealm-infra
- Purpose
- Conventions
- Address plan
- Layout
- Control node setup
- First run
- Hyper-V host layout
- Switching to SSH keys
- Virtual machines
- Licensing
- Roadmap
Purpose
Infrastructure-as-code for the picorealm environment: a homelab modeled on how real organizations (healthcare, government, universities) build and run Windows infrastructure. This repo is the single source of truth for host names, addresses, and configuration.
Build flow for a Windows host: autounattend.xml does only the bootstrap (disk, edition, Administrator password, SSH enabled), then Ansible applies everything else. See ms-server-install-automation.md for the install side.
Conventions
| Item | Value |
|---|---|
| Public domain | picorealm.net (Cloudflare; no records under ad.) |
| AD domain | ad.picorealm.net — single forest, single domain |
| NetBIOS name | PICO |
| UPN suffix | picorealm.net |
| Site code | SFO1 (nearest airport + building number); geography goes in AD Sites, not domain names |
| Hostnames | <SITE>-<ROLE><NN>, max 15 characters (e.g. SFO1-HV01) |
| Time zone | US Mountain Standard Time on all machines |
| Diagnostic data | 1 (Required), matching autounattend.xml |
Tier 0 systems (DCs, PKI, Entra Connect) never run on orange or on any host that serves internet-facing workloads.
Address plan
- Home LAN
192.168.12.0/24 - gateway BGW320 (
.1) - BGW320 can only reserve addresses inside its DHCP pool, so static addresses (servers, AMT) live outside it
| Range | Use |
|---|---|
.1 |
Gateway (BGW320) |
.2–.19 |
Network infrastructure: |
Pi-hole .2 (macvlan container on orange) |
|
SFO1-SW01 (MikroTik CRS125-24G-1S) .3 |
|
Brother printer .18 |
|
.20–.99 |
Static servers: |
SFO1-HV01 .21 |
|
SFO1-DC01 .22 (VM) |
|
orange .35 |
|
Forgejo .50 (macvlan container on orange) |
|
.100–.199 |
BGW320 DHCP pool and reservations |
.200–.229 |
Spare |
.230–.239 |
Reserved: out-of-band management with its own |
| address (BMCs, AMT on a NIC with a single MAC). | |
| Currently unused | |
.240–.254 |
Spare |
orange separates its own traffic from its workloads (like SFO1-HV01):
eno1(onboard I219-LM, shared with AMT) carries the host's addressesenp4s0(RTL8125B, to SFO1-SW01) is the only port of the bridgebr-work, which has no host address and is the parent of thelan-macvlanDocker network (Pi-hole, Forgejo) and the bridge for KVM VMs.- Because the containers' parent is not the host's own interface, orange can reach them (a macvlan child cannot talk to its parent interface, which was the case while both were on
br0). - List the macvlan containers on orange with
docker network ls --filter driver=macvlan -q | xargs -r docker network inspect -f '{{range .Containers}}{{.Name}} {{.IPv4Address}}{{"\n"}}{{end}}'.
AMT on both OptiPlexes shares the OS address (static inside AMT: SFO1-HV01 .21, orange .35); on that address AMT owns ports 16992–16995, 623 and 664.
Why AMT shares the OS address: when orange's AMT had its own address (.232), the macvlan containers (Pi-hole, Forgejo), then on br0 and so on the same NIC as AMT, were only intermittently reachable; they were stable once AMT shared .35. The likely cause is the NIC's receive filtering for the containers' extra MACs, which the ME partly controls (unconfirmed). Since then both hosts also keep containers and VMs off the AMT NIC entirely (br-work on orange, vSwitch-LAN on SFO1-HV01), so .230–.239 is only for AMT on a NIC that carries a single MAC.
Per-host addresses are recorded in inventory/hosts.yml (ansible_host, amt_ip).
Layout
ansible.cfg
requirements.yml collections: ansible.windows, community.windows, microsoft.ad
pyproject.toml, uv.lock control-node toolchain (ansible-core), managed by uv
inventory/
hosts.yml hosts and groups (windows > hyperv_hosts)
group_vars/all.yml org-wide settings (domain, site, time zone)
group_vars/windows/vars.yml Windows connection + baseline settings
group_vars/windows/vault.yml encrypted secrets (create from vault.yml.example)
group_vars/hyperv_hosts.yml Hyper-V host settings shared by hyperv_host and hyperv_vm (switch name)
playbooks/site.yml Hyper-V hosts (baseline, host, VMs), then VMs (first contact, baseline)
playbooks/network.yml static management address (windows_mgmt_network role)
roles/windows_baseline/ hostname, time zone, sshd + firewall, WER, telemetry, local admin, PowerShell 7
roles/hyperv_host/ Hyper-V role, VM storage volume (ReFS), default VM paths, external vSwitch
roles/hyperv_vm/ builds VMs from the ISO (image applied to a VHDX + unattend.xml), Gen 2 on vSwitch-LAN
roles/windows_mgmt_network/ static IP on the adapter matching mgmt_mac, DNS servers
network/sfo1-sw01.rsc SFO1-SW01 baseline RouterOS config (applied with reset-configuration run-after-reset)
Control node setup
- Runs from lumina (Ubuntu 24.04 under WSL2 on BACCHARIS, mirrored networking)
- Keep the clone in the WSL filesystem (e.g.
~/src/picorealm-infra), not under/mnt/c, which is slow and breaks file permissions - Default branch:
master
The control-node toolchain belongs to the repo, so every clone gets the same versions:
- ansible-core is a uv project dependency, pinned in
uv.lock(pyproject.tomldeclares it; Ubuntu's packaged ansible-core is too old for Windows over SSH, officially supported from 2.18). - Collections install into
./collections(collections_pathinansible.cfg; ignored by git), fromrequirements.yml. .venv/is created by uv and ignored by git.
Install sshpass (needed for the first, password-based run), then create the virtual environment from the lock file and install the collections:
sudo apt install sshpass && uv sync && uv run ansible-galaxy collection install -r requirements.yml
Run every Ansible command through uv run (e.g. uv run ansible-playbook ...), or activate the environment once per shell with source .venv/bin/activate. To upgrade ansible-core: uv lock --upgrade-package ansible-core && uv sync, then commit uv.lock.
Create and encrypt the vault, then set vault_windows_admin_password to the host's current Administrator password:
cp inventory/group_vars/windows/vault.yml.example inventory/group_vars/windows/vault.yml && uv run ansible-vault encrypt inventory/group_vars/windows/vault.yml
Set pwsh_version in inventory/group_vars/windows/vars.yml to the current PowerShell LTS release (the play stops with an assertion if it's empty).
First run
SFO1-HV01 still has its DHCP address (.125) until playbooks/network.yml has run, so pass it as mgmt_bootstrap_ip until then. Accept the host key once, so host key checking passes:
ssh Administrator@192.168.12.125 exit
Check connectivity, then apply the baseline:
uv run ansible windows -m ansible.windows.win_ping --ask-vault-pass -e mgmt_bootstrap_ip=192.168.12.125
uv run ansible-playbook playbooks/site.yml --ask-vault-pass -e mgmt_bootstrap_ip=192.168.12.125
The first run renames the host to SFO1-HV01 and reboots it, then reboots again after installing Hyper-V. Both reboots are handled by win_reboot. Re-running the playbook should report no changes; anything that changes on a re-run is drift or a non-idempotent task worth fixing.
Then move the host to its static address (mgmt_ip, .21). Do this near the machine: if it fails, recovery is the local console (sconfig). The change runs as a one-time scheduled task on the host (it would kill the SSH session otherwise); Ansible copies the trusted host key to the new address, reconnects there, and cleans up. The script's log is C:\ProgramData\picorealm\set-mgmt-ip.log.
uv run ansible-playbook playbooks/network.yml --ask-vault-pass -e mgmt_bootstrap_ip=192.168.12.125
Afterwards, drop -e mgmt_bootstrap_ip, remove the .125 reservation on the BGW320, and point the Pi-hole record sfo1-hv01.dunes.ixlo.net at .21.
Hyper-V host layout
SFO1-HV01 separates host management from VM traffic, as production Hyper-V hosts do:
| NIC | Carries | Inventory |
|---|---|---|
| Onboard I219-LM | Host management (.21) and AMT (sharing .21) |
mgmt_mac |
| RTL8125B (M.2 A+E), to SFO1-SW01 | VM traffic only: external switch vSwitch-LAN, AllowManagementOS = false (the host has no address on it) |
vm_switch_mac |
VMs live on a dedicated ReFS volume V: ("VMs") on the 850 EVO, found by serial number (vm_storage_disk_serial); Hyper-V's default paths point there (V:\Hyper-V, V:\Hyper-V\Virtual Hard Disks).
The role never erases a disk silently: if the VM disk holds partitions that aren't the VMs volume (e.g. the old ESXi install), the play stops. Erase it once, deliberately:
uv run ansible-playbook playbooks/site.yml --ask-vault-pass -e vm_storage_allow_wipe=true
Later runs find the volume and change nothing; never leave vm_storage_allow_wipe set anywhere persistent.
Switching to SSH keys
Add the control node's public key to windows_admin_ssh_pubkeys in inventory/group_vars/windows/vars.yml and run the playbook. The role writes C:\ProgramData\ssh\administrators_authorized_keys (the file sshd uses for members of Administrators, instead of the user's .ssh folder) and restricts it to Administrators and SYSTEM, without which sshd ignores it. Once key login works, remove ansible_password from vars.yml. New VMs get these keys when they are built, so they never need a password for Ansible.
Virtual machines
VMs are hosts in the inventory group hyperv_vms (domain controllers in its child group domain_controllers), with vm_host naming the Hyper-V host that builds and runs them. site.yml creates any that don't exist yet, then baselines them like any other Windows host.
How a VM is built (roles/hyperv_vm), without an interactive Windows Setup:
- The image named
hyperv_vm_image_name(set ingroup_vars/hyperv_hosts.yml: Windows Server 2025 Standard Evaluation, Server Core; see Licensing) is applied from the ISO'sinstall.wimstraight to a new dynamic VHDX inV:\Hyper-V\Virtual Hard Disks, made bootable withbcdboot. - An
unattend.xmlrendered from the inventory goes into the image: computer name, time zone, static address on the NIC with the VM's fixed MAC (mgmt_mac), DNS servers, Administrator password (from the vault), and specialize-pass commands that enable sshd. windows_admin_ssh_pubkeysis placed inC:\ProgramData\ssh\administrators_authorized_keys, so Ansible connects with keys from the first boot.- The VM is Generation 2 with Secure Boot, fixed memory, starts and stops with the host, and has automatic checkpoints off. Domain controllers also have Hyper-V time synchronization off (
vm_disable_time_sync). - The second play waits for SSH, trusts the new host key on first contact, waits for Windows Setup to finish, and applies
windows_baseline.
Copy the install ISO to the host once (from lumina, with the ISO in your home folder):
ssh Administrator@192.168.12.21 "New-Item -ItemType Directory -Force V:\ISO | Out-Null" && scp ~/WindowsServer2025.iso Administrator@192.168.12.21:V:/ISO/WindowsServer2025.iso
To rebuild a VM from scratch: on the host, Stop-VM <name> -TurnOff; Remove-VM <name> -Force, then delete its VHDX from V:\Hyper-V\Virtual Hard Disks; on lumina, remove its old host key with ssh-keygen -R <ip>; then run site.yml.
Licensing
The install media is the Windows Server 2025 evaluation ISO (26100.32230…SERVER_EVAL…iso). Each machine is converted to a licensed edition after it is built:
| Machine | Installed image (edition ID) | Converted to | Activation |
|---|---|---|---|
| SFO1-HV01 | Datacenter Evaluation, Server Core (ServerDatacenterEvalCor) |
ServerDatacenterCor |
Purchased Datacenter key; licenses unlimited Windows Server VMs on this host |
| VMs (SFO1-DC01, …) | Standard Evaluation, Server Core (ServerStandardEvalCor) |
ServerStandardCor |
AVMA: the VM activates against the activated Datacenter host, no per-VM key |
- An install converts only to its own edition or higher: Standard Evaluation to Standard or Datacenter, Datacenter Evaluation to Datacenter only. That is why VMs are built from the Standard image.
- Server Core stays Server Core; on Server Core the edition IDs end in
Cor.ServerTurbineCor(Datacenter: Azure Edition) only runs on Azure and Azure Local. - A domain controller can't be converted: convert a VM before promoting it.
Check what an install is and can become:
DISM /Online /Get-CurrentEdition; DISM /Online /Get-TargetEditions
Convert a VM with the KMS client setup key (GVLK) for Server 2025 Standard, then install the AVMA key for Server 2025 Standard; take both from Microsoft's documentation ("Key Management Services (KMS) client activation and product keys", "Automatic Virtual Machine Activation"):
DISM /Online /Set-Edition:ServerStandardCor /ProductKey:<GVLK> /AcceptEula
slmgr /ipk <AVMA key>
slmgr /dlv shows the edition and License Status.
Roadmap
- Intel drivers on SFO1-HV01 (chipset INF, MEI, UHD 630 graphics) in
hyperv_host; graphics is installed by hand for now. - Promote SFO1-DC01 (forest root for
ad.picorealm.net), then a second DC: AD SiteSFO1, UPN suffix, DNS forwarders to a filtering public resolver, conditional forwarders to Pi-hole for self-hosted zones, Pi-hole conditional forward forad.picorealm.net. - Domain join (
microsoft.ad.membership), DNS pointed at the DCs only, Windows LAPS for the local Administrator. - Move telemetry and password policy to GPO; Prometheus
windows_exporterscraped from orange. - Later: member servers on orange's KVM (non-Tier 0, virtio drivers), MECM, Azure Arc.