1392 lines
54 KiB
YAML
1392 lines
54 KiB
YAML
---
|
|
- name: PXE Server Setup (Ubuntu with dnsmasq)
|
|
hosts: localhost
|
|
connection: local
|
|
become: yes
|
|
gather_facts: yes
|
|
|
|
pre_tasks:
|
|
- name: "Verify required packages are installed (pre-installed from offline .debs)"
|
|
command: dpkg -s {{ item }}
|
|
loop:
|
|
- dnsmasq
|
|
- apache2
|
|
- samba
|
|
- unzip
|
|
- ufw
|
|
- cron
|
|
- ansible
|
|
- wimtools
|
|
- conntrack
|
|
- sbsigntool # sbverify: iPXE update signature checks
|
|
- p7zip-full # 7z: Dell driver packs, catalog cabs, Blancco ISO
|
|
- zip # driver zips PESetup unpacks
|
|
- curl # Updates page downloads
|
|
register: pkg_check
|
|
failed_when: false
|
|
changed_when: false
|
|
|
|
- name: "Warn about missing packages"
|
|
debug:
|
|
msg: "WARNING: {{ item.item }} is not installed! Install offline .debs first."
|
|
loop: "{{ pkg_check.results }}"
|
|
when: item.rc != 0
|
|
|
|
vars:
|
|
tftp_dir: "/srv/tftp"
|
|
web_root: "/var/www/html"
|
|
samba_share: "/srv/samba/winpeapps"
|
|
usb_mount: "/mnt/usb/playbook" # playbook location on USB
|
|
usb_root: "/mnt/usb" # CIDATA partition root
|
|
# Secure Boot iPXE chain, fetched into boot-files/ by scripts/fetch-ipxe.sh
|
|
# (keep these pins in step with that script). Every UEFI client gets the
|
|
# dual-signed shim (Microsoft UEFI CA 2011 + 2023), which loads ipxe.efi
|
|
# from the TFTP root: the release's SNPONLY build (firmware network and
|
|
# USB drivers; the full ipxe.efi drives USB itself and kills USB
|
|
# keyboards at the menu). The old Broadcom-signed 1.21.1 build stays on
|
|
# the box as ipxe-bcm.efi, the rollback.
|
|
ipxe_tarball_sha256: "01a526d4cc791fc30362259c609d6c506cc64a7bdff51b9a5eb788354e17eee1" # ipxe v2.0.0 ipxeboot.tar.gz
|
|
ipxe_shim_sha256: "5eecca2780bd49c900565e124516a1bd666ec5e012825f34991b6ba1ef2fa6cf" # ipxe/shim ipxe-16.1 ipxe-shimx64.efi
|
|
ipxe_snponly_sha256: "b1e67c3e4a1e8708ddfd0079ad4505e3a02245acb55ee9a95437ab3c507be82a" # x86_64-sb/snponly.efi
|
|
ipxe_bios_sha256: "0fb21c695c82fd70d4f89732ddcd285063776e2bbd71de9a2c39e9cfe4b180b8" # x86_64/ipxe.pxe
|
|
# Zscaler Root CA: GE's Zscaler re-signs GitHub TLS, so the iPXE update
|
|
# check fails without it. Repo copy first, else the copy on the image share.
|
|
zscaler_ca_src: "{{ playbook_dir }}/certs/zscaler-root-ca.crt"
|
|
# _media/<pctype> links the base image's entries, so also look in the
|
|
# image roots (on a rebuild the _media views may not exist yet).
|
|
zscaler_ca_share_glob: "{{ samba_share }}/_media/*/Deploy/Applications/ZscalerCommercialCertificate-2048-SHA256.crt {{ samba_share }}/gea-*/Deploy/Applications/ZscalerCommercialCertificate-2048-SHA256.crt"
|
|
# NIC guard (pxe-nic-check): dnsmasq must never serve DHCP/PXE on the GE
|
|
# corporate network. Pin the two NICs by MAC (ip -br link); left blank,
|
|
# the imaging NIC is the interface= of /etc/dnsmasq.d/pxe-nic-only.conf
|
|
# or the holder of 172.16.9.1, and the GE NIC is the one with a DHCP
|
|
# lease. A MAC of a bridge port resolves to the bridge (br-pxe).
|
|
pxe_imaging_mac: ""
|
|
pxe_ge_mac: ""
|
|
# A foreign DHCP server handing out one of these domains (whole labels:
|
|
# wjs.geaerospace.net matches, notgeaerospace.net does not) = GE network.
|
|
pxe_corp_domain_suffixes: "geaerospace.net, ge.com"
|
|
# Only if the IMAGING switch is itself managed and sends LLDP/CDP: its
|
|
# LLDP system name / CDP device id / chassis MAC, comma separated, so
|
|
# it does not count as a corporate switch. 802.1X always counts.
|
|
pxe_nic_allowed_switches: ""
|
|
image_types:
|
|
- gea-standard
|
|
- gea-engineer
|
|
- gea-shopfloor
|
|
shopfloor_types:
|
|
- gea-shopfloor
|
|
# Image variants that share the generic Win10/Win11 unattend
|
|
# (gea-standard and gea-engineer both deploy Win11 Pro 24H2 now; the same
|
|
# unattend file drives both because the RunSynchronous entries are
|
|
# OS-version-agnostic).
|
|
standard_types:
|
|
- gea-standard
|
|
- gea-engineer
|
|
deploy_subdirs:
|
|
- Applications
|
|
- Control
|
|
- "Operating Systems"
|
|
- "Out-of-box Drivers"
|
|
- Packages
|
|
- Tools
|
|
|
|
tasks:
|
|
- name: "Gather minimal network facts"
|
|
ansible.builtin.setup:
|
|
filter:
|
|
- ansible_interfaces
|
|
- ansible_default_ipv4
|
|
|
|
- name: "Bring up all ethernet-like interfaces"
|
|
command: ip link set dev {{ item }} up
|
|
loop: "{{ ansible_interfaces | select('match','^e(th|n)') | list }}"
|
|
ignore_errors: yes
|
|
|
|
- name: "Find interface with 172.16.9.1 already configured"
|
|
set_fact:
|
|
preconfigured_iface: >-
|
|
{{ ansible_interfaces
|
|
| select('match','^e(th|n)')
|
|
| map('regex_replace','^(.*)$','ansible_\1')
|
|
| map('extract', hostvars[inventory_hostname])
|
|
| selectattr('ipv4','defined')
|
|
| selectattr('ipv4.address','equalto','172.16.9.1')
|
|
| map(attribute='device')
|
|
| list
|
|
| first
|
|
| default('') }}
|
|
ignore_errors: yes
|
|
|
|
- name: "Determine PXE interface"
|
|
set_fact:
|
|
pxe_iface: >-
|
|
{{ preconfigured_iface | default('',true)
|
|
or (ansible_interfaces
|
|
| select('match','^e(th|n)')
|
|
| reject('equalto','lo')
|
|
| reject('equalto', ansible_default_ipv4.interface | default(''))
|
|
| list
|
|
)
|
|
| first
|
|
| default(ansible_default_ipv4.interface | default(
|
|
ansible_interfaces | select('match','^e(th|n)') | first | default('eth0')
|
|
)) }}
|
|
|
|
- name: "Debug: final pxe_iface choice"
|
|
debug:
|
|
msg: "Using {{ pxe_iface }} for DHCP/TFTP"
|
|
|
|
- name: "Expand root partition and filesystem to use full disk"
|
|
args:
|
|
executable: /bin/bash
|
|
shell: |
|
|
# Find the root LV device
|
|
ROOT_DEV=$(findmnt -n -o SOURCE /)
|
|
ROOT_DISK=$(lsblk -n -o PKNAME $(readlink -f "$ROOT_DEV") | tail -1)
|
|
if [ -z "$ROOT_DISK" ]; then
|
|
echo "Could not determine root disk, skipping"
|
|
exit 0
|
|
fi
|
|
# Find the partition number for the LVM PV
|
|
PV_PART=$(pvs --noheadings -o pv_name | tr -d ' ' | head -1)
|
|
if [ -z "$PV_PART" ]; then
|
|
echo "No LVM PV found, skipping"
|
|
exit 0
|
|
fi
|
|
PART_NUM=$(echo "$PV_PART" | grep -o '[0-9]*$')
|
|
echo "Expanding /dev/${ROOT_DISK} partition ${PART_NUM} (${PV_PART})..."
|
|
growpart "/dev/${ROOT_DISK}" "${PART_NUM}" 2>&1 || true
|
|
pvresize "$PV_PART" 2>&1
|
|
lvextend -l +100%FREE "$ROOT_DEV" 2>&1 || true
|
|
resize2fs "$ROOT_DEV" 2>&1
|
|
echo "Disk: $(df -h / | tail -1)"
|
|
register: disk_expand
|
|
changed_when: "'CHANGED' in disk_expand.stdout or 'resized' in disk_expand.stdout"
|
|
|
|
- name: "Deploy dnsmasq dhcp-script for per-lease state cleanup"
|
|
copy:
|
|
src: "{{ usb_mount }}/pxe-server-helpers/pxe-dhcp-hook.sh"
|
|
dest: /usr/local/sbin/pxe-dhcp-hook.sh
|
|
mode: '0755'
|
|
|
|
- name: "Configure dnsmasq for DHCP and TFTP"
|
|
copy:
|
|
dest: /etc/dnsmasq.conf
|
|
backup: yes
|
|
content: |
|
|
port=0
|
|
listen-address=172.16.9.1
|
|
bind-dynamic
|
|
dhcp-range=172.16.9.10,172.16.9.100,12h
|
|
# No default gateway (option 3) and no DNS (option 6) handed out:
|
|
# the PXE network is isolated and the PXE server does not forward
|
|
# internet traffic. Previously we set both, which made imaged PCs
|
|
# add a default route via 172.16.9.1 and prefer it over WiFi (lower
|
|
# interface metric). PPKG / Intune enrollment then black-holed
|
|
# internet-bound traffic. The fix used to be migrate-to-wifi.ps1
|
|
# disabling the wired NIC during first-logon, which created an
|
|
# eDNC race (10022 socket errors until the SYSTEM task re-enabled
|
|
# the wired NIC much later). Removing these options entirely lets
|
|
# Windows route internet via WiFi and same-subnet PXE/SMB traffic
|
|
# via wired, no migration script needed.
|
|
#
|
|
# Important: dnsmasq DEFAULTS to sending its own listening address as
|
|
# both router and DNS when these options are unset. Commenting them
|
|
# out is NOT the same as disabling - imaged PCs (and Blancco PXE
|
|
# clients) end up with 172.16.9.1 as gateway. The empty-value form
|
|
# below explicitly suppresses both options.
|
|
dhcp-option=3
|
|
dhcp-option=6
|
|
enable-tftp
|
|
tftp-root={{ tftp_dir }}
|
|
# Arch-aware NBP for Blancco/WinPE PXE clients:
|
|
# - legacy BIOS (vendorclass PXEClient:Arch:00000) -> ipxe.pxe, a
|
|
# BIOS full-feature iPXE build with an HTTP/TCP stack.
|
|
# - iPXE-running clients (userclass "iPXE") -> chain to the HTTP menu
|
|
# - every UEFI client -> ipxe-shim.efi, iPXE's Microsoft-signed shim
|
|
# (dual-signed, UEFI CA 2011 + 2023). Over TFTP it always loads
|
|
# ipxe.efi from the TFTP root, which is the iPXE snponly build
|
|
# (see the ipxe_* vars). Rollback: point the last line back at
|
|
# ipxe-bcm.efi (the old Broadcom-signed 1.21.1 build).
|
|
dhcp-vendorclass=set:bios,PXEClient:Arch:00000
|
|
dhcp-userclass=set:ipxe,iPXE
|
|
dhcp-boot=tag:bios,tag:!ipxe,ipxe.pxe
|
|
dhcp-boot=tag:ipxe,http://172.16.9.1:4433/Altiris/iPXE/GetPxeScript.aspx
|
|
dhcp-boot=tag:!bios,tag:!ipxe,ipxe-shim.efi
|
|
log-dhcp
|
|
# Per-lease state cleanup: flush conntrack + port-445 sockets for
|
|
# the client IP on add/del. Prevents "System error 53" when a PXE
|
|
# client re-images the same machine and hits a stale SMB session.
|
|
# Script runs as root by default (dnsmasq --dhcp-scriptuser default).
|
|
dhcp-script=/usr/local/sbin/pxe-dhcp-hook.sh
|
|
# Also call it when a client comes back to its existing lease (a
|
|
# re-image of the same PC), which dnsmasq otherwise reports only if
|
|
# the hostname or MAC changed. The hook acts on those only for PXE
|
|
# firmware / iPXE requests.
|
|
script-on-renewal
|
|
|
|
# --- NIC guard: keep dnsmasq off the GE corporate network ---
|
|
# pxe-nic-check classifies each NIC from what it hears (LLDP/CDP/802.1X
|
|
# from managed switches, foreign DHCP offers and their domain). The
|
|
# dnsmasq drop-in runs it as ExecStartPre (--guard: dnsmasq refuses to
|
|
# start if the imaging NIC is on the GE network or next to another DHCP
|
|
# server); the timer re-checks every 5 min (--watch: stops dnsmasq) and
|
|
# writes /run/pxe-nic-status.json for the webapp. Operator notes and
|
|
# the floor tests: docs/pxe-nic-guard.md.
|
|
- name: "NIC guard: deploy pxe-nic-check"
|
|
copy:
|
|
src: "{{ usb_mount }}/pxe-server-helpers/pxe-nic-check"
|
|
dest: /usr/local/sbin/pxe-nic-check
|
|
mode: '0755'
|
|
|
|
- name: "NIC guard: create /etc/pxe-server"
|
|
file:
|
|
path: /etc/pxe-server
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: "NIC guard: write /etc/pxe-server/nic.conf"
|
|
copy:
|
|
dest: /etc/pxe-server/nic.conf
|
|
mode: '0644'
|
|
content: |
|
|
# Managed by pxe_server_setup.yml (vars pxe_imaging_mac, pxe_ge_mac,
|
|
# pxe_corp_domain_suffixes). Read by /usr/local/sbin/pxe-nic-check.
|
|
[nic]
|
|
{% if pxe_imaging_mac %}
|
|
imaging_mac = {{ pxe_imaging_mac | lower }}
|
|
{% else %}
|
|
# imaging_mac unset: falls back to interface= in
|
|
# /etc/dnsmasq.d/pxe-nic-only.conf, then the holder of own_ip
|
|
{% endif %}
|
|
{% if pxe_ge_mac %}
|
|
ge_mac = {{ pxe_ge_mac | lower }}
|
|
{% else %}
|
|
# ge_mac unset: falls back to the interface holding a DHCP lease
|
|
{% endif %}
|
|
corp_domain_suffixes = {{ pxe_corp_domain_suffixes }}
|
|
own_ip = 172.16.9.1
|
|
allowed_switches = {{ pxe_nic_allowed_switches }}
|
|
|
|
- name: "NIC guard: create dnsmasq drop-in directory"
|
|
file:
|
|
path: /etc/systemd/system/dnsmasq.service.d
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: "NIC guard: install dnsmasq ExecStartPre drop-in"
|
|
copy:
|
|
src: "{{ usb_mount }}/pxe-server-helpers/dnsmasq.service.d/nic-guard.conf"
|
|
dest: /etc/systemd/system/dnsmasq.service.d/nic-guard.conf
|
|
mode: '0644'
|
|
|
|
- name: "NIC guard: install watch service and timer"
|
|
copy:
|
|
src: "{{ usb_mount }}/pxe-server-helpers/{{ item }}"
|
|
dest: "/etc/systemd/system/{{ item }}"
|
|
mode: '0644'
|
|
loop:
|
|
- pxe-nic-check.service
|
|
- pxe-nic-check.timer
|
|
|
|
- name: "NIC guard: enable watch timer"
|
|
systemd:
|
|
name: pxe-nic-check.timer
|
|
state: started
|
|
enabled: yes
|
|
daemon_reload: yes
|
|
|
|
- name: "Create TFTP directory"
|
|
file:
|
|
path: "{{ tftp_dir }}"
|
|
state: directory
|
|
mode: '0755'
|
|
owner: nobody
|
|
group: nogroup
|
|
|
|
- name: "Create Win11 directory structure"
|
|
file:
|
|
path: "{{ web_root }}/win11/{{ item }}"
|
|
state: directory
|
|
mode: '0755'
|
|
loop:
|
|
- "EFI/Boot"
|
|
- "EFI/Microsoft/Boot"
|
|
- "Boot"
|
|
- "sources"
|
|
|
|
- name: "Create Altiris iPXE directory"
|
|
file:
|
|
path: "{{ web_root }}/Altiris/iPXE"
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: "Create boot tool directories"
|
|
file:
|
|
path: "{{ web_root }}/{{ item }}"
|
|
state: directory
|
|
mode: '0755'
|
|
loop:
|
|
- clonezilla
|
|
- blancco
|
|
- memtest
|
|
|
|
- name: "Install GetPxeScript.aspx (iPXE boot menu)"
|
|
# The live menu, tracked as a file (playbook/ipxe/GetPxeScript.aspx).
|
|
# WinPE skips the Secure Boot warning when iPXE reads Secure Boot as on
|
|
# (iPXE 2.0 ${efi/SecureBoot}); Blancco starts through the Ubuntu shim
|
|
# (iPXE shim command) so it runs with Secure Boot on. The Blancco
|
|
# Releases page edits this file (test entry), so keep exactly one
|
|
# "item blancco" line and the :blancco_efi kernel+initrd block.
|
|
copy:
|
|
src: "{{ usb_mount }}/ipxe/GetPxeScript.aspx"
|
|
dest: "{{ web_root }}/Altiris/iPXE/GetPxeScript.aspx"
|
|
mode: '0644'
|
|
backup: yes
|
|
|
|
- name: "Ensure Apache listens on port 4433"
|
|
lineinfile:
|
|
path: /etc/apache2/ports.conf
|
|
line: "Listen 4433"
|
|
backup: yes
|
|
state: present
|
|
|
|
- name: "Create VirtualHost for Altiris iPXE on 4433"
|
|
copy:
|
|
dest: /etc/apache2/sites-available/altiris-ipxe.conf
|
|
backup: yes
|
|
content: |
|
|
<VirtualHost *:4433>
|
|
DocumentRoot {{ web_root }}
|
|
<Directory "{{ web_root }}/Altiris/iPXE">
|
|
Options Indexes FollowSymLinks
|
|
AllowOverride None
|
|
Require all granted
|
|
AddType text/plain .aspx
|
|
</Directory>
|
|
</VirtualHost>
|
|
|
|
- name: "Enable Altiris iPXE site"
|
|
command: a2ensite altiris-ipxe.conf
|
|
args:
|
|
creates: /etc/apache2/sites-enabled/altiris-ipxe.conf
|
|
|
|
- name: "Reload Apache to apply changes"
|
|
systemd:
|
|
name: apache2
|
|
state: reloaded
|
|
|
|
- name: "Create Samba share root"
|
|
file:
|
|
path: "{{ samba_share }}"
|
|
state: directory
|
|
mode: '0777'
|
|
|
|
- name: "Create Clonezilla backup share directory"
|
|
file:
|
|
path: /srv/samba/clonezilla
|
|
state: directory
|
|
mode: '0777'
|
|
|
|
- name: "Create Blancco reports share directory"
|
|
file:
|
|
path: /srv/samba/blancco-reports
|
|
state: directory
|
|
mode: '0777'
|
|
|
|
- name: "Create enrollment share with internal taxonomy"
|
|
file:
|
|
path: "/srv/samba/enrollment/{{ item }}"
|
|
state: directory
|
|
mode: '0777'
|
|
loop:
|
|
- ""
|
|
- ppkgs
|
|
- scripts
|
|
- config
|
|
- shopfloor-setup
|
|
- pre-install
|
|
- pre-install/bios
|
|
- pre-install/installers
|
|
- installers-post
|
|
- installers-post/cmm
|
|
- blancco
|
|
- logs
|
|
|
|
- name: "Deploy enrollment share README"
|
|
copy:
|
|
dest: /srv/samba/enrollment/README.md
|
|
mode: '0644'
|
|
content: |
|
|
# Enrollment Share Layout
|
|
Single SMB share mounted by WinPE as Y: during imaging. Subdir layout:
|
|
- ppkgs/ GCCH bulk-enrollment PPKGs
|
|
- scripts/ run-enrollment.ps1, wait-for-internet.ps1, migrate-to-wifi.ps1
|
|
- config/ site-config.json, FlatUnattendW10*.xml, per-site overrides
|
|
- shopfloor-setup/ Per-PC-type post-imaging scripts
|
|
- pre-install/ WinPE-phase content (bios/, installers/, preinstall.json)
|
|
- installers-post/ Post-OOBE app installers (cmm/PCDMIS, etc.)
|
|
- blancco/ Blancco custom images / configs
|
|
- logs/ Client log uploads
|
|
|
|
- name: "Deploy PPKG enrollment packages to ppkgs/"
|
|
shell: |
|
|
set +e
|
|
# Copy any whole PPKGs (small enough to fit on FAT32)
|
|
cp -f {{ usb_root }}/enrollment/*.ppkg /srv/samba/enrollment/ppkgs/ 2>/dev/null
|
|
# Reassemble any split files (foo.ppkg.part.00, .01, ... -> foo.ppkg)
|
|
for first in {{ usb_root }}/enrollment/*.part.00; do
|
|
[ -e "$first" ] || continue
|
|
base="${first%.part.00}"
|
|
name="$(basename "$base")"
|
|
echo "Reassembling $name from chunks..."
|
|
cat "${base}.part."* > "/srv/samba/enrollment/ppkgs/$name"
|
|
done
|
|
ls -lh /srv/samba/enrollment/ppkgs/*.ppkg 2>/dev/null
|
|
ignore_errors: yes
|
|
|
|
- name: "Deploy enrollment scripts to scripts/"
|
|
copy:
|
|
src: "{{ item.src }}"
|
|
dest: "/srv/samba/enrollment/scripts/{{ item.dest }}"
|
|
mode: '0644'
|
|
loop:
|
|
- { src: "{{ usb_mount }}/shopfloor-setup/run-enrollment.ps1", dest: "run-enrollment.ps1" }
|
|
- { src: "{{ usb_mount }}/wait-for-internet.ps1", dest: "wait-for-internet.ps1" }
|
|
- { src: "{{ usb_mount }}/migrate-to-wifi.ps1", dest: "migrate-to-wifi.ps1" }
|
|
- { src: "{{ usb_mount }}/winpe-status-push.ps1", dest: "winpe-status-push.ps1" }
|
|
ignore_errors: yes
|
|
|
|
- name: "Deploy site-config.json to config/"
|
|
copy:
|
|
src: "{{ usb_mount }}/shopfloor-setup/site-config.json"
|
|
dest: /srv/samba/enrollment/config/site-config.json
|
|
mode: '0644'
|
|
ignore_errors: yes
|
|
|
|
- name: "Deploy Dell driver packs to shared Out-of-box Drivers"
|
|
args:
|
|
executable: /bin/bash
|
|
shell: |
|
|
set +e
|
|
SRC="{{ usb_root }}/drivers"
|
|
DEST="/srv/samba/winpeapps/_shared/Out-of-box Drivers/Dell_11"
|
|
if [ ! -d "$SRC" ]; then
|
|
echo "No drivers/ on USB - skipping"
|
|
exit 0
|
|
fi
|
|
mkdir -p "$DEST"
|
|
# Copy everything except split chunks
|
|
rsync -a --exclude='*.part.*' "$SRC/" "$DEST/"
|
|
# Reassemble any split driver files
|
|
while IFS= read -r first; do
|
|
base="${first%.part.00}"
|
|
rel="${base#$SRC/}"
|
|
out="$DEST/$rel"
|
|
mkdir -p "$(dirname "$out")"
|
|
echo "Reassembling $rel from chunks..."
|
|
cat "${base}.part."* > "$out"
|
|
done < <(find "$SRC" -name '*.part.00')
|
|
echo "Deployed Dell drivers from USB"
|
|
ignore_errors: yes
|
|
|
|
- name: "Deploy shopfloor setup scripts to enrollment share"
|
|
copy:
|
|
src: "{{ usb_mount }}/shopfloor-setup/"
|
|
dest: /srv/samba/enrollment/shopfloor-setup/
|
|
mode: '0755'
|
|
directory_mode: '0755'
|
|
ignore_errors: yes
|
|
|
|
- name: "Deploy preinstall.json to pre-install/"
|
|
copy:
|
|
src: "{{ usb_mount }}/preinstall/preinstall.json"
|
|
dest: /srv/samba/enrollment/pre-install/preinstall.json
|
|
mode: '0644'
|
|
ignore_errors: yes
|
|
|
|
# Oracle Client 11.2 is the first app the preinstall runner executes, so it
|
|
# has to be present on-disk before the first client images. The 686 MB
|
|
# Oracle_OracleDatabase_11r2_V03.zip doesn't belong in git; it rides on the
|
|
# USB under oracle/ alongside the BIOS exes. Install-Oracle11r2.cmd is
|
|
# tracked at playbook/preinstall/oracle/ and arrives via usb_mount.
|
|
- name: "Create pre-install/installers/oracle/ staging dir"
|
|
file:
|
|
path: /srv/samba/enrollment/pre-install/installers/oracle
|
|
state: directory
|
|
mode: '0755'
|
|
ignore_errors: yes
|
|
|
|
- name: "Deploy Install-Oracle11r2.cmd to pre-install/installers/oracle/"
|
|
copy:
|
|
src: "{{ usb_mount }}/preinstall/oracle/Install-Oracle11r2.cmd"
|
|
dest: /srv/samba/enrollment/pre-install/installers/oracle/Install-Oracle11r2.cmd
|
|
mode: '0755'
|
|
ignore_errors: yes
|
|
|
|
# Per-file overrides for the .ora config dropped by the wrapper post-install.
|
|
# The zip's client/ora/ contains dated defaults; shipping an updated
|
|
# tnsnames.ora alongside the wrapper lets us refresh the DB catalog without
|
|
# repackaging the 686 MB zip. sqlnet.ora and ldap.ora can be added here the
|
|
# same way if they ever need to diverge from the zip's bundled copies.
|
|
- name: "Deploy updated tnsnames.ora override to pre-install/installers/oracle/"
|
|
copy:
|
|
src: "{{ usb_mount }}/preinstall/oracle/tnsnames.ora"
|
|
dest: /srv/samba/enrollment/pre-install/installers/oracle/tnsnames.ora
|
|
mode: '0644'
|
|
ignore_errors: yes
|
|
|
|
- name: "Deploy Oracle 11.2 zip (686 MB) from USB to pre-install/installers/oracle/"
|
|
shell: >
|
|
if [ -f "{{ usb_root }}/oracle/Oracle_OracleDatabase_11r2_V03.zip" ]; then
|
|
cp -f "{{ usb_root }}/oracle/Oracle_OracleDatabase_11r2_V03.zip" \
|
|
/srv/samba/enrollment/pre-install/installers/oracle/
|
|
echo "Deployed Oracle 11.2 zip ($(stat -c %s /srv/samba/enrollment/pre-install/installers/oracle/Oracle_OracleDatabase_11r2_V03.zip) bytes)"
|
|
else
|
|
echo "WARNING: {{ usb_root }}/oracle/Oracle_OracleDatabase_11r2_V03.zip not on USB - preinstall runner will fail on Oracle step until this file is staged at /srv/samba/enrollment/pre-install/installers/oracle/"
|
|
fi
|
|
ignore_errors: yes
|
|
|
|
- name: "Ensure winpeapps/_shared/BIOS directory exists"
|
|
file:
|
|
path: /srv/samba/winpeapps/_shared/BIOS
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: "Ensure driver store is owned by pxe (download-drivers.py pushes here over ssh as the pxe user; root/webapp still write it fine)"
|
|
file:
|
|
path: "/srv/samba/winpeapps/_shared/Out-of-box Drivers"
|
|
state: directory
|
|
owner: pxe
|
|
group: pxe
|
|
mode: '0775'
|
|
|
|
- name: "Deploy BIOS check script + manifest to winpeapps/_shared/BIOS/"
|
|
# Path matches what startnet.cmd reads at WinPE boot:
|
|
# net use B: \\172.16.9.1\winpeapps\_shared
|
|
# if exist B:\BIOS\check-bios.cmd ...
|
|
# Earlier deploy targeted enrollment/pre-install/bios/ (different share)
|
|
# which startnet.cmd never read, so BIOS_STATUS perma-stuck on
|
|
# "No BIOS check (share unavailable)". Corrected 2026-04-28.
|
|
copy:
|
|
src: "{{ usb_mount }}/shopfloor-setup/BIOS/{{ item }}"
|
|
dest: "/srv/samba/winpeapps/_shared/BIOS/{{ item }}"
|
|
mode: '0644'
|
|
loop:
|
|
- check-bios.cmd
|
|
- models.txt
|
|
- hardware-report.ps1
|
|
ignore_errors: yes
|
|
|
|
- name: "Deploy Dell Flash64W.exe to winpeapps/_shared/BIOS/"
|
|
copy:
|
|
src: "{{ usb_root }}/bios/Flash64W.exe"
|
|
dest: /srv/samba/winpeapps/_shared/BIOS/Flash64W.exe
|
|
mode: '0644'
|
|
ignore_errors: yes
|
|
|
|
- name: "Deploy BIOS update binaries from USB to winpeapps/_shared/BIOS/"
|
|
shell: >
|
|
if [ -d "{{ usb_root }}/bios" ]; then
|
|
cp -f {{ usb_root }}/bios/*.exe /srv/samba/winpeapps/_shared/BIOS/ 2>/dev/null || true
|
|
count=$(find /srv/samba/winpeapps/_shared/BIOS -name '*.exe' | wc -l)
|
|
echo "Deployed $count BIOS binaries"
|
|
else
|
|
echo "No bios/ on USB - skipping"
|
|
fi
|
|
ignore_errors: yes
|
|
|
|
- name: "Create image upload staging directory"
|
|
file:
|
|
path: /home/pxe/image-upload
|
|
state: directory
|
|
mode: '0777'
|
|
owner: pxe
|
|
group: pxe
|
|
|
|
- name: "Enable Samba symlink following (shared image dirs)"
|
|
blockinfile:
|
|
path: /etc/samba/smb.conf
|
|
backup: yes
|
|
marker: "# {mark} MANAGED - GLOBAL SYMLINKS"
|
|
insertafter: '\[global\]'
|
|
block: |
|
|
follow symlinks = yes
|
|
wide links = yes
|
|
unix extensions = no
|
|
# Modern Samba silently disables wide links WITHOUT this. The shared
|
|
# image dirs are served via symlinks into _shared, so it is required
|
|
# or WinPE clients cannot follow them.
|
|
allow insecure wide links = yes
|
|
|
|
- name: "Samba SMB session handling for WinPE re-image robustness"
|
|
blockinfile:
|
|
path: /etc/samba/smb.conf
|
|
backup: yes
|
|
marker: "# {mark} MANAGED - PXE REIMAGE FIX"
|
|
insertafter: "# END MANAGED - GLOBAL SYMLINKS"
|
|
block: |
|
|
# Reduce the chance a WinPE client rebooting mid-imaging leaves a
|
|
# stale session on the server that blocks its next connection
|
|
# attempt with "System error 53 network path not found". Combined
|
|
# with /etc/sysctl.d/99-pxe-conntrack.conf (shorter nf_conntrack
|
|
# TCP timeouts) this keeps the conntrack + smbd state in sync with
|
|
# the short-lived flows that PXE imaging produces.
|
|
socket options = TCP_NODELAY SO_KEEPALIVE IPTOS_LOWDELAY
|
|
keepalive = 30
|
|
# deadtime=0 (disabled): WinPE maps the enrollment share early then
|
|
# idles for minutes during the WIM apply. A non-zero deadtime drops
|
|
# that idle session, so the post-apply staging copies failed (bay
|
|
# left with only site-config.json). 0 = never auto-disconnect idle.
|
|
deadtime = 0
|
|
|
|
- name: "Configure Samba shares"
|
|
blockinfile:
|
|
path: /etc/samba/smb.conf
|
|
backup: yes
|
|
block: |
|
|
[winpeapps]
|
|
path = {{ samba_share }}
|
|
browseable = yes
|
|
read only = no
|
|
guest ok = no
|
|
valid users = pxe-upload
|
|
force user = root
|
|
|
|
[clonezilla]
|
|
path = /srv/samba/clonezilla
|
|
browseable = yes
|
|
read only = no
|
|
guest ok = no
|
|
valid users = pxe-upload
|
|
force user = root
|
|
comment = Clonezilla backup images
|
|
|
|
[blancco-reports]
|
|
path = /srv/samba/blancco-reports
|
|
browseable = yes
|
|
read only = no
|
|
guest ok = no
|
|
valid users = pxe-upload blancco
|
|
force user = root
|
|
comment = Blancco Drive Eraser reports
|
|
|
|
[enrollment]
|
|
path = /srv/samba/enrollment
|
|
browseable = yes
|
|
read only = no
|
|
guest ok = no
|
|
valid users = pxe-upload
|
|
force user = root
|
|
comment = GCCH bulk enrollment packages
|
|
|
|
[image-upload]
|
|
path = /home/pxe/image-upload
|
|
browseable = yes
|
|
read only = no
|
|
guest ok = no
|
|
valid users = pxe-upload
|
|
force user = pxe
|
|
force group = pxe
|
|
comment = PXE image upload staging area
|
|
oplocks = no
|
|
level2 oplocks = no
|
|
strict sync = yes
|
|
|
|
[winpeapps_bios]
|
|
path = /srv/samba/winpeapps/_shared/BIOS
|
|
browseable = no
|
|
read only = yes
|
|
guest ok = no
|
|
valid users = pxe-upload
|
|
comment = Dell BIOS update bundle (read-only, served to WinPE)
|
|
|
|
- name: "Create Samba users (pxe-upload and blancco)"
|
|
shell: |
|
|
id pxe-upload >/dev/null 2>&1 || useradd -M -s /usr/sbin/nologin pxe-upload
|
|
echo -e 'pxe\npxe' | smbpasswd -a pxe-upload -s
|
|
id blancco >/dev/null 2>&1 || useradd -M -s /usr/sbin/nologin blancco
|
|
echo -e 'blancco\nblancco' | smbpasswd -a blancco -s
|
|
args:
|
|
executable: /bin/bash
|
|
changed_when: false
|
|
|
|
- name: "Deploy nf_conntrack TCP timeout sysctl for PXE workload"
|
|
copy:
|
|
src: "{{ usb_mount }}/pxe-server-helpers/99-pxe-conntrack.conf"
|
|
dest: /etc/sysctl.d/99-pxe-conntrack.conf
|
|
mode: '0644'
|
|
notify: reload sysctl
|
|
|
|
- name: "Load nf_conntrack at boot so the conntrack sysctl applies"
|
|
# systemd-sysctl runs before ufw loads nf_conntrack, so without this the
|
|
# net.netfilter.* keys do not exist yet at boot and the 1 h timeout is
|
|
# silently skipped (the kernel default of 5 days stays in force).
|
|
copy:
|
|
dest: /etc/modules-load.d/pxe-conntrack.conf
|
|
content: "nf_conntrack\n"
|
|
mode: '0644'
|
|
|
|
- name: "Deploy SMB diagnostic + soft-reset helper scripts"
|
|
copy:
|
|
src: "{{ usb_mount }}/pxe-server-helpers/{{ item }}"
|
|
dest: "/usr/local/sbin/{{ item }}"
|
|
mode: '0755'
|
|
loop:
|
|
- smb-diag.sh
|
|
- smb-soft-reset.sh
|
|
|
|
- name: "Create image-type top-level directories"
|
|
file:
|
|
path: "{{ samba_share }}/{{ item }}"
|
|
state: directory
|
|
mode: '0777'
|
|
loop: "{{ image_types }}"
|
|
|
|
- name: "Create Deploy subdirectories for each image type"
|
|
file:
|
|
path: "{{ samba_share }}/{{ item.0 }}/Deploy/{{ item.1 }}"
|
|
state: directory
|
|
mode: '0777'
|
|
with_nested:
|
|
- "{{ image_types }}"
|
|
- "{{ deploy_subdirs }}"
|
|
|
|
- name: "Create Media.tag for FlatSetupLoader.exe drive detection"
|
|
copy:
|
|
content: ""
|
|
dest: "{{ samba_share }}/{{ item }}/Deploy/Control/Media.tag"
|
|
mode: '0644'
|
|
force: no
|
|
loop: "{{ image_types }}"
|
|
|
|
- name: "Deploy shopfloor unattend.xml template"
|
|
copy:
|
|
src: "{{ usb_mount }}/FlatUnattendW10-shopfloor.xml"
|
|
dest: "{{ samba_share }}/{{ item }}/Deploy/FlatUnattendW10.xml"
|
|
mode: '0644'
|
|
# force: yes - repo is source of truth. force: no let the live shopfloor
|
|
# unattend go stale (missing the Fetch + Verify-And-Heal staging steps),
|
|
# and a playbook run never repaired it. Keep it in sync like the standard
|
|
# /engineer unattend below.
|
|
force: yes
|
|
loop: "{{ shopfloor_types }}"
|
|
ignore_errors: yes
|
|
|
|
# gea-standard and gea-engineer each get their OWN unattend. They are not
|
|
# interchangeable: the engineer file carries FirstLogonCommands Order 11,
|
|
# which installs the Engineering Layer, and nothing else differs. Deploying
|
|
# one shared template to both - which this task used to do - silently
|
|
# stripped that entry from gea-engineer on every playbook run.
|
|
#
|
|
# force: yes because drift between these files and the share is what caused
|
|
# the Win10/Win11 search-cleanup regression (d49f516). That only works if
|
|
# the repo copies are genuinely current: on 2026-08-19 this template was
|
|
# found to be missing specialize Orders 39-48 - including Order 39, which
|
|
# registers the bulk-enrollment orchestrator - so a playbook run would have
|
|
# removed enrollment from every standard and engineer bay. Both files are
|
|
# now reconciled against the live share. Re-check before trusting force: yes.
|
|
- name: "Deploy standard/engineer unattend.xml (per-type template)"
|
|
copy:
|
|
src: "{{ usb_mount }}/{{ item.src }}"
|
|
dest: "{{ samba_share }}/{{ item.dest }}/Deploy/FlatUnattendW10.xml"
|
|
mode: '0644'
|
|
force: yes
|
|
loop:
|
|
- { src: 'FlatUnattendW10.xml', dest: 'gea-standard' }
|
|
- { src: 'FlatUnattendW10-engineer.xml', dest: 'gea-engineer' }
|
|
ignore_errors: yes
|
|
|
|
- name: "Daily cron to create/refresh Media.tag for all images"
|
|
copy:
|
|
content: |
|
|
# Create Media.tag in any image with Deploy/Control/ and refresh existing ones
|
|
@reboot root for d in {{ samba_share }}/*/Deploy/Control; do [ -d "$d" ] && touch "$d/Media.tag"; done
|
|
0 0 * * * root for d in {{ samba_share }}/*/Deploy/Control; do [ -d "$d" ] && touch "$d/Media.tag"; done
|
|
dest: /etc/cron.d/media-tag-refresh
|
|
mode: '0644'
|
|
|
|
- name: "Copy WinPE & boot files from USB (skipped if not present)"
|
|
copy:
|
|
src: "{{ usb_root }}/{{ item.src }}"
|
|
dest: "{{ web_root }}/win11/{{ item.dest }}"
|
|
mode: '0644'
|
|
loop:
|
|
- { src: "wimboot", dest: "wimboot" }
|
|
- { src: "boot.stl", dest: "EFI/Microsoft/Boot/boot.stl" }
|
|
- { src: "BCD", dest: "EFI/Microsoft/Boot/BCD" }
|
|
- { src: "bootx64.efi", dest: "EFI/Boot/bootx64.efi" }
|
|
- { src: "boot.sdi", dest: "Boot/boot.sdi" }
|
|
- { src: "boot.wim", dest: "sources/boot.wim" }
|
|
ignore_errors: yes
|
|
|
|
- name: "Inject startnet.cmd into boot.wim (virtual BOOT/MEDIA volumes)"
|
|
shell: |
|
|
WIM="{{ web_root }}/win11/sources/boot.wim"
|
|
STARTNET="{{ usb_mount }}/startnet.cmd"
|
|
if [ -f "$WIM" ] && [ -f "$STARTNET" ]; then
|
|
echo "add $STARTNET /Windows/System32/startnet.cmd" | wimupdate "$WIM" 1
|
|
echo "Updated startnet.cmd in boot.wim"
|
|
else
|
|
echo "Skipped: boot.wim or startnet.cmd not found"
|
|
fi
|
|
args:
|
|
executable: /bin/bash
|
|
ignore_errors: yes
|
|
|
|
- name: "Install the Secure Boot iPXE chain into the TFTP root (pinned, verified)"
|
|
# Not ignore_errors: without these files no client can boot. Files come
|
|
# from boot-files/ via scripts/fetch-ipxe.sh; each is checked against
|
|
# its pin before anything is replaced, and each is put in place by
|
|
# rename so a client that is booting never reads half a file.
|
|
shell: |
|
|
set -euo pipefail
|
|
U="{{ usb_root }}"; T="{{ tftp_dir }}"
|
|
check() { echo "$2 $1" | sha256sum -c --status || { echo "sha256 mismatch or missing: $1" >&2; exit 1; }; }
|
|
check "$U/ipxeboot.tar.gz" "{{ ipxe_tarball_sha256 }}"
|
|
check "$U/ipxe-shimx64.efi" "{{ ipxe_shim_sha256 }}"
|
|
W=$(mktemp -d); trap 'rm -rf "$W"' EXIT
|
|
tar -xzf "$U/ipxeboot.tar.gz" -C "$W" ipxeboot/x86_64-sb/snponly.efi ipxeboot/x86_64/ipxe.pxe
|
|
check "$W/ipxeboot/x86_64-sb/snponly.efi" "{{ ipxe_snponly_sha256 }}"
|
|
check "$W/ipxeboot/x86_64/ipxe.pxe" "{{ ipxe_bios_sha256 }}"
|
|
put() { install -m 0644 -o root -g root "$1" "$T/.$2.new" && mv -f "$T/.$2.new" "$T/$2"; }
|
|
put "$U/ipxe-shimx64.efi" ipxe-shim.efi
|
|
put "$W/ipxeboot/x86_64-sb/snponly.efi" ipxe.efi
|
|
put "$W/ipxeboot/x86_64/ipxe.pxe" ipxe.pxe
|
|
# Rollback boot file: the old Broadcom-signed build (boot-files/ipxe.efi).
|
|
if [ -f "$U/ipxe.efi" ]; then put "$U/ipxe.efi" ipxe-bcm.efi; fi
|
|
echo "installed ipxe-shim.efi, ipxe.efi (snponly), ipxe.pxe$( [ -f "$U/ipxe.efi" ] && echo ', ipxe-bcm.efi')"
|
|
args:
|
|
executable: /bin/bash
|
|
register: ipxe_chain
|
|
changed_when: true
|
|
|
|
- name: "Show the installed iPXE chain"
|
|
debug:
|
|
msg: "{{ ipxe_chain.stdout }}"
|
|
|
|
- name: "Copy boot tool files from USB (Clonezilla, Blancco, Memtest)"
|
|
shell: >
|
|
cp -r "{{ usb_root }}/boot-tools/{{ item }}/"* "{{ web_root }}/{{ item }}/" 2>/dev/null || true
|
|
loop:
|
|
- clonezilla
|
|
- blancco
|
|
- memtest
|
|
|
|
# --- Blancco PXE boot via Ubuntu kernel + switch_root ---
|
|
# Blancco's own kernel freezes on Dell Precision towers. Workaround:
|
|
# Boot Ubuntu kernel, download Blancco rootfs, overlay mount, switch_root.
|
|
|
|
- name: "Build Blancco PXE initramfs"
|
|
# The narrow hand-picked NIC driver list used before 2026-04-22 produced
|
|
# a 2 MB initramfs that hung on "waiting for network interface" for any
|
|
# hardware outside e1000e/igb/tg3/bnx2/bnxt_en/b44. This rewrite sweeps
|
|
# the full drivers/net/ tree (ethernet + phy + mdio + usb + fddi + wan)
|
|
# plus overlay / squashfs / loop / ptp / libphy / mii deps, runs depmod
|
|
# so blancco-init.sh can use modprobe with proper dependency resolution,
|
|
# and produces a ~20 MB initramfs. Size isn't a concern - HTTP loads it
|
|
# in under two seconds at gigabit, versus the many minutes of hangtime
|
|
# the narrow build cost us when a NIC was unsupported.
|
|
args:
|
|
executable: /bin/bash
|
|
creates: "{{ web_root }}/blancco/kexec-initrd.img"
|
|
shell: |
|
|
set -e
|
|
WORK=$(mktemp -d)
|
|
KVER=$(uname -r)
|
|
mkdir -p "$WORK"/{bin,lib/modules/$KVER/kernel,lib64,sbin,usr/share/udhcpc,etc,run,proc,sys,dev}
|
|
|
|
# Busybox (static) - bundled on USB at playbook/busybox-static
|
|
if [ -f /bin/busybox ]; then
|
|
cp /bin/busybox "$WORK/bin/busybox"
|
|
elif [ -f "{{ usb_root }}/playbook/busybox-static" ]; then
|
|
cp "{{ usb_root }}/playbook/busybox-static" "$WORK/bin/busybox"
|
|
else
|
|
echo "ERROR: No busybox available (not at /bin/busybox or on USB)"
|
|
exit 1
|
|
fi
|
|
chmod +x "$WORK/bin/busybox"
|
|
# All applets blancco-init.sh uses: modprobe, insmod, dmesg, find, env
|
|
# and export added vs the old narrow list.
|
|
for cmd in sh ash awk cat chmod cp dd echo grep gunzip ifconfig ip insmod ln losetup ls mkdir mknod modprobe mount mv reboot rm rmdir route sed sleep switch_root tar udhcpc umount wget cpio dmesg env export find; do
|
|
ln -sf busybox "$WORK/bin/$cmd"
|
|
done
|
|
|
|
# Full drivers/net/ tree - ethernet + phy + mdio + usb + fddi + wan.
|
|
# Preserve path under /lib/modules/$KVER so depmod can resolve deps.
|
|
NETDIR=/lib/modules/$KVER/kernel/drivers/net
|
|
for sub in ethernet mdio phy usb fddi wan; do
|
|
if [ -d "$NETDIR/$sub" ]; then
|
|
mkdir -p "$WORK/lib/modules/$KVER/kernel/drivers/net/$sub"
|
|
cp -r "$NETDIR/$sub/"* "$WORK/lib/modules/$KVER/kernel/drivers/net/$sub/" 2>/dev/null || true
|
|
fi
|
|
done
|
|
# Overlay + squashfs + loop + usb + hid + ptp + net/core
|
|
for modpath in fs/overlayfs fs/squashfs drivers/block drivers/usb/core drivers/usb/host drivers/hid drivers/ptp net/core; do
|
|
if [ -e "/lib/modules/$KVER/kernel/$modpath" ]; then
|
|
mkdir -p "$WORK/lib/modules/$KVER/kernel/$(dirname $modpath)"
|
|
cp -r "/lib/modules/$KVER/kernel/$modpath" "$WORK/lib/modules/$KVER/kernel/$modpath" 2>/dev/null || true
|
|
fi
|
|
done
|
|
# Pull in every module the copied ones depend on, from the host's
|
|
# modules.dep. A fixed list misses them: drivers/net/mii.ko was named
|
|
# here but ships as mii.ko.zst, so the test skipped it and usbnet,
|
|
# r8152 (USB-C to RJ45 adapters) and cdc_ether failed with "Unknown
|
|
# symbol mii_*"; igb likewise lacked dca and i2c-algo-bit.
|
|
python3 - "$KVER" "$WORK" <<'PYDEP'
|
|
import os, shutil, sys
|
|
kver, work = sys.argv[1], sys.argv[2]
|
|
src = f"/lib/modules/{kver}"
|
|
dst = f"{work}/lib/modules/{kver}"
|
|
dep = {}
|
|
for line in open(f"{src}/modules.dep"):
|
|
k, v = line.split(":", 1)
|
|
dep[k] = v.split()
|
|
have = {os.path.relpath(os.path.join(r, f), dst)
|
|
for r, _, fs in os.walk(dst) for f in fs if ".ko" in f}
|
|
todo, added = list(have), 0
|
|
while todo:
|
|
for d in dep.get(todo.pop(), []):
|
|
if d not in have:
|
|
have.add(d); todo.append(d); added += 1
|
|
os.makedirs(os.path.dirname(f"{dst}/{d}"), exist_ok=True)
|
|
shutil.copy2(f"{src}/{d}", f"{dst}/{d}")
|
|
print(f"added {added} dependency modules")
|
|
PYDEP
|
|
|
|
# NIC firmware the drivers request at probe (r8152/r8169 rtl_nic
|
|
# patches, tg3, bnx2/bnx2x, e100). The kernel loads .zst firmware.
|
|
for fw in rtl_nic tigon bnx2 bnx2x e100; do
|
|
if [ -d "/lib/firmware/$fw" ]; then
|
|
mkdir -p "$WORK/lib/firmware"
|
|
cp -r "/lib/firmware/$fw" "$WORK/lib/firmware/"
|
|
fi
|
|
done
|
|
|
|
# Decompress zstd modules in-place (busybox insmod can't handle .zst)
|
|
find "$WORK/lib/modules" -name '*.ko.zst' -print0 | \
|
|
xargs -0 -I {} sh -c 'zstd -d --rm -o "${1%.zst}" "$1" 2>/dev/null' _ {} || true
|
|
|
|
# Preserve modules.builtin / modules.order, regenerate modules.dep so
|
|
# modprobe can resolve dependencies inside the initramfs.
|
|
cp /lib/modules/$KVER/modules.builtin "$WORK/lib/modules/$KVER/" 2>/dev/null || true
|
|
cp /lib/modules/$KVER/modules.order "$WORK/lib/modules/$KVER/" 2>/dev/null || true
|
|
(cd "$WORK" && depmod -b . $KVER) 2>/dev/null || echo "depmod warning (non-fatal)"
|
|
|
|
# Init script
|
|
cp "{{ usb_root }}/playbook/blancco-init.sh" "$WORK/init"
|
|
chmod +x "$WORK/init"
|
|
|
|
# Build CPIO
|
|
cd "$WORK"
|
|
find . | cpio -o -H newc --quiet | gzip -1 > "{{ web_root }}/blancco/kexec-initrd.img"
|
|
cd /
|
|
rm -rf "$WORK"
|
|
echo "Built kexec-initrd.img: $(stat -c %s '{{ web_root }}/blancco/kexec-initrd.img') bytes"
|
|
ignore_errors: yes
|
|
|
|
- name: "Copy Ubuntu kernel for Blancco PXE boot"
|
|
copy:
|
|
src: "/boot/vmlinuz-{{ ansible_kernel }}"
|
|
dest: "{{ web_root }}/blancco/vmlinuz-ubuntu"
|
|
remote_src: yes
|
|
mode: '0644'
|
|
|
|
- name: "Create TFTP blancco directory"
|
|
file:
|
|
path: "{{ tftp_dir }}/blancco"
|
|
state: directory
|
|
owner: nobody
|
|
group: nogroup
|
|
mode: '0755'
|
|
|
|
- name: "Create TFTP symlinks for Blancco kernel/initrd (GRUB HTTP times out on large files; TFTP is reliable)"
|
|
file:
|
|
src: "{{ web_root }}/blancco/{{ item }}"
|
|
dest: "{{ tftp_dir }}/blancco/{{ item }}"
|
|
state: link
|
|
force: yes
|
|
owner: nobody
|
|
group: nogroup
|
|
loop:
|
|
- vmlinuz-bde-linux
|
|
- initramfs-bde-linux.img
|
|
- intel-ucode.img
|
|
- amd-ucode.img
|
|
- config.img
|
|
|
|
- name: "Build Ubuntu kernel modules tarball for Blancco"
|
|
shell: |
|
|
set -e
|
|
KVER=$(uname -r)
|
|
# Ship the host's iwlwifi firmware with its modules. The UEFI path
|
|
# runs this Ubuntu kernel on Blancco's rootfs, and Blancco 7.20 only
|
|
# carries API 89 ucode for AX201/AX210/AX211, which the 6.8 iwlwifi
|
|
# (max API 86) cannot load, so WiFi licensing never came up. Files
|
|
# only, no lib/ entry: on the Blancco rootfs lib is a symlink to
|
|
# usr/lib and a directory entry would replace it.
|
|
cd /
|
|
tar czf "{{ web_root }}/blancco/kmod.tar.gz" -C / "lib/modules/$KVER" $(ls -d lib/firmware/iwlwifi-*)
|
|
echo "Built kmod.tar.gz: $(du -h '{{ web_root }}/blancco/kmod.tar.gz' | cut -f1)"
|
|
args:
|
|
creates: "{{ web_root }}/blancco/kmod.tar.gz"
|
|
|
|
- name: "Extract config-clean.xml from config.img (strip null bytes)"
|
|
shell: |
|
|
if [ -f "{{ web_root }}/blancco/config.img" ]; then
|
|
WORK=$(mktemp -d)
|
|
cd "$WORK"
|
|
cpio -id < "{{ web_root }}/blancco/config.img" 2>/dev/null
|
|
tr -d '\000' < config.xml > "{{ web_root }}/blancco/config-clean.xml"
|
|
rm -rf "$WORK"
|
|
fi
|
|
args:
|
|
creates: "{{ web_root }}/blancco/config-clean.xml"
|
|
|
|
# Idempotent file copy (was bundled into the previous shell task with a
|
|
# 'creates:' gate, so playbook re-runs never picked up edits to the
|
|
# source XML - stale prefs survived deploys).
|
|
- name: "Deploy Blancco preferences.xml from playbook source"
|
|
copy:
|
|
src: "{{ usb_root }}/playbook/blancco-preferences.xml"
|
|
dest: "{{ web_root }}/blancco/preferences.xml"
|
|
mode: '0644'
|
|
|
|
# blancco-init.sh fetches this at boot and runs it as a service in the
|
|
# Blancco rootfs: erase progress for the webapp's /imaging dashboard.
|
|
- name: "Deploy Blancco progress reporter"
|
|
copy:
|
|
src: "{{ usb_root }}/playbook/blancco-progress.py"
|
|
dest: "{{ web_root }}/blancco/blancco-progress.py"
|
|
mode: '0644'
|
|
|
|
# Hard gate: blancco-init.sh in initramfs drops to shell if the served
|
|
# preferences.xml is malformed or missing the SMB target. Fail the
|
|
# playbook here too so the problem surfaces at deploy time, not at the
|
|
# next erasure attempt.
|
|
- name: "Validate deployed preferences.xml is well-formed + targets the right SMB share"
|
|
shell: |
|
|
set -e
|
|
python3 -c 'import xml.etree.ElementTree as ET; ET.parse("{{ web_root }}/blancco/preferences.xml")'
|
|
grep -q '<hostname>172.16.9.1</hostname>' "{{ web_root }}/blancco/preferences.xml"
|
|
grep -q '<path>blancco-reports</path>' "{{ web_root }}/blancco/preferences.xml"
|
|
changed_when: false
|
|
|
|
- name: "Ensure Samba user for Blancco reports exists (idempotent)"
|
|
shell: |
|
|
id blancco >/dev/null 2>&1 || useradd -r -s /usr/sbin/nologin blancco
|
|
pdbedit -L 2>/dev/null | grep -q '^blancco:' || (echo -e "blancco\nblancco" | smbpasswd -a -s blancco)
|
|
changed_when: false
|
|
|
|
- name: "Check for WinPE deployment content on USB"
|
|
stat:
|
|
path: "{{ usb_root }}/images"
|
|
register: usb_images_dir
|
|
|
|
- name: "Import WinPE deployment content from USB (if present)"
|
|
shell: >
|
|
cp -rn "{{ usb_root }}/images/{{ item }}/"* "{{ samba_share }}/{{ item }}/" 2>/dev/null || true
|
|
loop: "{{ image_types }}"
|
|
when: usb_images_dir.stat.exists
|
|
|
|
- name: "Restart and enable services"
|
|
systemd:
|
|
name: "{{ item }}"
|
|
state: restarted
|
|
enabled: yes
|
|
loop:
|
|
- dnsmasq
|
|
- apache2
|
|
- smbd
|
|
|
|
- name: "Allow necessary firewall ports (UFW)"
|
|
ufw:
|
|
rule: allow
|
|
port: "{{ item }}"
|
|
proto: "{{ 'udp' if item in ['67','69'] else 'tcp' }}"
|
|
loop:
|
|
- "22"
|
|
- "67"
|
|
- "69"
|
|
- "80"
|
|
- "4433"
|
|
- "445"
|
|
- "9009"
|
|
|
|
- name: "Enable UFW firewall"
|
|
ufw:
|
|
state: enabled
|
|
policy: deny
|
|
|
|
- name: "Schedule dnsmasq restart 15s after reboot"
|
|
copy:
|
|
dest: /etc/cron.d/dnsmasq-restart
|
|
mode: '0644'
|
|
content: |
|
|
@reboot root /bin/sleep 15 && /usr/bin/systemctl restart dnsmasq.service
|
|
|
|
# --- Updates pages (Dell drivers/BIOS, iPXE, Blancco) ---
|
|
# The webapp downloads from downloads.dell.com and GitHub through the
|
|
# corporate NIC and unpacks with 7z/zip; sbverify checks iPXE signatures.
|
|
- name: "Install tools the webapp Updates pages need (if missing)"
|
|
apt:
|
|
name:
|
|
- sbsigntool
|
|
- p7zip-full
|
|
- zip
|
|
- unzip
|
|
- curl
|
|
state: present
|
|
ignore_errors: yes
|
|
|
|
- name: "Find the Zscaler Root CA (playbook copy, else the image share)"
|
|
shell: |
|
|
for f in "{{ zscaler_ca_src }}" {{ zscaler_ca_share_glob }}; do
|
|
if [ -f "$f" ] && grep -q "BEGIN CERTIFICATE" "$f"; then
|
|
echo "$f"
|
|
exit 0
|
|
fi
|
|
done
|
|
register: zscaler_ca
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: "Install the Zscaler Root CA into the system trust store"
|
|
copy:
|
|
src: "{{ zscaler_ca.stdout_lines[0] }}"
|
|
dest: /usr/local/share/ca-certificates/zscaler-root-ca.crt
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
when: zscaler_ca.stdout_lines | length > 0
|
|
register: zscaler_ca_copy
|
|
|
|
- name: "Rebuild the system CA bundle"
|
|
command: update-ca-certificates
|
|
when: zscaler_ca_copy is changed
|
|
|
|
- name: "Warn when no Zscaler Root CA was found"
|
|
debug:
|
|
msg: "WARNING: no Zscaler Root CA at {{ zscaler_ca_src }} or {{ zscaler_ca_share_glob }}; GitHub (iPXE update check) will fail TLS until it is installed."
|
|
when: zscaler_ca.stdout_lines | length == 0
|
|
|
|
- name: "Create webapp Updates state directory"
|
|
file:
|
|
path: /var/lib/pxe-webapp/updates
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: '0755'
|
|
|
|
# --- Web Management App (Flask) ---
|
|
- name: "Create webapp directory"
|
|
file:
|
|
path: /opt/pxe-webapp
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: "Copy webapp from USB"
|
|
shell: >
|
|
cp -r "{{ usb_root }}/webapp/"* /opt/pxe-webapp/ 2>/dev/null || true
|
|
args:
|
|
creates: /opt/pxe-webapp/app.py
|
|
|
|
- name: "Install webapp Python dependencies (offline wheels)"
|
|
args:
|
|
executable: /bin/bash
|
|
shell: |
|
|
# Find the pip-wheels directory on the CIDATA mount
|
|
export WHEEL_DIR=""
|
|
for d in "{{ usb_root }}/pip-wheels" "{{ usb_mount }}/pip-wheels"; do
|
|
if [ -d "$d" ] && compgen -G "$d/*.whl" > /dev/null; then
|
|
export WHEEL_DIR="$(cd "$d" && pwd)"
|
|
break
|
|
fi
|
|
done
|
|
if [ -n "$WHEEL_DIR" ]; then
|
|
# Install wheels directly using Python zipfile (bypasses pip entirely)
|
|
# This avoids the pip3/distutils incompatibility between Ubuntu 22.04 debs and Python 3.12
|
|
python3 << 'PYEOF'
|
|
import zipfile, sysconfig, glob, os
|
|
site = sysconfig.get_path('platlib')
|
|
wheel_dir = os.environ['WHEEL_DIR']
|
|
for whl in sorted(glob.glob(os.path.join(wheel_dir, '*.whl'))):
|
|
name = os.path.basename(whl)
|
|
print(f' Installing {name}')
|
|
with zipfile.ZipFile(whl) as z:
|
|
z.extractall(site)
|
|
print('All wheels installed to ' + site)
|
|
PYEOF
|
|
else
|
|
# Fallback: try system pip (works if system has internet and compatible pip)
|
|
python3 -m pip install --break-system-packages flask lxml 2>/dev/null ||
|
|
pip3 install --break-system-packages flask lxml
|
|
fi
|
|
|
|
- name: "Create systemd service for PXE webapp"
|
|
copy:
|
|
dest: /etc/systemd/system/pxe-webapp.service
|
|
content: |
|
|
[Unit]
|
|
Description=PXE Server Web Management
|
|
After=network.target apache2.service
|
|
|
|
[Service]
|
|
Type=simple
|
|
User=root
|
|
WorkingDirectory=/opt/pxe-webapp
|
|
Environment=SAMBA_SHARE={{ samba_share }}
|
|
Environment=CLONEZILLA_SHARE=/srv/samba/clonezilla
|
|
Environment=WEB_ROOT={{ web_root }}
|
|
Environment=BLANCCO_REPORTS=/srv/samba/blancco-reports
|
|
Environment=ENROLLMENT_SHARE=/srv/samba/enrollment
|
|
Environment=AUDIT_LOG=/var/log/pxe-webapp-audit.log
|
|
# Lock TZ so report/backup mtimes and audit-log timestamps render
|
|
# in Eastern time regardless of how the host's /etc/localtime ends
|
|
# up. Without this, a Python process started before timedatectl
|
|
# finishes can cache UTC for its lifetime.
|
|
Environment=TZ=America/New_York
|
|
ExecStart=/usr/bin/python3 app.py
|
|
Restart=always
|
|
RestartSec=5
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
|
|
- name: "Enable and start PXE webapp service"
|
|
systemd:
|
|
name: pxe-webapp
|
|
state: started
|
|
enabled: yes
|
|
daemon_reload: yes
|
|
|
|
# Monthly Blancco CMMC evidence pack (ENT-056/158): on the 1st, save last
|
|
# month's ZIP to the reports share's evidence/ folder for the tech to copy
|
|
# into Box. Persistent catches a run missed while the server was off.
|
|
- name: "Create Blancco evidence pack service and timer"
|
|
copy:
|
|
dest: "/etc/systemd/system/{{ item.name }}"
|
|
content: "{{ item.content }}"
|
|
loop:
|
|
- name: pxe-blancco-evidence.service
|
|
content: |
|
|
[Unit]
|
|
Description=Save last month's Blancco CMMC evidence pack to the reports share
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
WorkingDirectory=/opt/pxe-webapp
|
|
Environment=BLANCCO_REPORTS=/srv/samba/blancco-reports
|
|
Environment=TZ=America/New_York
|
|
ExecStart=/usr/bin/python3 /opt/pxe-webapp/blancco_evidence_monthly.py
|
|
- name: pxe-blancco-evidence.timer
|
|
content: |
|
|
[Unit]
|
|
Description=Monthly Blancco CMMC evidence pack
|
|
|
|
[Timer]
|
|
OnCalendar=*-*-01 06:00:00
|
|
Persistent=true
|
|
|
|
[Install]
|
|
WantedBy=timers.target
|
|
|
|
- name: "Enable Blancco evidence pack timer"
|
|
systemd:
|
|
name: pxe-blancco-evidence.timer
|
|
state: started
|
|
enabled: yes
|
|
daemon_reload: yes
|
|
|
|
- name: "Configure unified Apache site (static files + webapp proxy)"
|
|
copy:
|
|
dest: /etc/apache2/sites-available/pxe-server.conf
|
|
content: |
|
|
Listen 9009
|
|
<VirtualHost *:80>
|
|
DocumentRoot {{ web_root }}
|
|
<Directory "{{ web_root }}">
|
|
Options Indexes FollowSymLinks
|
|
AllowOverride None
|
|
Require all granted
|
|
</Directory>
|
|
ProxyPreserveHost On
|
|
ProxyPass /manage http://127.0.0.1:9010/
|
|
ProxyPassReverse /manage http://127.0.0.1:9010/
|
|
</VirtualHost>
|
|
<VirtualHost *:9009>
|
|
Alias /static /opt/pxe-webapp/static
|
|
<Directory "/opt/pxe-webapp/static">
|
|
Require all granted
|
|
Options -Indexes
|
|
</Directory>
|
|
ProxyPreserveHost On
|
|
ProxyPass /static !
|
|
ProxyPass / http://127.0.0.1:9010/
|
|
ProxyPassReverse / http://127.0.0.1:9010/
|
|
</VirtualHost>
|
|
|
|
- name: "Enable Apache proxy modules"
|
|
command: a2enmod proxy proxy_http
|
|
args:
|
|
creates: /etc/apache2/mods-enabled/proxy.load
|
|
|
|
- name: "Disable default Apache site"
|
|
command: a2dissite 000-default.conf
|
|
args:
|
|
removes: /etc/apache2/sites-enabled/000-default.conf
|
|
|
|
- name: "Enable unified PXE server site"
|
|
command: a2ensite pxe-server.conf
|
|
args:
|
|
creates: /etc/apache2/sites-enabled/pxe-server.conf
|
|
|
|
- name: "Reload Apache after site changes"
|
|
systemd:
|
|
name: apache2
|
|
state: reloaded
|
|
|
|
# Single-NIC fresh-deploy default. Boxes that need higher throughput
|
|
# (e.g. WJF prod uses a USB-C 5 Gbps NIC) override this with a bridge
|
|
# config bonding the USB NIC + onboard NIC into br-pxe. Live override
|
|
# currently deployed on 172.16.9.1 (do NOT re-run this task there
|
|
# without first reviewing /etc/netplan/50-cloud-init.yaml.pre-gold-swap):
|
|
#
|
|
# network:
|
|
# version: 2
|
|
# renderer: networkd
|
|
# ethernets:
|
|
# enp128s31f6: { dhcp4: no }
|
|
# enx34c8d6b11010: { dhcp4: no }
|
|
# bridges:
|
|
# br-pxe:
|
|
# interfaces: [enp128s31f6, enx34c8d6b11010]
|
|
# addresses: [172.16.9.1/24]
|
|
# parameters:
|
|
# stp: false
|
|
#
|
|
# Re-running THIS task on a box already using the bridge config will
|
|
# replace the bridge with a single-iface flat config and likely break
|
|
# the PXE LAN. Skip this task or restore the .pre-gold-swap backup
|
|
# before applying.
|
|
- name: "Configure static IP for PXE interface"
|
|
copy:
|
|
dest: /etc/netplan/50-cloud-init.yaml
|
|
backup: yes
|
|
content: |
|
|
network:
|
|
version: 2
|
|
renderer: networkd
|
|
ethernets:
|
|
{{ pxe_iface }}:
|
|
dhcp4: no
|
|
addresses: [172.16.9.1/24]
|
|
notify: "Apply netplan"
|
|
|
|
handlers:
|
|
- name: "Apply netplan"
|
|
command: netplan apply
|
|
|
|
- name: "reload sysctl"
|
|
command: sysctl --system
|