Fix WinPE SMB auth and timeout commands, restore autoinstall disk match

- Add /user:pxe-upload pxe credentials to all net use commands (share requires auth)
- Replace timeout with ping delays (timeout.exe not available in WinPE)
- Restore size: largest disk match in autoinstall (root cause was BIOS RST mode)
- Simplify autoinstall late-commands structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-02-16 15:32:39 -05:00
parent a4abd238de
commit 5de807143b
3 changed files with 31 additions and 49 deletions

View File

@@ -35,7 +35,7 @@ autoinstall:
identity:
hostname: pxeserver
username: pxe
password: '$6$8AerqUockJh6ycgl$HJFBYjiFqXpzgcU9edto4CMrnaDpEX71Epin.kNTpj57GVjimIDHhcQs0AC4tmkEkKUaj.S/55wsBfMsV0KC71'
password: '$6$MV3UwfSxKqxDYCwt$2IPUfSvqpzUdH6QVKHfPH8I9E0SPqNCh0lLvn.D9btxhZUYmceOGcB51Ryfg1Fojlroin.qguSKYFoIDGUIC20'
# Enable SSH
ssh:
@@ -44,7 +44,7 @@ autoinstall:
# Installer-stage late commands
late-commands:
# Install deb packages from CIDATA USB, then disable cloud-init
# Step 1: Install deb packages from CIDATA USB
- |
curtin in-target --target=/target -- bash -c '
mkdir -p /mnt/cidata
@@ -61,51 +61,37 @@ autoinstall:
fi
umount /mnt/cidata
fi
# Disable cloud-init AFTER dpkg (dpkg may overwrite earlier disables)
mkdir -p /etc/cloud
touch /etc/cloud/cloud-init.disabled
ln -sf /dev/null /etc/systemd/system/cloud-init.service
ln -sf /dev/null /etc/systemd/system/cloud-init-local.service
ln -sf /dev/null /etc/systemd/system/cloud-config.service
ln -sf /dev/null /etc/systemd/system/cloud-final.service
ln -sf /dev/null /etc/systemd/system/cloud-init.target
# Disable networkd-wait-online (no gateway on air-gapped network, causes 2min hang)
ln -sf /dev/null /etc/systemd/system/systemd-networkd-wait-online.service
'
# Create first-boot.sh + disable cloud-init (in same block we know works)
# Step 2: Disable networkd-wait-online (hangs on air-gapped network)
- ln -sf /dev/null /target/etc/systemd/system/systemd-networkd-wait-online.service
# Step 3: Create first-boot.sh
- |
curtin in-target --target=/target -- bash -c '
mkdir -p /etc/cloud/cloud.cfg.d
echo "datasource_list: [None]" > /etc/cloud/cloud.cfg.d/99-nocloud.cfg
touch /etc/cloud/cloud-init.disabled
ln -sf /dev/null /etc/systemd/system/systemd-networkd-wait-online.service
cat <<"EOF" > /opt/first-boot.sh
#!/bin/bash
CIDATA_DEV=$(blkid -L CIDATA)
if [ -n "$CIDATA_DEV" ]; then
mkdir -p /mnt/usb
mount "$CIDATA_DEV" /mnt/usb
# Install all offline .deb packages (ansible, dnsmasq, apache2, samba, etc.)
if compgen -G "/mnt/usb/packages/*.deb" > /dev/null; then
dpkg -i /mnt/usb/packages/*.deb 2>/dev/null || true
dpkg -i /mnt/usb/packages/*.deb 2>/dev/null || true
fi
# Run the Ansible playbook
if [ -f /mnt/usb/playbook/pxe_server_setup.yml ]; then
cd /mnt/usb/playbook
ansible-playbook -i localhost, -c local pxe_server_setup.yml
fi
umount /mnt/usb
fi
# Disable rc.local to prevent rerunning
sed -i "s|^/opt/first-boot.sh.*|# &|" /etc/rc.local
lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv || true
EOF
chmod +x /opt/first-boot.sh
'
- curtin in-target --target=/target -- chmod +x /opt/first-boot.sh
# Create rc.local without unintended indentation
# Step 4: Create rc.local
- |
curtin in-target --target=/target -- bash -c '
cat <<"EOF" > /etc/rc.local
@@ -113,15 +99,11 @@ autoinstall:
/opt/first-boot.sh > /var/log/first-boot.log 2>&1 &
exit 0
EOF
chmod +x /etc/rc.local
'
- curtin in-target --target=/target -- chmod +x /etc/rc.local
user-data:
disable_root: false
runcmd:
- touch /etc/cloud/cloud-init.disabled
- systemctl disable cloud-init.service cloud-init-local.service cloud-config.service cloud-final.service
- systemctl mask cloud-init.service cloud-init-local.service cloud-config.service cloud-final.service
refresh-installer:
update: no