--- # A user-supplied override profile skips detection (golden-image flow: bake an # image with a fixed profile). - name: Resolve hardware detection requirement ansible.builtin.set_fact: _hardware_detection_needed: >- {{ (system_cfg.features.firmware.enabled | bool) or (system_cfg.features.gpu.enabled | bool) or (system_cfg.features.peripherals.enabled | bool) }} _hardware_profile_override: "{{ system_cfg.features.hardware.profile | default({}) }}" - name: Use supplied hardware profile (override) when: - _hardware_detection_needed | bool - _hardware_profile_override | length > 0 ansible.builtin.set_fact: hardware_profile_active: cpu: "{{ _hardware_profile_override.cpu | default('') | string | lower }}" gpus: "{{ _hardware_profile_override.gpus | default([]) | map('lower') | list }}" nvidia_supports_open: "{{ _hardware_profile_override.nvidia_supports_open | default(true) | bool }}" wireless: "{{ _hardware_profile_override.wireless | default([]) | map('lower') | list }}" audio: "{{ _hardware_profile_override.audio | default([]) | map('lower') | list }}" fingerprint: "{{ _hardware_profile_override.fingerprint | default(false) | bool }}" bluetooth: "{{ _hardware_profile_override.bluetooth | default(false) | bool }}" camera: uvc: "{{ _hardware_profile_override.camera.uvc | default(false) | bool }}" ipu6: "{{ _hardware_profile_override.camera.ipu6 | default(false) | bool }}" - name: Detect hardware from live host when: - _hardware_detection_needed | bool - _hardware_profile_override | length == 0 block: - name: Read CPU vendor ansible.builtin.command: lscpu register: _hardware_lscpu changed_when: false - name: Read PCI device list ansible.builtin.command: lspci -nn register: _hardware_lspci changed_when: false - name: Read USB device list ansible.builtin.command: lsusb register: _hardware_lsusb changed_when: false failed_when: false - name: Resolve detected hardware profile ansible.builtin.include_tasks: _resolve_hardware_profile.yml - name: Initialize empty hardware profile when detection skipped when: not (_hardware_detection_needed | bool) ansible.builtin.set_fact: hardware_profile_active: cpu: "" gpus: [] nvidia_supports_open: true wireless: [] audio: [] fingerprint: false bluetooth: false camera: { uvc: false, ipu6: false } - name: Merge declarative hardware group over detection when: _hardware_detection_needed | bool ansible.builtin.include_tasks: _merge_hardware_profile.yml - name: Report active hardware profile when: _hardware_detection_needed | bool ansible.builtin.debug: msg: >- Hardware profile {{ 'override' if _hardware_profile_override | length > 0 else 'detected' }}: cpu={{ hardware_profile_active.cpu | default('-') }}, gpus={{ hardware_profile_active.gpus | default([]) | join(',') | default('-', true) }} {{ '(open-supported)' if hardware_profile_active.nvidia_supports_open | bool else '(legacy)' }}, wireless={{ hardware_profile_active.wireless | default([]) | join(',') | default('-', true) }}, audio={{ hardware_profile_active.audio | default([]) | join(',') | default('-', true) }}, fingerprint={{ hardware_profile_active.fingerprint | default(false) }}, bluetooth={{ hardware_profile_active.bluetooth | default(false) }}, camera={{ 'uvc' if hardware_profile_active.camera.uvc | default(false) else '' }}{{ '+ipu6' if hardware_profile_active.camera.ipu6 | default(false) else '' }}