--- # The AUTHORITATIVE record. Every boot the persistent journal still holds, re-derived from # scratch in one pass by the same code that produced the per-round ledger. # # WHY BOTH. The ledger is written by the driver; if the driver dies between the reboot and # the append, that round exists on the machine but not in the ledger. The journal does not # care whether the driver was alive — the boot happened, the kernel logged it, journald # persisted it. So the harvest can only ever be a superset of the ledger, and the analysis # joins the two on boot_id: rounds come from the ledger, outcomes from the harvest, and # any boot the ledger missed still shows up. # # This runs even for a node that aborted mid-survey, which is exactly when it matters most. - name: Harvest every retained boot from the persistent journal ansible.builtin.script: cmd: memattr_probe.py --all-boots executable: /usr/bin/python3 register: memattr_survey_harvest_raw changed_when: false # strictly a read of the journal - name: Parse the harvest ansible.builtin.set_fact: memattr_survey_harvest: "{{ memattr_survey_harvest_raw.stdout | from_json }}" - name: Ensure the artifact directory exists (on the controller) ansible.builtin.file: path: "{{ memattr_survey_artifact_dir }}" state: directory mode: "0755" delegate_to: localhost become: false # NOT run_once: the survey play uses `strategy: free` (see the playbook for why) and # run_once is unreliable there. `state: directory` is idempotent, so three hosts each # asserting the directory exists is cheaper than a conditional that might not fire. changed_when: false when: memattr_survey_write_artifacts | bool - name: Write the harvested boot record ansible.builtin.copy: dest: "{{ memattr_survey_artifact_dir }}/{{ inventory_hostname }}.boots.json" mode: "0644" content: "{{ memattr_survey_harvest | to_nice_json }}" delegate_to: localhost become: false changed_when: false when: memattr_survey_write_artifacts | bool - name: Mirror the final ledger to the controller ansible.builtin.fetch: src: "{{ memattr_survey_state_file }}" dest: "{{ memattr_survey_artifact_dir }}/{{ inventory_hostname }}.rounds.jsonl" flat: true changed_when: false when: memattr_survey_write_artifacts | bool - name: Harvest summary ansible.builtin.debug: msg: >- {{ inventory_hostname }}: harvested {{ memattr_survey_harvest.boots | length }} boots from the journal ({{ memattr_survey_harvest.boots | selectattr('verdict', 'equalto', 'bad') | list | length }} bad, {{ memattr_survey_harvest.boots | selectattr('verdict', 'equalto', 'good') | list | length }} good, {{ memattr_survey_harvest.boots | rejectattr('verdict', 'in', ['bad', 'good']) | list | length }} other) {%- if memattr_survey_aborted | default(false) | bool %} — NOTE: this node ABORTED ({{ memattr_survey_abort_reason }}) {%- endif %}