Blueforce-Linux/ansible/playbooks/bf-deploy-update.yml
emirhanmamak-blueforce ef102b9657 feat(field-os): provisioning layer, real ISO build, offline contracts
Adds the Blueforce Field OS provisioning stack on top of the existing fleet
architecture, without rewriting the working systems (installer, diagnostics,
Ansible, WireGuard/SSH/xRDP/RustDesk, Docker policies, monitoring, Docusaurus).

ISO build (the previous builder was a skeleton that produced no medium):
- boot layout is read from the base ISO at build time via
  `xorriso -report_el_torito as_mkisofs` and rebuilt with `-as mkisofs`;
  `-boot_image any replay` cannot work on Ubuntu live ISOs because the GRUB2
  MBR lives in the source image's first 16 sectors and the EFI system partition
  is an appended partition, neither of which is a file in the ISO9660 tree
- preflight now asserts El Torito boot metadata positively: xorriso exits 0 on
  a non-ISO input, which previously let an arbitrary file pass --check
- artifact produced and verified: dist/Blueforce-Field-OS-1.0.0-amd64.iso,
  6 481 917 952 bytes, SHA256 cb0cc56f...d431296, BIOS+UEFI entries preserved,
  /autoinstall.yaml at the media root, casper/minimal.squashfs byte-identical
  to the base
- recorded baseline deviation: the verified medium on the build host is the
  Desktop flavour, so the manifest carries a baseline_deviation block instead
  of hiding it; Server remains one flag away

Offline and identity:
- offline APT contract with concrete package requirements, pin format and an
  audit table; builds fail closed while pins are UNPINNED
- autoinstall keeps interactive-sections: [storage]: the operator confirms the
  target disk, and no automatic wipe is ever performed
- firstboot terminal wizard for the 8-digit dealer id, three-state lifecycle
  (PROVISIONED_OFFLINE -> ENROLLED -> READY) with fail-closed gates, so a
  missing internet link or WireGuard handshake cannot fail provisioning but can
  never produce a false READY

Fleet and migration:
- five read-only Ansible playbooks for Field OS version, provisioning,
  enrollment, remote channels and offline readiness, all wave-scoped with a
  separate production override
- Windows pre-migration inventory and data export extended to the full brief
  scope, read-only, never collecting credentials

Tests: tests/run-all.sh -> 8/8 pass, exit 0. Boot acceptance (UEFI, Legacy
BIOS, Secure Boot), air-gapped install, real enrollment endpoint and Windows
rollback remain LAB work and are listed in IMPLEMENTATION-REPORT.md.
2026-09-16 11:14:42 +03:00

86 lines
No EOL
3.2 KiB
YAML

---
# Approved package update with mandatory wave scope and per-batch health gates.
# Example: ansible-playbook -i inventory/hosts.yml playbooks/bf-deploy-update.yml -e release_wave=lab -e wave_gate_confirmed=true -e update_packages='["package=version"]'
- name: Deploy approved package update
hosts: "{{ release_wave | default('invalid-wave', true) }}"
gather_facts: false
become: true
serial: 5
max_fail_percentage: 0
any_errors_fatal: true
vars:
release_wave: ""
wave_gate_confirmed: false
production_override: false
halt_on_fail: true
update_packages: []
update_cache_time: 3600
approved_waves: [lab, pilot_1, pilot_2, wave_1, wave_2, production]
pre_tasks:
- name: Require a valid rollout wave
ansible.builtin.assert:
that:
- release_wave in approved_waves
- release_wave in groups
- groups[release_wave] | length > 0
fail_msg: "release_wave must name a non-empty approved inventory group; refusing an ungated rollout."
run_once: true
- name: Require exact or subset host selection for release wave
ansible.builtin.assert:
that:
- ansible_play_hosts_all | length > 0
- ansible_play_hosts_all | difference(groups[release_wave]) | length == 0
fail_msg: "Selected hosts must equal or be a subset of groups[release_wave]; broader fleet scope is refused."
run_once: true
- name: Require central wave-gate confirmation
ansible.builtin.assert:
that:
- wave_gate_confirmed | bool
fail_msg: "Set wave_gate_confirmed=true only after the prior wave health gate and central approval pass."
run_once: true
- name: Require separate production override
ansible.builtin.assert:
that:
- release_wave != 'production' or production_override | bool
fail_msg: "Production rollout requires production_override=true in addition to wave_gate_confirmed=true."
run_once: true
- name: Require halt-on-failure protection
ansible.builtin.assert:
that:
- halt_on_fail | bool
fail_msg: "halt_on_fail must remain true for every rollout."
run_once: true
- name: Require pinned package versions
ansible.builtin.assert:
that:
- update_packages | length > 0
- update_packages | select('match', '^[A-Za-z0-9][A-Za-z0-9+_.:-]*=.+$') | list | length == update_packages | length
fail_msg: "update_packages must be a non-empty list of exact package=version pins."
run_once: true
tasks:
- name: Update apt cache
ansible.builtin.apt:
update_cache: true
cache_valid_time: "{{ update_cache_time }}"
- name: Install approved pinned package versions
ansible.builtin.apt:
name: "{{ update_packages }}"
state: present
allow_downgrade: true
post_tasks:
- name: Run mandatory post-batch health gate
ansible.builtin.command: /usr/local/bin/bf-status
register: update_health
changed_when: false
failed_when: update_health.rc != 0
- name: Report passed post-batch health gate
ansible.builtin.debug:
msg: "Update batch health gate passed for {{ ansible_play_batch }}"
run_once: true