#cloud-config hostname: pxe-server fqdn: pxe-server.mynodes.xyz manage_etc_hosts: true users: - name: ilker sudo: ALL=(ALL) NOPASSWD:ALL shell: /bin/bash lock_passwd: true ssh_authorized_keys: - ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDSAJ4owXlJreHP3sa4HstasxA5pk1ZAPi6vnzOpA5R1 ilker@t440s package_update: true packages: - qemu-guest-agent - dnsmasq - pxelinux - syslinux-common - syslinux-efi - nftables - curl write_files: - path: /etc/dnsmasq.d/pxe.conf content: | # PXE/DHCP for SDN vnet pxenet (10.213.77.0/24). Only bound to the pxenet leg. interface=__PXEIF__ bind-interfaces domain-needed bogus-priv domain=pxe.local local=/pxe.local/ expand-hosts dhcp-range=10.213.77.100,10.213.77.200,255.255.255.0,12h dhcp-option=option:router,10.213.77.1 dhcp-option=option:dns-server,10.213.77.1 dhcp-authoritative enable-tftp tftp-root=/srv/tftp dhcp-match=set:efi64,option:client-arch,7 dhcp-match=set:efi64,option:client-arch,9 dhcp-match=set:bios,option:client-arch,0 dhcp-boot=tag:bios,pxelinux.0 dhcp-boot=tag:efi64,efi64/syslinux.efi log-dhcp # rollcall writes static node leases / names here and HUPs dnsmasq dhcp-hostsfile=/var/lib/rollcall/dnsmasq/hosts.dhcp addn-hosts=/var/lib/rollcall/dnsmasq/hosts - path: /srv/tftp/pxelinux.cfg/default content: | DEFAULT menu.c32 PROMPT 0 TIMEOUT 300 MENU TITLE pxe-server (10.213.77.1) - PXE menu LABEL netbootxyz MENU LABEL netboot.xyz (internet gerekir, NAT uzerinden) KERNEL netboot.xyz.lkrn LABEL local MENU LABEL Yerel diskten boot LOCALBOOT 0 - path: /etc/nftables.conf permissions: '0755' content: | #!/usr/sbin/nft -f flush ruleset table ip nat { chain postrouting { type nat hook postrouting priority 100; oifname "__EXTIF__" ip saddr 10.213.77.0/24 masquerade } } - path: /etc/sysctl.d/99-pxe-forward.conf content: | net.ipv4.ip_forward=1 runcmd: - sysctl --system - PXEIF=$(ip -o -4 addr show | awk '/10\.213\.77\.1\//{print $2}'); sed -i "s/__PXEIF__/$PXEIF/" /etc/dnsmasq.d/pxe.conf - EXTIF=$(ip -o -4 route show default | awk '{print $5; exit}'); sed -i "s/__EXTIF__/$EXTIF/" /etc/nftables.conf - mkdir -p /srv/tftp/efi64 - cp /usr/lib/PXELINUX/pxelinux.0 /srv/tftp/ - cp /usr/lib/syslinux/modules/bios/ldlinux.c32 /usr/lib/syslinux/modules/bios/menu.c32 /usr/lib/syslinux/modules/bios/libutil.c32 /usr/lib/syslinux/modules/bios/libcom32.c32 /srv/tftp/ - cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi /srv/tftp/efi64/ - cp /usr/lib/syslinux/modules/efi64/ldlinux.e64 /usr/lib/syslinux/modules/efi64/menu.c32 /usr/lib/syslinux/modules/efi64/libutil.c32 /usr/lib/syslinux/modules/efi64/libcom32.c32 /srv/tftp/efi64/ - ln -sfn ../pxelinux.cfg /srv/tftp/efi64/pxelinux.cfg - curl -fsSL --retry 3 -o /srv/tftp/netboot.xyz.lkrn https://boot.netboot.xyz/ipxe/netboot.xyz.lkrn || true - systemctl enable --now nftables - systemctl enable --now qemu-guest-agent - systemctl restart dnsmasq - systemctl enable dnsmasq