From f2b4122a822059db4f81ee623a2479f641e6265f Mon Sep 17 00:00:00 2001 From: "@ClimateAmante" Date: Sun, 2 Aug 2026 00:01:17 -0500 Subject: [PATCH] feat(ipmctl): add pinned Debian 13 source installer --- .github/workflows/www.pages.yml | 70 +- .../ipmctl/app-direct/memory-resources.txt | 5 - .../fixtures/ipmctl/app-direct/regions.txt | 4 - actions/fixtures/ipmctl/malformed/dimms.txt | 1 - .../ipmctl/memory-mode/capabilities.rc | 1 - .../ipmctl/memory-mode/capabilities.txt | 5 - actions/fixtures/ipmctl/memory-mode/dimms.rc | 1 - actions/fixtures/ipmctl/memory-mode/dimms.txt | 8 - actions/fixtures/ipmctl/memory-mode/goal.rc | 1 - actions/fixtures/ipmctl/memory-mode/goal.txt | 1 - .../ipmctl/memory-mode/memory-resources.rc | 1 - .../ipmctl/memory-mode/memory-resources.txt | 5 - .../ipmctl/memory-mode/ndctl-dimms.rc | 1 - .../ipmctl/memory-mode/ndctl-dimms.txt | 1 - .../ipmctl/memory-mode/ndctl-namespaces.rc | 1 - .../ipmctl/memory-mode/ndctl-namespaces.txt | 1 - .../ipmctl/memory-mode/ndctl-regions.rc | 1 - .../ipmctl/memory-mode/ndctl-regions.txt | 1 - .../fixtures/ipmctl/memory-mode/regions.rc | 1 - .../fixtures/ipmctl/memory-mode/regions.txt | 1 - .../fixtures/ipmctl/memory-mode/sensors.rc | 1 - .../fixtures/ipmctl/memory-mode/sensors.txt | 2 - .../fixtures/ipmctl/memory-mode/topology.rc | 1 - .../fixtures/ipmctl/memory-mode/topology.txt | 6 - .../fixtures/ipmctl/memory-mode/version.rc | 1 - .../fixtures/ipmctl/memory-mode/version.txt | 1 - .../ipmctl/namespaces/ndctl-namespaces.txt | 1 - .../ipmctl/partial-failure/topology.rc | 1 - actions/fixtures/ipmctl/pending-goal/goal.txt | 3 - .../ipmctl/unsupported/capabilities.txt | 5 - actions/test.documentation-contract.sh | 10 +- actions/test.ipmctl-contract.sh | 396 ++---- actions/test.ipmctl-source-build.sh | 102 -- actions/test.llm-host-contract.sh | 17 +- actions/test.runner-contract.sh | 42 +- actions/test.sudo-access.sh | 2 +- actions/validate.runtime.sh | 9 +- ansible/cli/ipmctl.yml | 1231 +++++------------ ansible/cli/llm/host.yml | 107 +- ansible/files/ipmctl/apply-patch.yml | 96 ++ ansible/files/ipmctl/compatibility-matrix.yml | 23 - ansible/files/ipmctl/ipmctl-inventory.py | 319 ----- ...0001-edk2-stable202511-host-os-build.patch | 22 + ...0002-ipmctl-disable-c-release-werror.patch | 37 + ...-remove-pie-from-shared-linker-flags.patch | 38 + ansible/files/ipmctl/patches/README.md | 27 + ansible/files/ipmctl/source-profile.py | 113 -- ansible/files/llm/host-inventory.py | 3 +- ansible/packages.yml | 2 +- docs/actions/publish/readme.md | 4 + docs/actions/readme.md | 5 +- docs/actions/test/ipmctl-contract/readme.md | 39 +- docs/actions/validate/runtime/readme.md | 4 +- docs/cli/ipmctl/readme.md | 325 ++--- docs/cli/llm/host/readme.md | 26 +- setup/cli/ipmctl.sh | 448 +++--- setup/cli/llm/host.sh | 7 +- 57 files changed, 1211 insertions(+), 2376 deletions(-) delete mode 100644 actions/fixtures/ipmctl/app-direct/memory-resources.txt delete mode 100644 actions/fixtures/ipmctl/app-direct/regions.txt delete mode 100644 actions/fixtures/ipmctl/malformed/dimms.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/capabilities.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/capabilities.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/dimms.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/dimms.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/goal.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/goal.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/memory-resources.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/memory-resources.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/ndctl-dimms.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/ndctl-dimms.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/ndctl-namespaces.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/ndctl-namespaces.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/ndctl-regions.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/ndctl-regions.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/regions.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/regions.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/sensors.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/sensors.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/topology.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/topology.txt delete mode 100644 actions/fixtures/ipmctl/memory-mode/version.rc delete mode 100644 actions/fixtures/ipmctl/memory-mode/version.txt delete mode 100644 actions/fixtures/ipmctl/namespaces/ndctl-namespaces.txt delete mode 100644 actions/fixtures/ipmctl/partial-failure/topology.rc delete mode 100644 actions/fixtures/ipmctl/pending-goal/goal.txt delete mode 100644 actions/fixtures/ipmctl/unsupported/capabilities.txt delete mode 100755 actions/test.ipmctl-source-build.sh create mode 100644 ansible/files/ipmctl/apply-patch.yml delete mode 100644 ansible/files/ipmctl/compatibility-matrix.yml delete mode 100755 ansible/files/ipmctl/ipmctl-inventory.py create mode 100644 ansible/files/ipmctl/patches/0001-edk2-stable202511-host-os-build.patch create mode 100644 ansible/files/ipmctl/patches/0002-ipmctl-disable-c-release-werror.patch create mode 100644 ansible/files/ipmctl/patches/0003-ipmctl-remove-pie-from-shared-linker-flags.patch create mode 100644 ansible/files/ipmctl/patches/README.md delete mode 100755 ansible/files/ipmctl/source-profile.py diff --git a/.github/workflows/www.pages.yml b/.github/workflows/www.pages.yml index 7142b6c..61ccca5 100644 --- a/.github/workflows/www.pages.yml +++ b/.github/workflows/www.pages.yml @@ -12,26 +12,32 @@ on: - "readme.md" - "actions/**" - ".github/workflows/www.pages.yml" + pull_request: + paths: + - "setup/**" + - "ansible/**" + - "docs/**" + - "www/**" + - "readme.md" + - "actions/**" + - ".github/workflows/www.pages.yml" workflow_dispatch: permissions: - contents: write + contents: read concurrency: group: www-pages-${{ github.ref }} cancel-in-progress: true jobs: - deploy-www: - needs: validate-ipmctl-source + validate-runtime: runs-on: ubuntu-slim timeout-minutes: 10 steps: - name: Checkout repository uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Configure validation Python uses: actions/setup-python@v5 @@ -46,9 +52,17 @@ jobs: - name: Validate runtime contract env: LLM_SOURCE_NETWORK_VERIFY: "1" - IPMCTL_SOURCE_NETWORK_VERIFY: "1" run: bash ./actions/validate.runtime.sh + build-www: + needs: validate-runtime + runs-on: ubuntu-slim + timeout-minutes: 10 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install Pages build dependencies run: sudo apt-get update && sudo apt-get install -y pandoc rsync @@ -57,29 +71,35 @@ jobs: PUBLISH_DIR: static run: bash ./actions/www.pages.sh - - name: Deploy static to www branch - uses: peaceiris/actions-gh-pages@v4 + - name: Upload static Pages tree + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./static - publish_branch: www - force_orphan: true + name: www-static + path: static + if-no-files-found: error - validate-ipmctl-source: - runs-on: ubuntu-latest - timeout-minutes: 20 - container: debian:13 + deploy-www: + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + needs: build-www + runs-on: ubuntu-slim + timeout-minutes: 10 + permissions: + contents: write steps: - - name: Install pinned ipmctl build dependencies - run: | - apt-get update - apt-get install -y \ - git ca-certificates build-essential cmake pkgconf python3 \ - ndctl daxctl libndctl6 libndctl-dev asciidoctor - - name: Checkout repository uses: actions/checkout@v4 - - name: Build reviewed ipmctl source - run: bash ./actions/test.ipmctl-source-build.sh + - name: Download static Pages tree + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: www-static + path: static + + - name: Deploy static to www branch + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./static + publish_branch: www + force_orphan: true diff --git a/actions/fixtures/ipmctl/app-direct/memory-resources.txt b/actions/fixtures/ipmctl/app-direct/memory-resources.txt deleted file mode 100644 index ce877fb..0000000 --- a/actions/fixtures/ipmctl/app-direct/memory-resources.txt +++ /dev/null @@ -1,5 +0,0 @@ -Volatile DDR Capacity | 103079215104 B -Volatile PMem module Capacity | 0 B -AppDirect PMem module Capacity | 412316860416 B -Cache DDR Capacity | 0 B -Inaccessible PMem module Capacity | 0 B diff --git a/actions/fixtures/ipmctl/app-direct/regions.txt b/actions/fixtures/ipmctl/app-direct/regions.txt deleted file mode 100644 index 6011220..0000000 --- a/actions/fixtures/ipmctl/app-direct/regions.txt +++ /dev/null @@ -1,4 +0,0 @@ -SocketID | ISetID | PersistentMemoryType | Capacity | FreeCapacity | HealthState -================================================================================================= -0x0000 | 0x111111111111111 | AppDirect | 206158430208 B | 0 B | Healthy -0x0001 | 0x222222222222222 | AppDirect | 206158430208 B | 0 B | Healthy diff --git a/actions/fixtures/ipmctl/malformed/dimms.txt b/actions/fixtures/ipmctl/malformed/dimms.txt deleted file mode 100644 index 3d9b12e..0000000 --- a/actions/fixtures/ipmctl/malformed/dimms.txt +++ /dev/null @@ -1 +0,0 @@ -This output has no parseable PMem module records. diff --git a/actions/fixtures/ipmctl/memory-mode/capabilities.rc b/actions/fixtures/ipmctl/memory-mode/capabilities.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/capabilities.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/capabilities.txt b/actions/fixtures/ipmctl/memory-mode/capabilities.txt deleted file mode 100644 index ebb77df..0000000 --- a/actions/fixtures/ipmctl/memory-mode/capabilities.txt +++ /dev/null @@ -1,5 +0,0 @@ -PlatformConfigSupported=1 -AllowedVolatileMode=Memory Mode -CurrentVolatileMode=Memory Mode -AllowedAppDirectMode=App Direct -ModesSupported=1LM, 2LM, App Direct diff --git a/actions/fixtures/ipmctl/memory-mode/dimms.rc b/actions/fixtures/ipmctl/memory-mode/dimms.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/dimms.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/dimms.txt b/actions/fixtures/ipmctl/memory-mode/dimms.txt deleted file mode 100644 index 9b92282..0000000 --- a/actions/fixtures/ipmctl/memory-mode/dimms.txt +++ /dev/null @@ -1,8 +0,0 @@ ----DimmID=0x0001--- - ManageabilityState=Manageable - HealthState=Healthy - LockState=Disabled, Frozen ----DimmID=0x1001--- - ManageabilityState=Manageable - HealthState=Healthy - LockState=Unlocked diff --git a/actions/fixtures/ipmctl/memory-mode/goal.rc b/actions/fixtures/ipmctl/memory-mode/goal.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/goal.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/goal.txt b/actions/fixtures/ipmctl/memory-mode/goal.txt deleted file mode 100644 index 701e1d0..0000000 --- a/actions/fixtures/ipmctl/memory-mode/goal.txt +++ /dev/null @@ -1 +0,0 @@ -No memory allocation goals were found. diff --git a/actions/fixtures/ipmctl/memory-mode/memory-resources.rc b/actions/fixtures/ipmctl/memory-mode/memory-resources.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/memory-resources.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/memory-resources.txt b/actions/fixtures/ipmctl/memory-mode/memory-resources.txt deleted file mode 100644 index e22ad55..0000000 --- a/actions/fixtures/ipmctl/memory-mode/memory-resources.txt +++ /dev/null @@ -1,5 +0,0 @@ -Volatile DDR Capacity | 0 B -Volatile PMem module Capacity | 412316860416 B -AppDirect PMem module Capacity | 0 B -Cache DDR Capacity | 103079215104 B -Inaccessible PMem module Capacity | 0 B diff --git a/actions/fixtures/ipmctl/memory-mode/ndctl-dimms.rc b/actions/fixtures/ipmctl/memory-mode/ndctl-dimms.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/ndctl-dimms.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/ndctl-dimms.txt b/actions/fixtures/ipmctl/memory-mode/ndctl-dimms.txt deleted file mode 100644 index e77274d..0000000 --- a/actions/fixtures/ipmctl/memory-mode/ndctl-dimms.txt +++ /dev/null @@ -1 +0,0 @@ -[{"dev":"nmem0"},{"dev":"nmem1"}] diff --git a/actions/fixtures/ipmctl/memory-mode/ndctl-namespaces.rc b/actions/fixtures/ipmctl/memory-mode/ndctl-namespaces.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/ndctl-namespaces.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/ndctl-namespaces.txt b/actions/fixtures/ipmctl/memory-mode/ndctl-namespaces.txt deleted file mode 100644 index fe51488..0000000 --- a/actions/fixtures/ipmctl/memory-mode/ndctl-namespaces.txt +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/actions/fixtures/ipmctl/memory-mode/ndctl-regions.rc b/actions/fixtures/ipmctl/memory-mode/ndctl-regions.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/ndctl-regions.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/ndctl-regions.txt b/actions/fixtures/ipmctl/memory-mode/ndctl-regions.txt deleted file mode 100644 index fe51488..0000000 --- a/actions/fixtures/ipmctl/memory-mode/ndctl-regions.txt +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/actions/fixtures/ipmctl/memory-mode/regions.rc b/actions/fixtures/ipmctl/memory-mode/regions.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/regions.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/regions.txt b/actions/fixtures/ipmctl/memory-mode/regions.txt deleted file mode 100644 index d27c159..0000000 --- a/actions/fixtures/ipmctl/memory-mode/regions.txt +++ /dev/null @@ -1 +0,0 @@ -There are no Regions defined in the system. diff --git a/actions/fixtures/ipmctl/memory-mode/sensors.rc b/actions/fixtures/ipmctl/memory-mode/sensors.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/sensors.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/sensors.txt b/actions/fixtures/ipmctl/memory-mode/sensors.txt deleted file mode 100644 index d44d18c..0000000 --- a/actions/fixtures/ipmctl/memory-mode/sensors.txt +++ /dev/null @@ -1,2 +0,0 @@ -DimmID=0x0001 -Health=Healthy diff --git a/actions/fixtures/ipmctl/memory-mode/topology.rc b/actions/fixtures/ipmctl/memory-mode/topology.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/topology.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/topology.txt b/actions/fixtures/ipmctl/memory-mode/topology.txt deleted file mode 100644 index 0511175..0000000 --- a/actions/fixtures/ipmctl/memory-mode/topology.txt +++ /dev/null @@ -1,6 +0,0 @@ -DimmID | MemoryType | Capacity | PhysicalID | DeviceLocator | SocketID -================================================================================================ -0x0001 | Logical Non-Volatile Device | 206158430208 B | 0x0028 | CPU1_DIMM_A2 | 0x0000 -0x1001 | Logical Non-Volatile Device | 206158430208 B | 0x0044 | CPU2_DIMM_A2 | 0x0001 -N/A | DDR4 | 51539607552 B | 0x0026 | CPU1_DIMM_A1 | 0x0000 -N/A | DDR4 | 51539607552 B | 0x0042 | CPU2_DIMM_A1 | 0x0001 diff --git a/actions/fixtures/ipmctl/memory-mode/version.rc b/actions/fixtures/ipmctl/memory-mode/version.rc deleted file mode 100644 index 573541a..0000000 --- a/actions/fixtures/ipmctl/memory-mode/version.rc +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/actions/fixtures/ipmctl/memory-mode/version.txt b/actions/fixtures/ipmctl/memory-mode/version.txt deleted file mode 100644 index f0a4be9..0000000 --- a/actions/fixtures/ipmctl/memory-mode/version.txt +++ /dev/null @@ -1 +0,0 @@ -Intel(R) Optane(TM) Persistent Memory Command Line Interface Version 03.00.00.0538 diff --git a/actions/fixtures/ipmctl/namespaces/ndctl-namespaces.txt b/actions/fixtures/ipmctl/namespaces/ndctl-namespaces.txt deleted file mode 100644 index 00f9ff1..0000000 --- a/actions/fixtures/ipmctl/namespaces/ndctl-namespaces.txt +++ /dev/null @@ -1 +0,0 @@ -[{"dev":"namespace0.0","mode":"fsdax","size":206158430208}] diff --git a/actions/fixtures/ipmctl/partial-failure/topology.rc b/actions/fixtures/ipmctl/partial-failure/topology.rc deleted file mode 100644 index d00491f..0000000 --- a/actions/fixtures/ipmctl/partial-failure/topology.rc +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/actions/fixtures/ipmctl/pending-goal/goal.txt b/actions/fixtures/ipmctl/pending-goal/goal.txt deleted file mode 100644 index 5f38600..0000000 --- a/actions/fixtures/ipmctl/pending-goal/goal.txt +++ /dev/null @@ -1,3 +0,0 @@ -SocketID=0 -Status=New -MemoryMode=100 diff --git a/actions/fixtures/ipmctl/unsupported/capabilities.txt b/actions/fixtures/ipmctl/unsupported/capabilities.txt deleted file mode 100644 index e18e0b3..0000000 --- a/actions/fixtures/ipmctl/unsupported/capabilities.txt +++ /dev/null @@ -1,5 +0,0 @@ -PlatformConfigSupported=0 -AllowedVolatileMode=1LM -CurrentVolatileMode=1LM -AllowedAppDirectMode=None -ModesSupported=1LM diff --git a/actions/test.documentation-contract.sh b/actions/test.documentation-contract.sh index 90976f7..114d880 100644 --- a/actions/test.documentation-contract.sh +++ b/actions/test.documentation-contract.sh @@ -70,7 +70,6 @@ require.runner.options.documented "setup/cli/llm/ktransformers.sh" "docs/cli/llm for document in \ docs/cli/gpu/readme.md \ - docs/cli/ipmctl/readme.md \ docs/cli/llm/host/readme.md \ docs/cli/llm/llamacpp/readme.md \ docs/cli/llm/ktransformers/readme.md \ @@ -85,8 +84,15 @@ for document in \ require_regex "${document}" '^[[:space:]]+bash -s -- apply([[:space:]]|$)' require_regex "${document}" '^[[:space:]]+sudo bash -s -- (apply|validate)([[:space:]]|$)' done +for marker in \ + 'wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh' \ + '/dev/tty'; do + require_contains "docs/cli/ipmctl/readme.md" "${marker}" +done +require_regex "docs/cli/ipmctl/readme.md" '^[[:space:]]+bash -s -- install([[:space:]]|$)' +require_regex "docs/cli/ipmctl/readme.md" '^[[:space:]]+sudo bash -s -- verify([[:space:]]|$)' require_contains "docs/cli/gpu/readme.md" '/etc/ansible/debian/facts/gpu.yml' -require_contains "docs/cli/ipmctl/readme.md" '/etc/ansible/debian/facts/ipmctl.yml' +require_contains "docs/cli/ipmctl/readme.md" '/var/lib/devs-guide/ipmctl/receipt.json' require_contains "docs/cli/llm/host/readme.md" '/etc/ansible/debian/facts/llm-host.yml' require_contains "docs/cli/llm/host/readme.md" '/etc/ansible/debian/facts/gpu.yml' require_contains "docs/cli/llm/host/readme.md" '/etc/ansible/debian/facts/nvidia.yml' diff --git a/actions/test.ipmctl-contract.sh b/actions/test.ipmctl-contract.sh index 475c804..e53c87e 100755 --- a/actions/test.ipmctl-contract.sh +++ b/actions/test.ipmctl-contract.sh @@ -4,7 +4,6 @@ set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" ACTION_LABEL="test.ipmctl-contract" -NETWORK_VERIFY="${IPMCTL_SOURCE_NETWORK_VERIFY:-0}" rc=0 SHELL_ONLY=0 @@ -20,296 +19,193 @@ esac # shellcheck source=actions/lib/contracts.sh source "${ROOT}/actions/lib/contracts.sh" -echo "[${ACTION_LABEL}] checking pinned ipmctl and guarded-goal contracts..." +echo "[${ACTION_LABEL}] checking the pinned Debian 13 ipmctl installer..." for file in \ setup/cli/ipmctl.sh \ ansible/cli/ipmctl.yml \ + ansible/files/ipmctl/apply-patch.yml \ + ansible/files/ipmctl/patches/README.md \ + ansible/files/ipmctl/patches/0001-edk2-stable202511-host-os-build.patch \ + ansible/files/ipmctl/patches/0002-ipmctl-disable-c-release-werror.patch \ + ansible/files/ipmctl/patches/0003-ipmctl-remove-pie-from-shared-linker-flags.patch \ + docs/cli/ipmctl/readme.md; do + require_file "${file}" +done + +for removed in \ + actions/test.ipmctl-source-build.sh \ ansible/files/ipmctl/source-profile.py \ ansible/files/ipmctl/ipmctl-inventory.py \ - ansible/files/ipmctl/compatibility-matrix.yml \ - actions/test.ipmctl-source-build.sh \ - docs/cli/ipmctl/readme.md \ - actions/fixtures/ipmctl/memory-mode/version.txt \ - actions/fixtures/ipmctl/memory-mode/memory-resources.txt \ - actions/fixtures/ipmctl/app-direct/memory-resources.txt \ - actions/fixtures/ipmctl/app-direct/regions.txt \ - actions/fixtures/ipmctl/unsupported/capabilities.txt \ - actions/fixtures/ipmctl/malformed/dimms.txt \ - actions/fixtures/ipmctl/namespaces/ndctl-namespaces.txt \ - actions/fixtures/ipmctl/pending-goal/goal.txt \ - actions/fixtures/ipmctl/partial-failure/topology.rc; do - require_file "${file}" + ansible/files/ipmctl/compatibility-matrix.yml; do + if [[ -e "${ROOT}/${removed}" ]]; then + contract.error "obsolete ipmctl implementation remains: ${removed}" + fi done +if find "${ROOT}/actions/fixtures/ipmctl" -type f -print -quit 2>/dev/null | grep -q .; then + contract.error "obsolete ipmctl parser fixtures remain" +fi require_shell_syntax "setup/cli/ipmctl.sh" +require_shell_syntax "actions/test.ipmctl-contract.sh" + for marker in \ + 'Usage: ipmctl.sh [install|verify]' \ + 'readonly EXIT_SOFTWARE=1' \ + 'readonly EXIT_HARDWARE=2' \ + 'readonly EXIT_BLOCKED=3' \ + 'readonly EXIT_USAGE=64' \ + 'readonly IPMCTL_BIN=/usr/local/bin/ipmctl' \ + 'readonly IPMCTL_VERSION=03.00.00.0538' \ 'FEATURE_PLAYBOOKS=("install.packages.yml" "cli/ipmctl.yml")' \ - 'files/ipmctl/source-profile.py' \ - 'files/ipmctl/ipmctl-inventory.py' \ - 'files/ipmctl/compatibility-matrix.yml' \ - '--commit=FULL_40_CHARACTER_SHA' \ - '--edk2-commit=FULL_40_CHARACTER_SHA' \ - '--goal=memory-mode|app-direct|app-direct-not-interleaved' \ - '--allow-destructive-goal-change' \ - 'runner.confirm.exact' \ - 'GOAL_CONFIRMATION_AUTHORIZED=true' \ - 'I UNDERSTAND PMEM GOAL CHANGES DESTROY DATA AND REQUIRE REBOOT' \ - 'stage.reviewed.sources' \ - 'runner.ensure.privileged.session'; do + 'files/ipmctl/apply-patch.yml' \ + 'files/ipmctl/patches/0001-edk2-stable202511-host-os-build.patch' \ + 'files/ipmctl/patches/0002-ipmctl-disable-c-release-werror.patch' \ + 'files/ipmctl/patches/0003-ipmctl-remove-pie-from-shared-linker-flags.patch' \ + 'runner.ensure.privileged.session' \ + 'runner.run.as.root "${IPMCTL_BIN}"' \ + 'hardware.probe dimms "PMem DIMMs" show -a -dimm' \ + 'hardware.probe topology "PMem topology" show -topology' \ + 'hardware.probe memoryresources "PMem memory resources" show -memoryresources' \ + 'hardware.probe goal "PMem current or pending goal" show -a -goal'; do require_contains "setup/cli/ipmctl.sh" "${marker}" done for marker in \ - "ipmctl_mode_effective in ['apply', 'validate', 'goal-plan', 'goal-apply']" \ - 'ipmctl_facts_path: /etc/ansible/debian/facts/ipmctl.yml' \ - 'Refuse Debian-packaged or foreign-repository ipmctl migration' \ - 'Refuse unmanaged local ipmctl replacement' \ - 'Fail closed on unsafe PMem goal prerequisites' \ - "ipmctl_mode_effective == 'goal-apply'" \ - 'ipmctl_goal_confirmation_authorized | bool' \ - 'Return machine-readable PMem goal-plan disposition' \ - 'Apply pinned upstream Linux compatibility patch' \ - 'Verify pinned upstream Linux patch applicability' \ - 'Verify pinned upstream Linux compatibility patch application' \ - 'ipmctl_os_patch_preflight.rc' \ - '"-DBUILDNUM={{ ipmctl_profile_policy.binary_version }}"' \ - 'ipmctl_previous_facts.ipmctl.source.binary_version' \ - 'ipmctl_previous_facts.ipmctl.source.os_patch_script' \ - 'ipmctl_previous_facts.ipmctl.source.os_patch' \ - 'ipmctl_profile_policy.binary_version in ipmctl_inventory.binary.version' \ - 'namespace_deleted: false' \ - 'pcd_deleted: false' \ - 'firmware_changed: false' \ - 'security_changed: false' \ - 'reboot_performed: false'; do + 'ipmctl_tag: v03.00.00.0538' \ + 'ipmctl_commit: a71f2fb1c90dd07f9862b71c789881132193e8f9' \ + 'ipmctl_expected_version: 03.00.00.0538' \ + 'ipmctl_edk2_tag: edk2-stable202511' \ + 'ipmctl_edk2_commit: 46548b1adac82211d8d11da12dd914f41e7aa775' \ + 'ipmctl_install_prefix: /usr/local' \ + 'ipmctl_receipt_path: /var/lib/devs-guide/ipmctl/receipt.json' \ + 'Refuse an unmanaged local ipmctl binary' \ + 'Determine whether installation is current' \ + 'Fetch only reviewed source tags' \ + 'Check out reviewed commits detached' \ + 'Require exact source identities' \ + 'Preserve EDK2 CRLF source as a binary Git diff' \ + 'Apply finite reviewed compatibility pack' \ + 'Link reviewed EDK2 components explicitly' \ + '-DRELEASE=ON' \ + '-DCMAKE_BUILD_TYPE=Release' \ + '"-DBUILDNUM={{ ipmctl_expected_version }}"' \ + 'Compile reviewed Release build' \ + 'Write atomic installation receipt'; do require_contains "ansible/cli/ipmctl.yml" "${marker}" done for marker in \ - 'IPMCTL_BINARY_VERSION="03.00.00.0538"' \ - 'IPMCTL_OS_PATCH="src/os/patches/0001-Ignore-STATIC_ASSERTs-and-NULL-define-for-os-and-ut-builds.patch"' \ - './updateedk.sh' \ - './patch_OS.sh' \ - 'git apply --numstat' \ - 'git apply --check' \ - '--ignore-space-change' \ - '--ignore-whitespace' \ - '--whitespace=nowarn' \ - 'git apply --reverse --check' \ - '-DBUILDNUM="${IPMCTL_BINARY_VERSION}"' \ - "grep -R -Fq -- '-Werror' build/CMakeFiles" \ - 'version_token' \ - 'ldd "${TEST_ROOT}/install/bin/ipmctl"'; do - require_contains "actions/test.ipmctl-source-build.sh" "${marker}" + 'checksum_algorithm: sha256' \ + 'git' \ + 'apply' \ + '--numstat' \ + '--check' \ + '--whitespace=error-all' \ + '--reverse' \ + 'diff' \ + 'ipmctl_patch_preimage' \ + 'ipmctl_patch_postimage'; do + require_contains "ansible/files/ipmctl/apply-patch.yml" "${marker}" done -for file in actions/test.ipmctl-source-build.sh ansible/cli/ipmctl.yml; do - reject_contains "${file}" '-Wno-error' +declare -a patch_specs=( + '0001-edk2-stable202511-host-os-build.patch|ac6f0ea143c357c582135472defe8e936a63d7997221a29d4d0e4c349d7ac013|MdePkg/Include/Base.h' + '0002-ipmctl-disable-c-release-werror.patch|d1928dc874219578abbc9eab5cc7a826ccf88457bd148f268aff367d134321b8|CMakeLists.txt' + '0003-ipmctl-remove-pie-from-shared-linker-flags.patch|f926a6b07ad33b09f09032e6fd06a9229855d9d0501cfc7e67ecbb4c3c28a031|CMakeLists.txt' +) + +for spec in "${patch_specs[@]}"; do + IFS='|' read -r filename expected_sha expected_target <<<"${spec}" + patch_path="${ROOT}/ansible/files/ipmctl/patches/${filename}" + if command -v sha256sum >/dev/null 2>&1; then + actual_sha="$(sha256sum "${patch_path}" | awk '{print $1}')" + else + actual_sha="$(shasum -a 256 "${patch_path}" | awk '{print $1}')" + fi + [[ "${actual_sha}" == "${expected_sha}" ]] || \ + contract.error "patch checksum drifted: ${filename}: ${actual_sha}" + actual_targets="$(git apply --numstat "${patch_path}" | awk -F '\t' 'NF >= 3 {print $3}')" + [[ "${actual_targets}" == "${expected_target}" ]] || \ + contract.error "patch target drifted: ${filename}: ${actual_targets}" + require_contains "ansible/cli/ipmctl.yml" "sha256: ${expected_sha}" done -update_line="$(grep -n -m1 'updateedk[.]sh' actions/test.ipmctl-source-build.sh | cut -d: -f1)" -patch_line="$( - grep -n -m1 '^[[:space:]]*[.]/patch_OS[.]sh[[:space:]]*|' \ - actions/test.ipmctl-source-build.sh | - cut -d: -f1 -)" -preflight_line="$(grep -n -m1 'git apply --check' actions/test.ipmctl-source-build.sh | cut -d: -f1)" -cmake_line="$(grep -n -m1 'cmake -S' actions/test.ipmctl-source-build.sh | cut -d: -f1)" -if [[ -z "${update_line}" || -z "${preflight_line}" || -z "${patch_line}" || -z "${cmake_line}" ]] || - ((update_line >= preflight_line || preflight_line >= patch_line || patch_line >= cmake_line)); then - contract.error "ipmctl source build must run updateedk.sh, patch preflight, patch_OS.sh, then CMake" -fi - -for prohibited in \ - 'delete -pcd' \ - 'delete -goal' \ - 'delete -dimm' \ - 'start -format' \ - 'load -firmware' \ - 'set -dimm' \ - 'ndctl destroy-namespace' \ - 'systemctl reboot' \ - '/sbin/reboot'; do - reject_contains "ansible/cli/ipmctl.yml" "${prohibited}" +for file in setup/cli/ipmctl.sh ansible/cli/ipmctl.yml; do + for prohibited in \ + 'delete -pcd' \ + 'delete -goal' \ + 'delete -dimm' \ + 'start -format' \ + 'load -firmware' \ + 'set -dimm' \ + 'ndctl destroy-namespace' \ + 'systemctl reboot' \ + '/sbin/reboot' \ + './updateedk.sh' \ + './patch_OS.sh' \ + '--ignore-space-change' \ + '--ignore-whitespace' \ + '--whitespace=nowarn' \ + '-Wno-error'; do + reject_contains "${file}" "${prohibited}" + done done -set +e -confirmation_trace="$( - TEST_RUNNER="${ROOT}/setup/cli/ipmctl.sh" bash -c ' - source "${TEST_RUNNER}" - FEATURE_MODE=goal-apply - ANSIBLE_VENV_BIN=/usr/bin/true - GOAL_PLAN_RESULT_PATH="$(mktemp)" - runner.ensure.privileged.session() { return 0; } - write.extra.vars.file() { :; } - run.feature.playbook() { printf "no_op=false\n" > "${GOAL_PLAN_RESULT_PATH}"; } - runner.confirm.exact() { - printf "PROMPT=%s\nEXPECTED=%s\n" "$1" "$2" - return 3 - } - run.managed.mode - ' 2>&1 -)" -confirmation_status=$? -set -e -if [[ "${confirmation_status}" -ne 3 ]]; then - contract.error "non-no-op goal-apply did not stop when exact confirmation was rejected" -fi -if [[ "${confirmation_trace}" != *"EXPECTED=I UNDERSTAND PMEM GOAL CHANGES DESTROY DATA AND REQUIRE REBOOT"* ]]; then - contract.error "goal-apply did not pass the exact destructive confirmation phrase" -fi +for obsolete_interface in \ + 'goal-plan' \ + 'goal-apply' \ + '--allow-destructive-goal-change' \ + '--repository-url=' \ + '--commit=' \ + '--build-type='; do + reject_contains "setup/cli/ipmctl.sh" "${obsolete_interface}" +done +help_output="$(bash "${ROOT}/setup/cli/ipmctl.sh" --help)" || \ + contract.error "ipmctl --help failed" +[[ "${help_output}" == *'Usage: ipmctl.sh [install|verify]'* ]] || \ + contract.error "ipmctl --help omitted the two-mode interface" set +e -noop_trace="$( - TEST_RUNNER="${ROOT}/setup/cli/ipmctl.sh" bash -c ' - source "${TEST_RUNNER}" - FEATURE_MODE=goal-apply - ANSIBLE_VENV_BIN=/usr/bin/true - GOAL_PLAN_RESULT_PATH="$(mktemp)" - runner.ensure.privileged.session() { return 0; } - write.extra.vars.file() { printf "WRITE:%s\n" "${FEATURE_MODE}"; } - run.feature.playbook() { - printf "RUN:%s\n" "${FEATURE_MODE}" - [[ "${FEATURE_MODE}" != goal-plan ]] || printf "no_op=true\n" > "${GOAL_PLAN_RESULT_PATH}" - } - runner.confirm.exact() { printf "UNEXPECTED_CONFIRM\n"; return 90; } - run.managed.mode - ' 2>&1 -)" -noop_status=$? +bash "${ROOT}/setup/cli/ipmctl.sh" unsupported-mode >/dev/null 2>&1 +invalid_status=$? set -e -if [[ "${noop_status}" -ne 0 ]] || \ - [[ "${noop_trace}" != *"RUN:goal-plan"* ]] || \ - [[ "${noop_trace}" != *"RUN:validate"* ]] || \ - [[ "${noop_trace}" == *"UNEXPECTED_CONFIRM"* ]]; then - contract.error "a settled no-op goal did not refresh facts without confirmation or mutation" -fi +[[ "${invalid_status}" -eq 64 ]] || \ + contract.error "invalid ipmctl mode must exit 64, got ${invalid_status}" require_contains "ansible/packages.yml" 'ipmctl_build:' require_contains "ansible/install.packages.yml" ' - ipmctl_build' -require_contains "setup/cli/llm/host.sh" '--require-ipmctl' -require_contains "ansible/cli/llm/host.yml" 'llm_host_ipmctl_facts_path: /etc/ansible/debian/facts/ipmctl.yml' -require_contains "docs/cli/llm/host/readme.md" '/etc/ansible/debian/facts/ipmctl.yml' +require_contains "ansible/cli/llm/host.yml" 'llm_host_ipmctl_binary_path: /usr/local/bin/ipmctl' +require_contains "ansible/cli/llm/host.yml" 'llm_host_ipmctl_expected_version: 03.00.00.0538' +reject_contains "ansible/cli/llm/host.yml" '/etc/ansible/debian/facts/ipmctl.yml' +require_contains ".github/workflows/www.pages.yml" 'validate-runtime:' +reject_contains ".github/workflows/www.pages.yml" 'validate-ipmctl-source' +require_contains "actions/publication.manifest" 'file|setup/cli/ipmctl.sh|setup/cli/ipmctl.sh' +require_contains "actions/publication.manifest" 'tree|ansible|ansible' if ! validate_yaml_file "${ROOT}/ansible/cli/ipmctl.yml"; then rc=1 fi +if ! validate_yaml_file "${ROOT}/ansible/files/ipmctl/apply-patch.yml"; then + rc=1 +fi if ! validate_shell_payloads "${ROOT}/ansible/cli/ipmctl.yml"; then rc=1 fi -if [[ "${SHELL_ONLY}" -eq 0 ]]; then - matrix="${ROOT}/ansible/files/ipmctl/compatibility-matrix.yml" - profile_helper="${ROOT}/ansible/files/ipmctl/source-profile.py" - inventory_helper="${ROOT}/ansible/files/ipmctl/ipmctl-inventory.py" - fixture_base="${ROOT}/actions/fixtures/ipmctl/memory-mode" - - python3 "${profile_helper}" \ - --matrix "${matrix}" \ - --profile trixie-v03.00.00.0538 \ - --repository-url https://github.com/intel/ipmctl.git \ - --release v03.00.00.0538 \ - --commit a71f2fb1c90dd07f9862b71c789881132193e8f9 \ - --edk2-repository-url https://github.com/tianocore/edk2.git \ - --edk2-release edk2-stable202111 \ - --edk2-commit bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 >/dev/null || rc=1 - - if python3 "${profile_helper}" \ - --matrix "${matrix}" \ - --profile trixie-v03.00.00.0538 \ - --repository-url https://github.com/intel/ipmctl.git \ - --release v03.00.00.0538 \ - --commit a71f2fb \ - --edk2-repository-url https://github.com/tianocore/edk2.git \ - --edk2-release edk2-stable202111 \ - --edk2-commit bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 >/dev/null 2>&1; then - contract.error "a shortened ipmctl commit was accepted" +if [[ "${SHELL_ONLY}" -eq 0 ]] && command -v ansible-playbook >/dev/null 2>&1; then + if ! ansible-playbook --syntax-check -i localhost, \ + -e ansible_python_interpreter_managed=/usr/bin/python3 \ + -e ipmctl_build_user=nobody \ + -e ipmctl_build_group=nogroup \ + -e ipmctl_build_home=/tmp \ + "${ROOT}/ansible/cli/ipmctl.yml"; then + contract.error "ipmctl playbook failed ansible-playbook --syntax-check" fi - - snapshot="$( - python3 "${inventory_helper}" --fixture-dir "${fixture_base}" - )" || { - contract.error "ipmctl Memory Mode fixture execution failed" - snapshot="" - } - if [[ -n "${snapshot}" ]]; then - python3 - "${snapshot}" <<'PY' || rc=1 -import json -import sys - -snapshot = json.loads(sys.argv[1]) -assert snapshot["schema_version"] == 1 -assert snapshot["hardware"]["socket_ids"] == [0, 1] -assert snapshot["hardware"]["topology_verified"] is True -assert snapshot["hardware"]["manageable"] is True -assert snapshot["hardware"]["healthy"] is True -assert snapshot["hardware"]["security_safe_for_goal"] is True -assert snapshot["memory_resources"]["current_mode"] == "memory-mode" -assert snapshot["memory_resources"]["memory_mode_verified"] is True -assert snapshot["pending_goal"]["present"] is False -assert snapshot["ndctl"]["namespace_count"] == 0 -assert snapshot["readiness"]["goal_change_supported"] is True -PY - fi - - for scenario in app-direct unsupported malformed namespaces pending-goal partial-failure; do - snapshot="$( - python3 "${inventory_helper}" \ - --fixture-dir "${ROOT}/actions/fixtures/ipmctl/${scenario}" \ - --fixture-base-dir "${fixture_base}" - )" || { - contract.error "ipmctl ${scenario} fixture execution failed" - snapshot="" - } - [[ -n "${snapshot}" ]] || continue - python3 - "${scenario}" "${snapshot}" <<'PY' || rc=1 -import json -import sys - -scenario = sys.argv[1] -snapshot = json.loads(sys.argv[2]) -if scenario == "app-direct": - assert snapshot["memory_resources"]["current_mode"] == "app-direct" - assert snapshot["memory_resources"]["memory_mode_verified"] is False -elif scenario == "unsupported": - assert snapshot["capabilities"]["platform_config_supported"] is False - assert snapshot["readiness"]["goal_change_supported"] is False -elif scenario == "malformed": - assert snapshot["hardware"]["present"] is False - assert snapshot["readiness"]["inventory_ready"] is False - assert snapshot["readiness"]["goal_change_supported"] is False -elif scenario == "namespaces": - assert snapshot["ndctl"]["namespace_count"] == 1 -elif scenario == "pending-goal": - assert snapshot["pending_goal"]["present"] is True - assert snapshot["readiness"]["settled"] is False -elif scenario == "partial-failure": - assert snapshot["commands"]["topology"]["rc"] == 1 - assert snapshot["readiness"]["inventory_ready"] is False -PY - done -else - echo "[${ACTION_LABEL}] shell-only mode: deferred Python fixtures and source verification to CI" -fi - -resolve_remote_tag() { - local repository="$1" release="$2" output="" direct="" peeled="" - output="$(git ls-remote --tags "${repository}" "refs/tags/${release}" "refs/tags/${release}^{}")" - direct="$(printf '%s\n' "${output}" | awk -v ref="refs/tags/${release}" '$2 == ref {print $1}')" - peeled="$(printf '%s\n' "${output}" | awk -v ref="refs/tags/${release}^{}" '$2 == ref {print $1}')" - printf '%s\n' "${peeled:-${direct}}" -} - -if [[ "${SHELL_ONLY}" -eq 0 && "${NETWORK_VERIFY}" == 1 ]]; then - actual_ipmctl="$(resolve_remote_tag https://github.com/intel/ipmctl.git v03.00.00.0538)" - [[ "${actual_ipmctl}" == a71f2fb1c90dd07f9862b71c789881132193e8f9 ]] || - contract.error "ipmctl reviewed tag changed: ${actual_ipmctl}" - actual_edk2="$(resolve_remote_tag https://github.com/tianocore/edk2.git edk2-stable202111)" - [[ "${actual_edk2}" == bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 ]] || - contract.error "edk2 reviewed tag changed: ${actual_edk2}" +elif [[ "${SHELL_ONLY}" -eq 0 ]]; then + contract.warn "ansible-playbook unavailable; syntax check deferred to CI" else - echo "[${ACTION_LABEL}] source network verification deferred to GitHub Actions" + echo "[${ACTION_LABEL}] shell-only mode: deferred Ansible syntax check to CI" fi exit "${rc}" diff --git a/actions/test.ipmctl-source-build.sh b/actions/test.ipmctl-source-build.sh deleted file mode 100755 index c3eb2db..0000000 --- a/actions/test.ipmctl-source-build.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -ACTION_LABEL="test.ipmctl-source-build" -TEST_PARENT="${TMPDIR:-/tmp}" -TEST_ROOT="$(mktemp -d "${TEST_PARENT%/}/test.ipmctl-source-build.XXXXXX")" -IPMCTL_RELEASE="v03.00.00.0538" -IPMCTL_COMMIT="a71f2fb1c90dd07f9862b71c789881132193e8f9" -IPMCTL_BINARY_VERSION="03.00.00.0538" -IPMCTL_OS_PATCH="src/os/patches/0001-Ignore-STATIC_ASSERTs-and-NULL-define-for-os-and-ut-builds.patch" -EDK2_RELEASE="edk2-stable202111" -EDK2_COMMIT="bb1bba3d776733c41dbfa2d1dc0fe234819a79f2" - -cleanup() { - if [[ -n "${TEST_ROOT:-}" && "${TEST_ROOT}" == "${TEST_PARENT%/}/test.ipmctl-source-build."* ]]; then - rm -rf -- "${TEST_ROOT}" - fi -} -trap cleanup EXIT - -echo "[${ACTION_LABEL}] building the reviewed Debian 13 Release source tuple..." - -git init -q "${TEST_ROOT}/ipmctl" -git -C "${TEST_ROOT}/ipmctl" remote add origin https://github.com/intel/ipmctl.git -git -C "${TEST_ROOT}/ipmctl" fetch -q --depth=1 --no-tags origin \ - "refs/tags/${IPMCTL_RELEASE}:refs/tags/${IPMCTL_RELEASE}" -if [[ "$(git -C "${TEST_ROOT}/ipmctl" rev-list -n 1 "refs/tags/${IPMCTL_RELEASE}")" != "${IPMCTL_COMMIT}" ]]; then - echo "[${ACTION_LABEL}][error] reviewed ipmctl tag does not resolve to ${IPMCTL_COMMIT}" >&2 - exit 1 -fi -git -C "${TEST_ROOT}/ipmctl" checkout -q --detach "${IPMCTL_COMMIT}" - -git init -q "${TEST_ROOT}/edk2" -git -C "${TEST_ROOT}/edk2" remote add origin https://github.com/tianocore/edk2.git -git -C "${TEST_ROOT}/edk2" fetch -q --depth=1 --no-tags origin \ - "refs/tags/${EDK2_RELEASE}:refs/tags/${EDK2_RELEASE}" -if [[ "$(git -C "${TEST_ROOT}/edk2" rev-list -n 1 "refs/tags/${EDK2_RELEASE}")" != "${EDK2_COMMIT}" ]]; then - echo "[${ACTION_LABEL}][error] reviewed edk2 tag does not resolve to ${EDK2_COMMIT}" >&2 - exit 1 -fi -git -C "${TEST_ROOT}/edk2" checkout -q --detach "${EDK2_COMMIT}" - -( - cd "${TEST_ROOT}/ipmctl" - ./updateedk.sh - if [[ ! -x ./patch_OS.sh || ! -f "${IPMCTL_OS_PATCH}" ]]; then - echo "[${ACTION_LABEL}][error] pinned upstream Linux patch procedure is incomplete" >&2 - exit 1 - fi - patch_targets="$( - git apply --numstat "${IPMCTL_OS_PATCH}" | - awk -F '\t' '{print $3}' | - sort -u - )" - if [[ "${patch_targets}" != "MdePkg/Include/Base.h" ]]; then - echo "[${ACTION_LABEL}][error] upstream OS patch targets changed: ${patch_targets}" >&2 - exit 1 - fi - if ! git apply --check \ - --ignore-space-change \ - --ignore-whitespace \ - --whitespace=nowarn \ - "${IPMCTL_OS_PATCH}"; then - echo "[${ACTION_LABEL}][error] upstream OS patch cannot be applied to the reviewed EDK2 source" >&2 - exit 1 - fi - ./patch_OS.sh | tee "${TEST_ROOT}/patch-os.txt" - if ! git apply --reverse --check "${IPMCTL_OS_PATCH}"; then - echo "[${ACTION_LABEL}][error] upstream OS patch was not applied cleanly" >&2 - exit 1 - fi - cmake -S . -B build \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILDNUM="${IPMCTL_BINARY_VERSION}" \ - -DCMAKE_INSTALL_PREFIX="${TEST_ROOT}/install" - if ! grep -R -Fq -- '-Werror' build/CMakeFiles; then - echo "[${ACTION_LABEL}][error] reviewed Release configuration no longer enables -Werror" >&2 - exit 1 - fi - cmake --build build -j2 - cmake --install build -) - -version_output="$("${TEST_ROOT}/install/bin/ipmctl" version)" -printf '%s\n' "${version_output}" -version_token="$( - printf '%s\n' "${version_output}" | - grep -Eo '[0-9]{2}[.][0-9]{2}[.][0-9]{2}[.][0-9]{4}' | - head -n 1 || - true -)" -if [[ "${version_token}" != "${IPMCTL_BINARY_VERSION}" ]]; then - echo "[${ACTION_LABEL}][error] installed binary reports ${version_token:-no version}, expected ${IPMCTL_BINARY_VERSION}" >&2 - exit 1 -fi -ldd "${TEST_ROOT}/install/bin/ipmctl" | tee "${TEST_ROOT}/ldd.txt" -if grep -Fq 'not found' "${TEST_ROOT}/ldd.txt"; then - echo "[${ACTION_LABEL}][error] installed binary has an unresolved library" >&2 - exit 1 -fi diff --git a/actions/test.llm-host-contract.sh b/actions/test.llm-host-contract.sh index 30966ed..07cc0fb 100755 --- a/actions/test.llm-host-contract.sh +++ b/actions/test.llm-host-contract.sh @@ -61,10 +61,13 @@ for marker in \ 'Validate required NVIDIA producer contracts' \ 'Validate required NVLink producer contract' \ 'Validate required directed P2P evidence' \ - 'Validate required ipmctl producer contract' \ - 'Verify live ipmctl has no pending PMem goal' \ - 'Require live ipmctl identity and settled goal state' \ - '/etc/ansible/debian/facts/ipmctl.yml' \ + 'Verify live reviewed ipmctl version' \ + 'Verify live ipmctl memory resources' \ + 'Collect live ipmctl current or pending goal diagnostic' \ + 'Report live ipmctl goal diagnostic' \ + 'Require live ipmctl identity and memory resources' \ + 'llm_host_ipmctl_binary_path: /usr/local/bin/ipmctl' \ + 'llm_host_ipmctl_expected_version: 03.00.00.0538' \ 'producers:' \ 'ipmctl:' \ 'Read live NVIDIA PCI NUMA affinity' \ @@ -78,6 +81,12 @@ for marker in \ require_contains "ansible/cli/llm/host.yml" "${marker}" done +reject_contains "ansible/cli/llm/host.yml" '/etc/ansible/debian/facts/ipmctl.yml' +reject_contains "setup/cli/llm/host.sh" '/etc/ansible/debian/facts/ipmctl.yml' +require_contains "setup/cli/llm/host.sh" '/usr/local/bin/ipmctl version' +require_contains "setup/cli/llm/host.sh" '/usr/local/bin/ipmctl show -memoryresources' +require_contains "ansible/files/llm/host-inventory.py" '["/usr/local/bin/ipmctl", "show", "-memoryresources"]' + for prohibited in \ swapoff \ 'sysctl -w' \ diff --git a/actions/test.runner-contract.sh b/actions/test.runner-contract.sh index 077994a..b408917 100644 --- a/actions/test.runner-contract.sh +++ b/actions/test.runner-contract.sh @@ -42,7 +42,7 @@ for marker in \ require_contains "${runner_helper}" "${marker}" done -for runner in setup/cli/gpu.sh setup/cli/ipmctl.sh setup/cli/llm/host.sh setup/cli/llm/llamacpp.sh setup/cli/nvidia.sh setup/cli/nvlink.sh; do +for runner in setup/cli/gpu.sh setup/cli/llm/host.sh setup/cli/llm/llamacpp.sh setup/cli/nvidia.sh setup/cli/nvlink.sh; do runner_path="${ROOT}/${runner}" direct_fetch_count="$( grep -Ec '^[[:space:]]*(if[[:space:]]+![[:space:]]+)?wget[[:space:]]+-qO[[:space:]]' "${runner_path}" || true @@ -80,6 +80,46 @@ for runner in setup/cli/gpu.sh setup/cli/ipmctl.sh setup/cli/llm/host.sh setup/c fi done +# ipmctl intentionally has a smaller install/verify interface and prints its +# four read-only probe sections directly instead of implementing preflight +# report helpers shared by the inventory-oriented feature runners. +runner="setup/cli/ipmctl.sh" +runner_path="${ROOT}/${runner}" +direct_fetch_count="$( + grep -Ec '^[[:space:]]*(if[[:space:]]+![[:space:]]+)?wget[[:space:]]+-qO[[:space:]]' "${runner_path}" || true +)" +require_shell_syntax "${runner}" +for marker in \ + 'RUNNER_HELPER_URL' \ + 'source.runner.common' \ + 'runner.ensure.privileged.session' \ + 'runner.source.release.common' \ + 'runner.prepare.ansible.feature' \ + 'runner.run.ansible.playbooks' \ + 'runner.run.as.root' \ + 'FEATURE_TEMPLATE_REFS=()' \ + 'mktemp -d'; do + require_contains "${runner}" "${marker}" +done +for marker in \ + 'fail.streamed.managed.mode' \ + 'runner was executed from stdin' \ + 'ensure.root.or.sudo.reexec' \ + 'current.script.path' \ + 'use.local.feature.files' \ + 'fetch.feature.file' \ + 'fetch.runtime.support.file' \ + 'fetch.file()' \ + 'exec sudo'; do + reject_contains "${runner}" "${marker}" +done +if grep -Eq 'sudo[[:space:]]+-E([[:space:]]|$)|sudo[^#]*(wget|curl)' "${runner_path}"; then + contract.error "${runner} must not preserve the ambient environment or fetch inside sudo" +fi +if [[ "${direct_fetch_count}" -ne 1 ]]; then + contract.error "${runner} may directly fetch only the shared-runner bootstrap; found ${direct_fetch_count}" +fi + runner="setup/cli/llm/ktransformers.sh" runner_path="${ROOT}/${runner}" direct_fetch_count="$( diff --git a/actions/test.sudo-access.sh b/actions/test.sudo-access.sh index eb79e0a..08d5cec 100644 --- a/actions/test.sudo-access.sh +++ b/actions/test.sudo-access.sh @@ -229,7 +229,7 @@ expect_status 1 "${CASE_STATUS}" "no-TTY helper" expect_contains 'no usable /dev/tty is available' "${CASE_OUTPUT}" "no-TTY diagnostic" expect_count 0 'sudo <-v>' "${CASE_TRACE}" "no-TTY prompt" -for runner in setup/cli/gpu.sh setup/cli/ipmctl.sh setup/cli/llm/host.sh setup/cli/nvidia.sh setup/cli/nvlink.sh; do +for runner in setup/cli/gpu.sh setup/cli/llm/host.sh setup/cli/nvidia.sh setup/cli/nvlink.sh; do runner_path="${ROOT}/${runner}" # A cancelled prompt must stop at the first managed-mode operation. diff --git a/actions/validate.runtime.sh b/actions/validate.runtime.sh index e1eaea6..dc14a81 100644 --- a/actions/validate.runtime.sh +++ b/actions/validate.runtime.sh @@ -49,7 +49,6 @@ files=( "actions/test.documentation-contract.sh" "actions/test.gpu-contract.sh" "actions/test.ipmctl-contract.sh" - "actions/test.ipmctl-source-build.sh" "actions/test.llm-host-contract.sh" "actions/test.llm-source-contract.sh" "actions/test.nvidia-contract.sh" @@ -122,9 +121,11 @@ files=( "ansible/tasks/gpu.inventory.yml" "ansible/files/gpu/gpu-inventory.py" "ansible/files/gpu/nvidia_topology.py" - "ansible/files/ipmctl/source-profile.py" - "ansible/files/ipmctl/ipmctl-inventory.py" - "ansible/files/ipmctl/compatibility-matrix.yml" + "ansible/files/ipmctl/apply-patch.yml" + "ansible/files/ipmctl/patches/README.md" + "ansible/files/ipmctl/patches/0001-edk2-stable202511-host-os-build.patch" + "ansible/files/ipmctl/patches/0002-ipmctl-disable-c-release-werror.patch" + "ansible/files/ipmctl/patches/0003-ipmctl-remove-pie-from-shared-linker-flags.patch" "ansible/files/llm/host-inventory.py" "ansible/files/llm/source-profile.py" "ansible/files/llm/llamacpp/compatibility-matrix.yml" diff --git a/ansible/cli/ipmctl.yml b/ansible/cli/ipmctl.yml index 2b9d38d..6045be5 100644 --- a/ansible/cli/ipmctl.yml +++ b/ansible/cli/ipmctl.yml @@ -1,914 +1,429 @@ --- -- name: "[debian]: pinned ipmctl inventory and guarded PMem goals" +- name: "[debian]: pinned ipmctl source installer" hosts: localhost connection: local gather_facts: false - become: true + become: false vars: ansible_python_interpreter: "{{ ansible_python_interpreter_managed }}" - ipmctl_mode: validate - ipmctl_profile: trixie-v03.00.00.0538 - ipmctl_repository_url: https://github.com/intel/ipmctl.git - ipmctl_release: v03.00.00.0538 + ipmctl_mode: install + ipmctl_build_user: "" + ipmctl_build_group: "" + ipmctl_build_home: "" + ipmctl_repository: https://github.com/intel/ipmctl.git + ipmctl_tag: v03.00.00.0538 ipmctl_commit: a71f2fb1c90dd07f9862b71c789881132193e8f9 - ipmctl_edk2_repository_url: https://github.com/tianocore/edk2.git - ipmctl_edk2_release: edk2-stable202111 - ipmctl_edk2_commit: bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 - ipmctl_build_type: release - ipmctl_install_build_tools: false - ipmctl_staged_source_path: "" - ipmctl_staged_edk2_path: "" - ipmctl_goal: "" - ipmctl_socket_target: "" - ipmctl_goal_plan_result_path: "" - ipmctl_goal_confirmation_authorized: false - ipmctl_matrix_path: "{{ playbook_dir }}/../files/ipmctl/compatibility-matrix.yml" - ipmctl_inventory_helper_path: "{{ playbook_dir }}/../files/ipmctl/ipmctl-inventory.py" - ipmctl_facts_path: /etc/ansible/debian/facts/ipmctl.yml - ipmctl_transaction_root: /var/lib/ansible/debian/ipmctl/transactions - ipmctl_log_root: /var/log/ipmctl + ipmctl_expected_version: 03.00.00.0538 + ipmctl_edk2_repository: https://github.com/tianocore/edk2.git + ipmctl_edk2_tag: edk2-stable202511 + ipmctl_edk2_commit: 46548b1adac82211d8d11da12dd914f41e7aa775 + ipmctl_install_prefix: /usr/local + ipmctl_binary_path: /usr/local/bin/ipmctl + ipmctl_receipt_root: /var/lib/devs-guide/ipmctl + ipmctl_receipt_path: /var/lib/devs-guide/ipmctl/receipt.json + ipmctl_install_manifest_path: /var/lib/devs-guide/ipmctl/install_manifest.txt + ipmctl_patch_root: "{{ playbook_dir }}/../files/ipmctl/patches" + ipmctl_patches: + - id: edk2-stable202511-host-os-build + filename: 0001-edk2-stable202511-host-os-build.patch + sha256: ac6f0ea143c357c582135472defe8e936a63d7997221a29d4d0e4c349d7ac013 + repository: edk2 + target: MdePkg/Include/Base.h + preimage_sha256: fedaf9edaebc77a3e94649dc344fad8047cfe04b3ec09b2e3be4dcb008517c28 + postimage_sha256: 57fb0c2cf0c147c7f787faca9a0ad4f8fb1aa3c6b1702f1faecda35852a19804 + - id: ipmctl-disable-c-release-werror + filename: 0002-ipmctl-disable-c-release-werror.patch + sha256: d1928dc874219578abbc9eab5cc7a826ccf88457bd148f268aff367d134321b8 + repository: ipmctl + target: CMakeLists.txt + preimage_sha256: fb89ac2c0f78a2a0cbf898def22363fd87495d0e851d74688e7acf18db88ef8c + postimage_sha256: 17d0c9a012cae4ee2a2415e446a4cd44bff4e897cd7492438cd19d8c96e83f66 + - id: ipmctl-remove-pie-from-shared-linker-flags + filename: 0003-ipmctl-remove-pie-from-shared-linker-flags.patch + sha256: f926a6b07ad33b09f09032e6fd06a9229855d9d0501cfc7e67ecbb4c3c28a031 + repository: ipmctl + target: CMakeLists.txt + preimage_sha256: 17d0c9a012cae4ee2a2415e446a4cd44bff4e897cd7492438cd19d8c96e83f66 + postimage_sha256: f8e59840ef844f5631ccb1502a5cde79845f0779e267e13dd02bbb29efd80165 + ipmctl_patch_receipt: + - filename: 0001-edk2-stable202511-host-os-build.patch + sha256: ac6f0ea143c357c582135472defe8e936a63d7997221a29d4d0e4c349d7ac013 + - filename: 0002-ipmctl-disable-c-release-werror.patch + sha256: d1928dc874219578abbc9eab5cc7a826ccf88457bd148f268aff367d134321b8 + - filename: 0003-ipmctl-remove-pie-from-shared-linker-flags.patch + sha256: f926a6b07ad33b09f09032e6fd06a9229855d9d0501cfc7e67ecbb4c3c28a031 pre_tasks: - - name: Load reviewed ipmctl compatibility matrix - ansible.builtin.set_fact: - ipmctl_matrix: "{{ lookup('file', ipmctl_matrix_path) | from_json }}" - - - name: Select reviewed ipmctl profile - ansible.builtin.set_fact: - ipmctl_profile_matches: >- - {{ - ipmctl_matrix.profiles - | selectattr('feature', 'equalto', 'ipmctl') - | selectattr('id', 'equalto', ipmctl_profile) - | list - }} - - - name: Require one reviewed ipmctl profile - ansible.builtin.assert: - that: - - ipmctl_matrix.schema_version | int == 1 - - ipmctl_profile_matches | length == 1 - fail_msg: "The requested ipmctl source profile is not uniquely reviewed." - - - name: Normalize ipmctl policy - ansible.builtin.set_fact: - ipmctl_profile_policy: "{{ ipmctl_profile_matches[0] }}" - ipmctl_mode_effective: "{{ ipmctl_mode | lower }}" - ipmctl_build_type_effective: "{{ ipmctl_build_type | lower }}" - ipmctl_run_id: "{{ now(utc=true, fmt='%Y%m%dT%H%M%S%fZ') }}" - - - name: Resolve managed ipmctl paths - ansible.builtin.set_fact: - ipmctl_source_root: "/opt/src/ipmctl/{{ ipmctl_profile }}" - ipmctl_build_root: "/opt/build/ipmctl/{{ ipmctl_profile }}/{{ ipmctl_build_type_effective }}" - ipmctl_source_dir: "/opt/src/ipmctl/{{ ipmctl_profile }}/ipmctl" - ipmctl_edk2_source_dir: "/opt/src/ipmctl/{{ ipmctl_profile }}/edk2" - ipmctl_worktree_dir: "/opt/build/ipmctl/{{ ipmctl_profile }}/{{ ipmctl_build_type_effective }}/ipmctl" - ipmctl_edk2_worktree_dir: "/opt/build/ipmctl/{{ ipmctl_profile }}/{{ ipmctl_build_type_effective }}/edk2" - ipmctl_os_patch_script_path: "/opt/build/ipmctl/{{ ipmctl_profile }}/{{ ipmctl_build_type_effective }}/ipmctl/{{ ipmctl_profile_policy.os_patch_script }}" - ipmctl_os_patch_file_path: "/opt/build/ipmctl/{{ ipmctl_profile }}/{{ ipmctl_build_type_effective }}/ipmctl/{{ ipmctl_profile_policy.os_patch }}" - ipmctl_run_log_dir: "{{ ipmctl_log_root }}/{{ ipmctl_run_id }}" - - - name: Validate exact ipmctl source and mode policy - ansible.builtin.assert: - that: - - ipmctl_mode_effective in ['apply', 'validate', 'goal-plan', 'goal-apply'] - - ipmctl_profile_policy.repository_url == ipmctl_repository_url - - ipmctl_profile_policy.release == ipmctl_release - - ipmctl_profile_policy.commit == ipmctl_commit - - ipmctl_profile_policy.edk2_repository_url == ipmctl_edk2_repository_url - - ipmctl_profile_policy.edk2_release == ipmctl_edk2_release - - ipmctl_profile_policy.edk2_commit == ipmctl_edk2_commit - - ipmctl_profile_policy.binary_version is match('^[0-9]{2}[.][0-9]{2}[.][0-9]{2}[.][0-9]{4}$') - - ipmctl_profile_policy.os_patch_script == 'patch_OS.sh' - - ipmctl_profile_policy.os_patch == 'src/os/patches/0001-Ignore-STATIC_ASSERTs-and-NULL-define-for-os-and-ut-builds.patch' - - ipmctl_build_type_effective in ipmctl_profile_policy.allowed_build_types - - ipmctl_profile_policy.install_prefix == '/usr/local' - - ipmctl_commit is match('^[0-9a-f]{40}$') - - ipmctl_edk2_commit is match('^[0-9a-f]{40}$') - - ipmctl_facts_path == '/etc/ansible/debian/facts/ipmctl.yml' - - >- - ipmctl_mode_effective not in ['goal-plan', 'goal-apply'] - or - ( - ipmctl_goal_plan_result_path - is match('^/(?:[^/]+/)*devs-guide-ipmctl[.][A-Za-z0-9]+/goal-plan[.]result$') - and '..' not in ipmctl_goal_plan_result_path - ) - - >- - ipmctl_mode_effective != 'goal-apply' - or - ipmctl_goal_confirmation_authorized | bool - fail_msg: >- - ipmctl and edk2 URLs, tags, full commits, build type, and install - prefix must match the reviewed compatibility profile. goal-apply - additionally requires runner authorization after exact operator - confirmation. - - name: Read Debian release and architecture ansible.builtin.command: argv: "{{ item }}" loop: - [/usr/bin/dpkg, --print-architecture] - - [/usr/bin/sh, -c, ". /etc/os-release && printf '%s\\n' \"${ID}:${VERSION_ID}\""] + - [/usr/bin/sh, -c, ". /etc/os-release && printf '%s:%s\\n' \"${ID:-}\" \"${VERSION_ID:-}\""] register: ipmctl_platform_queries changed_when: false - - name: Require Debian 13 amd64 + - name: Validate fixed installer policy ansible.builtin.assert: that: + - ipmctl_mode == 'install' - ipmctl_platform_queries.results[0].stdout | trim == 'amd64' - ipmctl_platform_queries.results[1].stdout | trim == 'debian:13' - fail_msg: "The reviewed ipmctl source profile supports Debian 13 amd64 only." - - tasks: - - name: Create managed ipmctl evidence directories - ansible.builtin.file: - path: "{{ item }}" - state: directory - owner: root - group: root - mode: '0755' - loop: - - "{{ ipmctl_facts_path | dirname }}" - - "{{ ipmctl_transaction_root }}" - - "{{ ipmctl_log_root }}" - - "{{ ipmctl_run_log_dir }}" - - - name: Initialize previous managed ipmctl facts - ansible.builtin.set_fact: - ipmctl_previous_facts: {} - - - name: Inspect previous managed ipmctl facts - ansible.builtin.stat: - path: "{{ ipmctl_facts_path }}" - register: ipmctl_previous_fact_stat - - - name: Read previous managed ipmctl facts - ansible.builtin.slurp: - src: "{{ ipmctl_facts_path }}" - register: ipmctl_previous_fact_raw - when: ipmctl_previous_fact_stat.stat.exists + - ipmctl_build_user is match('^[a-z_][a-z0-9_-]*[$]?$') + - ipmctl_build_user != 'root' + - ipmctl_build_group is match('^[a-z_][a-z0-9_-]*[$]?$') + - ipmctl_build_home is match('^/[^\n\r]+$') + - ipmctl_install_prefix == '/usr/local' + - ipmctl_patches | length == 3 + fail_msg: >- + The reviewed installer supports only Debian 13 amd64, one pinned + Release tuple, /usr/local, and a non-root build user. - - name: Decode previous managed ipmctl facts + - name: Resolve per-run source paths ansible.builtin.set_fact: - ipmctl_previous_facts: "{{ ipmctl_previous_fact_raw.content | b64decode | from_yaml }}" - when: ipmctl_previous_fact_stat.stat.exists + ipmctl_run_id: "{{ lookup('pipe', '/usr/bin/date -u +%Y%m%dT%H%M%S%N') }}" + ipmctl_cache_root: "{{ ipmctl_build_home }}/.cache/devs-guide/ipmctl" - - name: Inspect installed ipmctl binary - ansible.builtin.stat: - path: /usr/local/bin/ipmctl - follow: false - register: ipmctl_installed_binary_stat - - - name: Determine whether the reviewed ipmctl install is current + - name: Resolve mutable worktree paths ansible.builtin.set_fact: - ipmctl_install_is_current: >- - {{ - ipmctl_installed_binary_stat.stat.exists - and ipmctl_previous_fact_stat.stat.exists - and (ipmctl_previous_facts.ipmctl.source.profile | default('') == ipmctl_profile) - and (ipmctl_previous_facts.ipmctl.source.commit | default('') == ipmctl_commit) - and (ipmctl_previous_facts.ipmctl.source.edk2_commit | default('') == ipmctl_edk2_commit) - and - ( - ipmctl_previous_facts.ipmctl.source.binary_version - | default('') - == - ipmctl_profile_policy.binary_version - ) - and - ( - ipmctl_previous_facts.ipmctl.source.os_patch_script - | default('') - == - ipmctl_profile_policy.os_patch_script - ) - and - ( - ipmctl_previous_facts.ipmctl.source.os_patch - | default('') - == - ipmctl_profile_policy.os_patch - ) - and (ipmctl_previous_facts.ipmctl.source.build_type | default('') == ipmctl_build_type_effective) - }} + ipmctl_run_root: "{{ ipmctl_cache_root }}/runs/{{ ipmctl_run_id }}" + ipmctl_source_dir: "{{ ipmctl_cache_root }}/runs/{{ ipmctl_run_id }}/ipmctl" + ipmctl_edk2_source_dir: "{{ ipmctl_cache_root }}/runs/{{ ipmctl_run_id }}/edk2" + ipmctl_build_dir: "{{ ipmctl_cache_root }}/runs/{{ ipmctl_run_id }}/build" - - name: Inspect Debian ipmctl package ownership - ansible.builtin.command: - argv: - - /usr/bin/dpkg-query - - -W - - "-f=${Status}" - - ipmctl - register: ipmctl_debian_package - changed_when: false - failed_when: false - - - name: Inspect configured APT candidate for ipmctl - ansible.builtin.command: - argv: - - /usr/bin/apt-cache - - policy - - ipmctl - register: ipmctl_apt_policy - changed_when: false - failed_when: false - - - name: Refuse Debian-packaged or foreign-repository ipmctl migration - ansible.builtin.assert: - that: - - ipmctl_debian_package.rc | int != 0 - - >- - ( - ipmctl_apt_policy.stdout - | regex_findall('(?m)^\\s*Candidate:\\s*(\\S+)') - | first - | default('(none)') - ) == '(none)' - fail_msg: >- - A Debian ipmctl package is installed or an ipmctl package candidate - is exposed by configured repositories. Remove the foreign - Bookworm/Sid package and repository through a separately reviewed - package migration before using this source-managed runner. - - - name: Refuse unmanaged local ipmctl replacement - ansible.builtin.assert: - that: - - >- - not ipmctl_installed_binary_stat.stat.exists - or - ( - ipmctl_previous_fact_stat.stat.exists - and - ipmctl_previous_facts.ipmctl.source.profile | default('') == ipmctl_profile - and - ipmctl_previous_facts.ipmctl.source.commit | default('') == ipmctl_commit - ) - fail_msg: >- - /usr/local/bin/ipmctl exists without matching managed provenance. - It will not be overwritten automatically. - when: ipmctl_mode_effective == 'apply' - - - name: Require staged source trees for apply - ansible.builtin.stat: - path: "{{ item }}" - loop: - - "{{ ipmctl_staged_source_path }}" - - "{{ ipmctl_staged_edk2_path }}" - register: ipmctl_staged_source_stats - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Validate pre-sudo staged source trees - ansible.builtin.assert: - that: - - ipmctl_staged_source_path | length > 0 - - ipmctl_staged_edk2_path | length > 0 - - ipmctl_staged_source_stats.results[0].stat.isdir | default(false) - - ipmctl_staged_source_stats.results[1].stat.isdir | default(false) - fail_msg: "apply requires exact ipmctl and edk2 source staged before sudo." - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Reset only the selected mutable ipmctl build workspace - ansible.builtin.file: - path: "{{ ipmctl_build_root }}" - state: absent - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Create managed source and build parents - ansible.builtin.file: - path: "{{ item }}" - state: directory - owner: root - group: root - mode: '0755' - loop: - - "{{ ipmctl_source_root }}" - - "{{ ipmctl_build_root }}" - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Copy pristine pre-sudo source trees - ansible.builtin.command: - argv: - - /usr/bin/cp - - -a - - --no-preserve=ownership - - "{{ item.source }}" - - "{{ item.destination }}" - creates: "{{ item.destination }}/.git" - loop: - - source: "{{ ipmctl_staged_source_path }}" - destination: "{{ ipmctl_source_dir }}" - - source: "{{ ipmctl_staged_edk2_path }}" - destination: "{{ ipmctl_edk2_source_dir }}" - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Verify pristine source identities - ansible.builtin.command: - argv: - - /usr/bin/git - - -C - - "{{ item.path }}" - - rev-parse - - HEAD - loop: - - path: "{{ ipmctl_source_dir }}" - commit: "{{ ipmctl_commit }}" - - path: "{{ ipmctl_edk2_source_dir }}" - commit: "{{ ipmctl_edk2_commit }}" - register: ipmctl_source_heads - changed_when: false - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Require exact pristine source identities - ansible.builtin.assert: - that: - - item.stdout | trim == item.item.commit - fail_msg: "A managed ipmctl source tree is at the wrong commit." - loop: "{{ ipmctl_source_heads.results | default([]) }}" - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Copy pristine sources into mutable build workspace - ansible.builtin.command: - argv: - - /usr/bin/cp - - -a - - --no-preserve=ownership - - "{{ item.source }}" - - "{{ item.destination }}" - creates: "{{ item.destination }}/.git" - loop: - - source: "{{ ipmctl_source_dir }}" - destination: "{{ ipmctl_worktree_dir }}" - - source: "{{ ipmctl_edk2_source_dir }}" - destination: "{{ ipmctl_edk2_worktree_dir }}" - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Populate reviewed edk2 components in mutable ipmctl worktree - ansible.builtin.command: - argv: - - /usr/bin/bash - - "{{ ipmctl_worktree_dir }}/updateedk.sh" - chdir: "{{ ipmctl_worktree_dir }}" - creates: "{{ ipmctl_worktree_dir }}/MdePkg" - register: ipmctl_updateedk_result - changed_when: ipmctl_updateedk_result.rc == 0 - failed_when: false - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Inspect pinned upstream Linux patch procedure + tasks: + - name: Inspect managed receipt and installed binary ansible.builtin.stat: path: "{{ item }}" + follow: false + checksum_algorithm: sha256 loop: - - "{{ ipmctl_os_patch_script_path }}" - - "{{ ipmctl_os_patch_file_path }}" - register: ipmctl_os_patch_stats - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - ipmctl_updateedk_result.rc | default(1) | int == 0 - - - name: Inventory pinned upstream Linux patches - ansible.builtin.command: - argv: - - /usr/bin/find - - "{{ ipmctl_worktree_dir }}/src/os/patches" - - -maxdepth - - "1" - - -type - - f - - -name - - "*.patch" - - -printf - - "%f\n" - register: ipmctl_os_patch_inventory - changed_when: false - failed_when: false - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - ipmctl_updateedk_result.rc | default(1) | int == 0 - - - name: Inspect pinned upstream Linux patch targets - ansible.builtin.command: - argv: - - /usr/bin/git - - -C - - "{{ ipmctl_worktree_dir }}" - - apply - - --numstat - - "{{ ipmctl_os_patch_file_path }}" - register: ipmctl_os_patch_plan - changed_when: false - failed_when: false - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - ipmctl_updateedk_result.rc | default(1) | int == 0 + - "{{ ipmctl_receipt_path }}" + - "{{ ipmctl_binary_path }}" + register: ipmctl_initial_stats - - name: Verify pinned upstream Linux patch applicability - ansible.builtin.command: - argv: - - /usr/bin/git - - -C - - "{{ ipmctl_worktree_dir }}" - - apply - - --check - - --ignore-space-change - - --ignore-whitespace - - --whitespace=nowarn - - "{{ ipmctl_os_patch_file_path }}" - register: ipmctl_os_patch_preflight - changed_when: false - failed_when: false - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - ipmctl_updateedk_result.rc | default(1) | int == 0 - - - name: Require exact pinned upstream Linux patch contract + - name: Refuse an unmanaged local ipmctl binary ansible.builtin.assert: that: - - ipmctl_os_patch_stats.results[0].stat.exists | default(false) - - ipmctl_os_patch_stats.results[1].stat.exists | default(false) - - ipmctl_os_patch_inventory.rc | default(1) | int == 0 - >- - (ipmctl_os_patch_inventory.stdout_lines | default([])) - == - [ipmctl_profile_policy.os_patch | basename] - - ipmctl_os_patch_plan.rc | default(1) | int == 0 - - ipmctl_os_patch_preflight.rc | default(1) | int == 0 - - ipmctl_os_patch_plan.stdout_lines | default([]) | length == 1 - - >- - ( - ( - ipmctl_os_patch_plan.stdout_lines - | default(['']) - | first - ).split('\t') - | last - ) - == - 'MdePkg/Include/Base.h' + not (ipmctl_initial_stats.results[1].stat.exists | default(false)) + or (ipmctl_initial_stats.results[0].stat.isreg | default(false)) fail_msg: >- - The pinned upstream Linux patch procedure is missing, changed, or - targets files outside the reviewed EDK2 Base.h compatibility change. - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - ipmctl_updateedk_result.rc | default(1) | int == 0 - - - name: Apply pinned upstream Linux compatibility patch - ansible.builtin.command: - argv: - - /usr/bin/bash - - "{{ ipmctl_os_patch_script_path }}" - chdir: "{{ ipmctl_worktree_dir }}" - register: ipmctl_os_patch_result - changed_when: ipmctl_os_patch_result.rc == 0 - failed_when: false - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - ipmctl_os_patch_preflight.rc | default(1) | int == 0 - - - name: Verify pinned upstream Linux compatibility patch application - ansible.builtin.command: - argv: - - /usr/bin/git - - -C - - "{{ ipmctl_worktree_dir }}" - - apply - - --reverse - - --check - - "{{ ipmctl_os_patch_file_path }}" - register: ipmctl_os_patch_verify - changed_when: false - failed_when: false - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - ipmctl_os_patch_result.rc | default(1) | int == 0 - - - name: Configure reviewed ipmctl build - ansible.builtin.command: - argv: - - /usr/bin/cmake - - -S - - "{{ ipmctl_worktree_dir }}" - - -B - - "{{ ipmctl_worktree_dir }}/build" - - "-DCMAKE_BUILD_TYPE={{ 'Release' if ipmctl_build_type_effective == 'release' else 'Debug' }}" - - "-DBUILDNUM={{ ipmctl_profile_policy.binary_version }}" - - -DCMAKE_INSTALL_PREFIX=/usr/local - creates: "{{ ipmctl_worktree_dir }}/build/CMakeCache.txt" - register: ipmctl_configure_result - changed_when: ipmctl_configure_result.rc == 0 - failed_when: false - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - ipmctl_os_patch_verify.rc | default(1) | int == 0 + {{ ipmctl_binary_path }} exists without the devs-guide receipt. + Refusing to overwrite an unmanaged installation. - - name: Build reviewed ipmctl source - ansible.builtin.command: - argv: - - /usr/bin/cmake - - --build - - "{{ ipmctl_worktree_dir }}/build" - - -j - - "{{ ansible_processor_vcpus | default(1) | string }}" - register: ipmctl_build_result - changed_when: ipmctl_build_result.rc == 0 - failed_when: false - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - ipmctl_configure_result.rc | default(1) | int == 0 - - - name: Record source-build output before enforcement - ansible.builtin.copy: - dest: "{{ ipmctl_run_log_dir }}/build.txt" - owner: root - group: root - mode: '0644' - content: | - updateedk rc={{ ipmctl_updateedk_result.rc | default('not-run') }} - {{ ipmctl_updateedk_result.stdout | default('') }} - {{ ipmctl_updateedk_result.stderr | default('') }} - patch inventory rc={{ ipmctl_os_patch_inventory.rc | default('not-run') }} - {{ ipmctl_os_patch_inventory.stdout | default('') }} - {{ ipmctl_os_patch_inventory.stderr | default('') }} - patch plan rc={{ ipmctl_os_patch_plan.rc | default('not-run') }} - {{ ipmctl_os_patch_plan.stdout | default('') }} - {{ ipmctl_os_patch_plan.stderr | default('') }} - patch preflight rc={{ ipmctl_os_patch_preflight.rc | default('not-run') }} - {{ ipmctl_os_patch_preflight.stdout | default('') }} - {{ ipmctl_os_patch_preflight.stderr | default('') }} - patch apply rc={{ ipmctl_os_patch_result.rc | default('not-run') }} - {{ ipmctl_os_patch_result.stdout | default('') }} - {{ ipmctl_os_patch_result.stderr | default('') }} - patch verify rc={{ ipmctl_os_patch_verify.rc | default('not-run') }} - {{ ipmctl_os_patch_verify.stdout | default('') }} - {{ ipmctl_os_patch_verify.stderr | default('') }} - configure rc={{ ipmctl_configure_result.rc | default('not-run') }} - {{ ipmctl_configure_result.stdout | default('') }} - {{ ipmctl_configure_result.stderr | default('') }} - build rc={{ ipmctl_build_result.rc | default('not-run') }} - {{ ipmctl_build_result.stdout | default('') }} - {{ ipmctl_build_result.stderr | default('') }} - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Require successful reviewed source build - ansible.builtin.assert: - that: - - ipmctl_updateedk_result.rc | default(1) | int == 0 - - ipmctl_os_patch_inventory.rc | default(1) | int == 0 - - ipmctl_os_patch_plan.rc | default(1) | int == 0 - - ipmctl_os_patch_preflight.rc | default(1) | int == 0 - - ipmctl_os_patch_result.rc | default(1) | int == 0 - - ipmctl_os_patch_verify.rc | default(1) | int == 0 - - ipmctl_configure_result.rc | default(1) | int == 0 - - ipmctl_build_result.rc | default(1) | int == 0 - fail_msg: >- - The reviewed {{ ipmctl_build_type_effective }} build failed. Review - {{ ipmctl_run_log_dir }}/build.txt. Release never falls back to Debug - automatically. - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Install reviewed ipmctl build under /usr/local - ansible.builtin.command: - argv: - - /usr/bin/cmake - - --install - - "{{ ipmctl_worktree_dir }}/build" - register: ipmctl_install_result - changed_when: true - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Refresh dynamic linker cache - ansible.builtin.command: - argv: - - /usr/sbin/ldconfig - changed_when: true - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Preserve CMake install manifest - ansible.builtin.copy: - src: "{{ ipmctl_worktree_dir }}/build/install_manifest.txt" - dest: "{{ ipmctl_transaction_root }}/{{ ipmctl_run_id }}.install-manifest.txt" - remote_src: true - owner: root - group: root - mode: '0644' - when: - - ipmctl_mode_effective == 'apply' - - not ipmctl_install_is_current | bool - - - name: Collect privileged read-only ipmctl inventory + - name: Decode the optional managed receipt safely ansible.builtin.command: argv: - /usr/bin/python3 - - "{{ ipmctl_inventory_helper_path }}" - - --log-dir - - "{{ ipmctl_run_log_dir }}/before" - register: ipmctl_inventory_raw + - -c + - |- + import json + import sys + p = sys.argv[1] + try: + with open(p, encoding="utf-8") as receipt: + print(json.dumps(json.load(receipt))) + except Exception: + print("{}") + - "{{ ipmctl_receipt_path }}" + register: ipmctl_receipt_query changed_when: false + when: ipmctl_initial_stats.results[0].stat.isreg | default(false) - - name: Decode privileged ipmctl inventory + - name: Normalize the previous receipt ansible.builtin.set_fact: - ipmctl_inventory: "{{ ipmctl_inventory_raw.stdout | from_json }}" - - - name: Require installed reviewed ipmctl and readable inventory - ansible.builtin.assert: - that: - - ipmctl_inventory.schema_version | int == 1 - - ipmctl_inventory.binary.available | bool - - ipmctl_profile_policy.binary_version in ipmctl_inventory.binary.version - - ipmctl_inventory.readiness.inventory_ready | bool - fail_msg: >- - The reviewed ipmctl binary is unavailable, has the wrong version, or - cannot produce a complete privileged inventory. + ipmctl_previous_receipt: "{{ ipmctl_receipt_query.stdout | default('{}') | from_json }}" - - name: Require existing managed provenance outside apply - ansible.builtin.assert: - that: - - ipmctl_previous_fact_stat.stat.exists - - ipmctl_previous_facts.ipmctl.schema_version | default(0) | int == 1 - - ipmctl_previous_facts.ipmctl.source.profile | default('') == ipmctl_profile - - ipmctl_previous_facts.ipmctl.source.commit | default('') == ipmctl_commit - - ipmctl_previous_facts.ipmctl.source.edk2_commit | default('') == ipmctl_edk2_commit - fail_msg: "Run the reviewed ipmctl apply mode before validation or goal operations." - when: ipmctl_mode_effective != 'apply' - - - name: Normalize requested PMem goal - ansible.builtin.set_fact: - ipmctl_requested_mode: "{{ ipmctl_goal }}" - ipmctl_goal_properties: >- - {{ - ['MemoryMode=100'] - if ipmctl_goal == 'memory-mode' - else - ( - ['MemoryMode=0', 'PersistentMemoryType=AppDirect'] - if ipmctl_goal == 'app-direct' - else - ['MemoryMode=0', 'PersistentMemoryType=AppDirectNotInterleaved'] - ) - }} - ipmctl_requested_sockets: >- - {{ - ipmctl_inventory.hardware.socket_ids - if ipmctl_socket_target == 'all' - else ipmctl_socket_target.split(',') | map('int') | list - }} - when: ipmctl_mode_effective in ['goal-plan', 'goal-apply'] + - name: Read current binary version and linkage + ansible.builtin.command: + argv: "{{ item }}" + loop: + - ["{{ ipmctl_binary_path }}", version] + - [/usr/bin/ldd, "{{ ipmctl_binary_path }}"] + register: ipmctl_current_software + changed_when: false + failed_when: false + when: ipmctl_initial_stats.results[1].stat.isreg | default(false) - - name: Build exact PMem goal command + - name: Determine whether installation is current ansible.builtin.set_fact: - ipmctl_goal_argv: >- + ipmctl_install_is_current: >- {{ - ['ipmctl', 'create', '-force', '-goal'] - + + (ipmctl_initial_stats.results[0].stat.isreg | default(false)) + and (ipmctl_initial_stats.results[1].stat.isreg | default(false)) + and (ipmctl_previous_receipt.schema_version | default(0) | int == 1) + and (ipmctl_previous_receipt.platform.debian | default('') == '13') + and (ipmctl_previous_receipt.platform.architecture | default('') == 'amd64') + and (ipmctl_previous_receipt.ipmctl.tag | default('') == ipmctl_tag) + and (ipmctl_previous_receipt.ipmctl.commit | default('') == ipmctl_commit) + and (ipmctl_previous_receipt.ipmctl.version | default('') == ipmctl_expected_version) + and (ipmctl_previous_receipt.edk2.tag | default('') == ipmctl_edk2_tag) + and (ipmctl_previous_receipt.edk2.commit | default('') == ipmctl_edk2_commit) + and (ipmctl_previous_receipt.patches | default([]) == ipmctl_patch_receipt) + and (ipmctl_previous_receipt.install.prefix | default('') == ipmctl_install_prefix) + and (ipmctl_previous_receipt.install.binary | default('') == ipmctl_binary_path) + and ( - [] - if ipmctl_socket_target == 'all' - else ['-socket', ipmctl_socket_target] + ipmctl_initial_stats.results[1].stat.checksum | default('') + == ipmctl_previous_receipt.install.binary_sha256 | default('') ) - + ipmctl_goal_properties - }} - ipmctl_goal_is_noop: >- - {{ - ipmctl_inventory.readiness.settled | bool - and - (ipmctl_requested_sockets | sort == ipmctl_inventory.hardware.socket_ids | sort) + and (ipmctl_current_software.results[0].rc | default(1) | int == 0) and ( - (ipmctl_goal == 'memory-mode' and ipmctl_inventory.memory_resources.current_mode == 'memory-mode') - or - (ipmctl_goal == 'app-direct' and ipmctl_inventory.memory_resources.current_mode == 'app-direct') - or ( - ipmctl_goal == 'app-direct-not-interleaved' - and - ipmctl_inventory.memory_resources.current_mode == 'app-direct-not-interleaved' + ipmctl_current_software.results[0].stdout + | default('') + | regex_search('[0-9]{2}\\.[0-9]{2}\\.[0-9]{2}\\.[0-9]{4}') + | default('') ) + == ipmctl_expected_version ) + and (ipmctl_current_software.results[1].rc | default(1) | int == 0) + and ('not found' not in (ipmctl_current_software.results[1].stdout | default(''))) }} - when: ipmctl_mode_effective in ['goal-plan', 'goal-apply'] - - - name: Fail closed on unsafe PMem goal prerequisites - ansible.builtin.assert: - that: - - ipmctl_inventory.hardware.present | bool - - ipmctl_inventory.hardware.topology_verified | bool - - ipmctl_inventory.hardware.manageable | bool - - ipmctl_inventory.hardware.healthy | bool - - ipmctl_inventory.hardware.security_safe_for_goal | bool - - ipmctl_inventory.readiness.goal_change_supported | bool - - ipmctl_inventory.readiness.settled | bool - - ipmctl_inventory.ndctl.namespace_count | int == 0 - - ipmctl_requested_sockets | length > 0 - - ipmctl_requested_sockets | difference(ipmctl_inventory.hardware.socket_ids) | length == 0 - - ipmctl_inventory.hardware.socket_ids | difference(ipmctl_requested_sockets) | length == 0 - - ipmctl_goal != 'memory-mode' or ipmctl_inventory.capabilities.memory_mode_supported | bool - - ipmctl_goal == 'memory-mode' or ipmctl_inventory.capabilities.app_direct_supported | bool - fail_msg: >- - PMem goals require healthy, manageable, unlocked modules, supported - platform modes, complete socket targets, no namespaces, and no - pending goal. The runner never deletes namespaces or repairs PCD. - when: - - ipmctl_mode_effective in ['goal-plan', 'goal-apply'] - - not ipmctl_goal_is_noop | bool - - - name: Display complete read-only PMem goal plan - ansible.builtin.debug: - msg: - - "Current mode: {{ ipmctl_inventory.memory_resources.current_mode }}" - - "Requested mode: {{ ipmctl_requested_mode }}" - - "DIMMs: {{ ipmctl_inventory.hardware.dimm_ids }}" - - "Detected sockets: {{ ipmctl_inventory.hardware.socket_ids }}" - - "Target sockets: {{ ipmctl_requested_sockets }}" - - "Manageable/healthy/security-safe: {{ ipmctl_inventory.hardware.manageable }}/{{ ipmctl_inventory.hardware.healthy }}/{{ ipmctl_inventory.hardware.security_safe_for_goal }}" - - "Platform configuration supported: {{ ipmctl_inventory.capabilities.platform_config_supported }}" - - "Supported modes: {{ ipmctl_inventory.capabilities.modes_supported }}" - - "Volatile PMem/App Direct/cache DDR bytes: {{ ipmctl_inventory.memory_resources.volatile_pmem_bytes }}/{{ ipmctl_inventory.memory_resources.app_direct_pmem_bytes }}/{{ ipmctl_inventory.memory_resources.cache_ddr_bytes }}" - - "Namespaces present: {{ ipmctl_inventory.ndctl.namespace_count }}" - - "Pending goal: {{ ipmctl_inventory.pending_goal.present }}" - - "Topology evidence: {{ ipmctl_inventory.commands.topology.log }}" - - "No-op: {{ ipmctl_goal_is_noop }}" - - "Proposed argv: {{ ipmctl_goal_argv }}" - - "A non-no-op goal can destroy App Direct data and requires reboot." - when: ipmctl_mode_effective in ['goal-plan', 'goal-apply'] - - - name: Return machine-readable PMem goal-plan disposition - ansible.builtin.copy: - dest: "{{ ipmctl_goal_plan_result_path }}" - owner: root - group: root - mode: '0644' - content: "no_op={{ ipmctl_goal_is_noop | bool | to_json }}\n" - when: ipmctl_mode_effective == 'goal-plan' - - - name: Create the explicitly confirmed PMem goal - ansible.builtin.command: - argv: "{{ ipmctl_goal_argv }}" - register: ipmctl_goal_result - changed_when: ipmctl_goal_result.rc == 0 - failed_when: false - when: - - ipmctl_mode_effective == 'goal-apply' - - not ipmctl_goal_is_noop | bool - - - name: Record PMem goal command result - ansible.builtin.copy: - dest: "{{ ipmctl_run_log_dir }}/goal-apply.txt" - owner: root - group: root - mode: '0600' - content: | - argv={{ ipmctl_goal_argv | to_json }} - rc={{ ipmctl_goal_result.rc | default(0) }} - stdout: - {{ ipmctl_goal_result.stdout | default('no-op') }} - stderr: - {{ ipmctl_goal_result.stderr | default('') }} - when: ipmctl_mode_effective == 'goal-apply' - - - name: Persist immutable PMem goal transaction record - ansible.builtin.copy: - dest: "{{ ipmctl_transaction_root }}/{{ ipmctl_run_id }}.goal.yml" - owner: root - group: root - mode: '0600' - content: | - schema_version: 1 - generated_at: "{{ now(utc=true, fmt='%Y-%m-%dT%H:%M:%SZ') }}" - requested_goal: {{ ipmctl_goal | to_json }} - socket_target: {{ ipmctl_socket_target | to_json }} - no_op: {{ ipmctl_goal_is_noop | bool | to_json }} - argv: {{ ipmctl_goal_argv | to_json }} - command_rc: {{ ipmctl_goal_result.rc | default(0) | int }} - reboot_required: {{ (not (ipmctl_goal_is_noop | bool) and (ipmctl_goal_result.rc | default(1) | int == 0)) | to_json }} - when: ipmctl_mode_effective == 'goal-apply' - - - name: Collect post-goal privileged inventory - ansible.builtin.command: - argv: - - /usr/bin/python3 - - "{{ ipmctl_inventory_helper_path }}" - - --log-dir - - "{{ ipmctl_run_log_dir }}/after" - register: ipmctl_post_goal_inventory_raw - changed_when: false - when: ipmctl_mode_effective == 'goal-apply' - - - name: Select final ipmctl inventory - ansible.builtin.set_fact: - ipmctl_final_inventory: >- - {{ - (ipmctl_post_goal_inventory_raw.stdout | from_json) - if ipmctl_mode_effective == 'goal-apply' - else ipmctl_inventory - }} - - - name: Persist schema-version-1 ipmctl facts - ansible.builtin.copy: - dest: "{{ ipmctl_facts_path }}" - owner: root - group: root - mode: '0644' - content: | - ipmctl: - schema_version: 1 - generated_at: "{{ now(utc=true, fmt='%Y-%m-%dT%H:%M:%SZ') }}" - mode: {{ ipmctl_mode_effective | to_json }} - source: - profile: {{ ipmctl_profile | to_json }} - repository_url: {{ ipmctl_repository_url | to_json }} - release: {{ ipmctl_release | to_json }} - commit: {{ ipmctl_commit | to_json }} - edk2_repository_url: {{ ipmctl_edk2_repository_url | to_json }} - edk2_release: {{ ipmctl_edk2_release | to_json }} - edk2_commit: {{ ipmctl_edk2_commit | to_json }} - binary_version: {{ ipmctl_profile_policy.binary_version | to_json }} - os_patch_script: {{ ipmctl_profile_policy.os_patch_script | to_json }} - os_patch: {{ ipmctl_profile_policy.os_patch | to_json }} - build_type: {{ ipmctl_build_type_effective | to_json }} - install_prefix: "/usr/local" - inventory: {{ ipmctl_final_inventory | to_json }} - goal: - requested: {{ (ipmctl_goal if ipmctl_mode_effective == 'goal-apply' else '') | to_json }} - socket_target: {{ (ipmctl_socket_target if ipmctl_mode_effective == 'goal-apply' else '') | to_json }} - command_rc: {{ ipmctl_goal_result.rc | default(0) | int }} - no_op: {{ ipmctl_goal_is_noop | default(false) | bool | to_json }} - reboot_required: {{ (ipmctl_mode_effective == 'goal-apply' and not (ipmctl_goal_is_noop | default(false) | bool) and (ipmctl_goal_result.rc | default(1) | int == 0)) | to_json }} - evidence: - run_log: {{ ipmctl_run_log_dir | to_json }} - safety: - namespace_deleted: false - pcd_deleted: false - firmware_changed: false - security_changed: false - reboot_performed: false - readiness: - tool_ready: {{ ipmctl_final_inventory.readiness.tool_ready | bool | to_json }} - inventory_ready: {{ ipmctl_final_inventory.readiness.inventory_ready | bool | to_json }} - settled: {{ ipmctl_final_inventory.readiness.settled | bool | to_json }} - memory_mode_verified: {{ ipmctl_final_inventory.memory_resources.memory_mode_verified | bool | to_json }} - when: ipmctl_mode_effective != 'goal-plan' - - - name: Update stable latest ipmctl log link - ansible.builtin.file: - src: "{{ ipmctl_run_log_dir }}" - dest: "{{ ipmctl_log_root }}/latest" - state: link - force: true - when: ipmctl_mode_effective != 'goal-plan' - - - name: Enforce PMem goal command success after evidence persistence - ansible.builtin.assert: - that: - - ipmctl_goal_is_noop | bool or ipmctl_goal_result.rc | default(1) | int == 0 - - ipmctl_goal_is_noop | bool or ipmctl_final_inventory.pending_goal.present | bool - fail_msg: >- - The PMem goal was not accepted or no pending goal is visible. Review - {{ ipmctl_run_log_dir }}. Do not retry destructively without review. - when: ipmctl_mode_effective == 'goal-apply' - - name: Report ipmctl checkpoint + - name: Report current installation ansible.builtin.debug: - msg: - - "ipmctl version: {{ ipmctl_final_inventory.binary.version }}" - - "PMem sockets/DIMMs: {{ ipmctl_final_inventory.hardware.socket_ids }}/{{ ipmctl_final_inventory.hardware.dimm_ids | length }}" - - "Current mode: {{ ipmctl_final_inventory.memory_resources.current_mode }}" - - "Pending goal: {{ ipmctl_final_inventory.pending_goal.present }}" - - "Managed facts: {{ ipmctl_facts_path }}" - when: ipmctl_mode_effective != 'goal-plan' + msg: >- + Matching receipt, binary checksum, version, and linkage found; + source fetch, compilation, and installation are skipped. + when: ipmctl_install_is_current | bool + + - name: Build and install pinned ipmctl + when: not ipmctl_install_is_current | bool + block: + - name: Create fresh non-root build workspace + ansible.builtin.file: + path: "{{ ipmctl_run_root }}" + state: directory + mode: "0750" + + - name: Initialize exact source repositories + ansible.builtin.command: + argv: [/usr/bin/git, init, "{{ item.path }}"] + loop: + - { path: "{{ ipmctl_source_dir }}" } + - { path: "{{ ipmctl_edk2_source_dir }}" } + environment: + HOME: "{{ ipmctl_build_home }}" + + - name: Add credential-free HTTPS origins + ansible.builtin.command: + argv: [/usr/bin/git, -C, "{{ item.path }}", remote, add, origin, "{{ item.repository }}"] + loop: + - { path: "{{ ipmctl_source_dir }}", repository: "{{ ipmctl_repository }}" } + - { path: "{{ ipmctl_edk2_source_dir }}", repository: "{{ ipmctl_edk2_repository }}" } + environment: + HOME: "{{ ipmctl_build_home }}" + + - name: Fetch only reviewed source tags + ansible.builtin.command: + argv: + - /usr/bin/git + - -C + - "{{ item.path }}" + - fetch + - --depth=1 + - origin + - "refs/tags/{{ item.tag }}:refs/tags/{{ item.tag }}" + loop: + - { path: "{{ ipmctl_source_dir }}", tag: "{{ ipmctl_tag }}" } + - { path: "{{ ipmctl_edk2_source_dir }}", tag: "{{ ipmctl_edk2_tag }}" } + environment: + HOME: "{{ ipmctl_build_home }}" + + - name: Check out reviewed commits detached + ansible.builtin.command: + argv: [/usr/bin/git, -C, "{{ item.path }}", checkout, --detach, "{{ item.commit }}"] + loop: + - { path: "{{ ipmctl_source_dir }}", commit: "{{ ipmctl_commit }}" } + - { path: "{{ ipmctl_edk2_source_dir }}", commit: "{{ ipmctl_edk2_commit }}" } + environment: + HOME: "{{ ipmctl_build_home }}" + + - name: Read checked-out and tag source identities + ansible.builtin.command: + argv: [/usr/bin/git, -C, "{{ item.path }}", rev-parse, "{{ item.revision }}"] + loop: + - { path: "{{ ipmctl_source_dir }}", revision: HEAD, expected: "{{ ipmctl_commit }}" } + - { path: "{{ ipmctl_source_dir }}", revision: "refs/tags/{{ ipmctl_tag }}^{commit}", expected: "{{ ipmctl_commit }}" } + - { path: "{{ ipmctl_edk2_source_dir }}", revision: HEAD, expected: "{{ ipmctl_edk2_commit }}" } + - { path: "{{ ipmctl_edk2_source_dir }}", revision: "refs/tags/{{ ipmctl_edk2_tag }}^{commit}", expected: "{{ ipmctl_edk2_commit }}" } + register: ipmctl_source_identity + changed_when: false + environment: + HOME: "{{ ipmctl_build_home }}" + + - name: Require exact source identities + ansible.builtin.assert: + that: + - item.stdout | trim == item.item.expected + fail_msg: "Reviewed source tag or commit identity did not match." + loop: "{{ ipmctl_source_identity.results }}" + + - name: Preserve EDK2 CRLF source as a binary Git diff + ansible.builtin.copy: + dest: "{{ ipmctl_edk2_source_dir }}/.git/info/attributes" + content: "MdePkg/Include/Base.h binary\n" + mode: "0600" + + - name: Apply finite reviewed compatibility pack + ansible.builtin.include_tasks: "../files/ipmctl/apply-patch.yml" + loop: "{{ ipmctl_patches }}" + loop_control: + loop_var: ipmctl_patch + label: "{{ ipmctl_patch.id }}" + + - name: Inspect EDK2 link destinations + ansible.builtin.stat: + path: "{{ ipmctl_source_dir }}/{{ item }}" + follow: false + loop: [BaseTools, MdeModulePkg, MdePkg, ShellPkg] + register: ipmctl_edk2_link_targets + + - name: Require fresh EDK2 link destinations + ansible.builtin.assert: + that: + - not (item.stat.exists | default(false)) + fail_msg: "Refusing to reuse an existing EDK2 component path." + loop: "{{ ipmctl_edk2_link_targets.results }}" + + - name: Link reviewed EDK2 components explicitly + ansible.builtin.file: + src: "{{ ipmctl_edk2_source_dir }}/{{ item }}" + dest: "{{ ipmctl_source_dir }}/{{ item }}" + state: link + force: false + loop: [BaseTools, MdeModulePkg, MdePkg, ShellPkg] + + - name: Configure reviewed Release build + ansible.builtin.command: + argv: + - /usr/bin/cmake + - -S + - "{{ ipmctl_source_dir }}" + - -B + - "{{ ipmctl_build_dir }}" + - -DRELEASE=ON + - -DCMAKE_BUILD_TYPE=Release + - "-DBUILDNUM={{ ipmctl_expected_version }}" + - "-DCMAKE_INSTALL_PREFIX={{ ipmctl_install_prefix }}" + environment: + HOME: "{{ ipmctl_build_home }}" + + - name: Compile reviewed Release build + ansible.builtin.command: + argv: [/usr/bin/cmake, --build, "{{ ipmctl_build_dir }}", --parallel, "2"] + environment: + HOME: "{{ ipmctl_build_home }}" + + - name: Install reviewed Release build + ansible.builtin.command: + argv: [/usr/bin/cmake, --install, "{{ ipmctl_build_dir }}"] + become: true + + - name: Refresh runtime linker cache + ansible.builtin.command: + argv: [/sbin/ldconfig] + become: true + changed_when: true + + - name: Read installed version and linkage + ansible.builtin.command: + argv: "{{ item }}" + loop: + - ["{{ ipmctl_binary_path }}", version] + - [/usr/bin/ldd, "{{ ipmctl_binary_path }}"] + register: ipmctl_installed_software + changed_when: false + + - name: Inspect installed binary and manifest + ansible.builtin.stat: + path: "{{ item }}" + follow: true + checksum_algorithm: sha256 + loop: + - "{{ ipmctl_binary_path }}" + - "{{ ipmctl_build_dir }}/install_manifest.txt" + register: ipmctl_installed_stats + + - name: Require installed software identity + ansible.builtin.assert: + that: + - >- + ( + ipmctl_installed_software.results[0].stdout + | regex_search('[0-9]{2}\\.[0-9]{2}\\.[0-9]{2}\\.[0-9]{4}') + | default('') + ) == ipmctl_expected_version + - "'not found' not in ipmctl_installed_software.results[1].stdout" + - ipmctl_installed_stats.results[0].stat.isreg | default(false) + - ipmctl_installed_stats.results[1].stat.isreg | default(false) + fail_msg: "Installed ipmctl version, linkage, or manifest is invalid." + + - name: Read toolchain versions for receipt + ansible.builtin.command: + argv: "{{ item }}" + loop: + - [/usr/bin/gcc, -dumpfullversion] + - [/usr/bin/g++, -dumpfullversion] + - [/usr/bin/cmake, --version] + - [/usr/bin/dpkg-query, -W, '-f=${Package}=${Version}\n', libndctl-dev, libndctl6] + register: ipmctl_toolchain_versions + changed_when: false + + - name: Create managed receipt directory + ansible.builtin.file: + path: "{{ ipmctl_receipt_root }}" + state: directory + owner: root + group: root + mode: "0755" + become: true + + - name: Preserve CMake install manifest + ansible.builtin.copy: + src: "{{ ipmctl_build_dir }}/install_manifest.txt" + dest: "{{ ipmctl_install_manifest_path }}" + remote_src: true + owner: root + group: root + mode: "0644" + become: true + + - name: Write atomic installation receipt + ansible.builtin.copy: + dest: "{{ ipmctl_receipt_path }}" + owner: root + group: root + mode: "0644" + content: >- + {{ + { + 'schema_version': 1, + 'installed_at': now(utc=true, fmt='%Y-%m-%dT%H:%M:%SZ'), + 'platform': {'debian': '13', 'architecture': 'amd64'}, + 'ipmctl': {'tag': ipmctl_tag, 'commit': ipmctl_commit, 'version': ipmctl_expected_version}, + 'edk2': {'tag': ipmctl_edk2_tag, 'commit': ipmctl_edk2_commit}, + 'patches': ipmctl_patch_receipt, + 'toolchain': { + 'gcc': ipmctl_toolchain_versions.results[0].stdout | trim, + 'g++': ipmctl_toolchain_versions.results[1].stdout | trim, + 'cmake': ipmctl_toolchain_versions.results[2].stdout_lines | first, + 'libndctl': ipmctl_toolchain_versions.results[3].stdout_lines + }, + 'install': { + 'prefix': ipmctl_install_prefix, + 'binary': ipmctl_binary_path, + 'binary_sha256': ipmctl_installed_stats.results[0].stat.checksum + } + } + | to_nice_json + }} + become: true + + - name: Report retained build workspace + ansible.builtin.debug: + msg: "Pinned source/build workspace retained at {{ ipmctl_run_root }}" diff --git a/ansible/cli/llm/host.yml b/ansible/cli/llm/host.yml index 4c1c536..17d603e 100644 --- a/ansible/cli/llm/host.yml +++ b/ansible/cli/llm/host.yml @@ -27,7 +27,8 @@ llm_host_gpu_facts_path: /etc/ansible/debian/facts/gpu.yml llm_host_nvidia_facts_path: /etc/ansible/debian/facts/nvidia.yml llm_host_nvlink_facts_path: /etc/ansible/debian/facts/nvlink.yml - llm_host_ipmctl_facts_path: /etc/ansible/debian/facts/ipmctl.yml + llm_host_ipmctl_binary_path: /usr/local/bin/ipmctl + llm_host_ipmctl_expected_version: 03.00.00.0538 llm_host_managed_directories: - /opt/src - /opt/venvs @@ -57,6 +58,7 @@ llm_host_require_ipmctl_effective: >- {{ (llm_host_require_ipmctl | bool) + or (llm_host_require_memory_mode | bool) or (llm_host_profile | lower == 'icelake-pmem-dual-3090') }} llm_host_require_nvidia_effective: >- @@ -160,89 +162,66 @@ - >- not (llm_host_require_memory_mode_effective | bool) or - llm_host_inventory.memory_mode.classification in ['verified', 'consistent'] + llm_host_inventory.memory_mode.classification == 'verified' fail_msg: >- Memory Mode evidence is {{ llm_host_inventory.memory_mode.classification }}. Required Memory - Mode must be verified by ipmctl or remain consistent with DMI - persistent-memory evidence. + Mode requires positive live MemoryCapacity from the reviewed ipmctl. - - name: Check producer-owned ipmctl facts - ansible.builtin.stat: - path: "{{ llm_host_ipmctl_facts_path }}" - register: llm_host_ipmctl_fact_stat - - - name: Require ipmctl facts selected by host policy - ansible.builtin.assert: - that: - - not (llm_host_require_ipmctl_effective | bool) or llm_host_ipmctl_fact_stat.stat.exists - fail_msg: >- - Authoritative ipmctl facts are required. Run setup/cli/ipmctl.sh - apply and validate before this host profile. - - - name: Initialize optional ipmctl fact document - ansible.builtin.set_fact: - llm_host_ipmctl_facts: {} - - - name: Read available ipmctl facts - ansible.builtin.slurp: - src: "{{ llm_host_ipmctl_facts_path }}" - register: llm_host_ipmctl_fact_raw - when: llm_host_ipmctl_fact_stat.stat.exists - - - name: Decode available ipmctl facts - ansible.builtin.set_fact: - llm_host_ipmctl_facts: "{{ llm_host_ipmctl_fact_raw.content | b64decode | from_yaml }}" - when: llm_host_ipmctl_fact_stat.stat.exists - - - name: Validate authoritative ipmctl producer contract - ansible.builtin.assert: - that: - - llm_host_ipmctl_facts.ipmctl.schema_version | default(0) | int == 1 - - llm_host_ipmctl_facts.ipmctl.readiness.tool_ready | default(false) | bool - - llm_host_ipmctl_facts.ipmctl.readiness.inventory_ready | default(false) | bool - - llm_host_ipmctl_facts.ipmctl.readiness.settled | default(false) | bool - - llm_host_ipmctl_facts.ipmctl.inventory.pending_goal.present | default(true) == false - - not (llm_host_require_memory_mode_effective | bool) or llm_host_ipmctl_facts.ipmctl.readiness.memory_mode_verified | default(false) | bool - fail_msg: >- - ipmctl facts must describe a live, completely inventoried, settled - platform. Required Memory Mode must have positive ipmctl evidence. - when: llm_host_require_ipmctl_effective | bool - - - name: Verify live ipmctl version agrees with producer facts + - name: Verify live reviewed ipmctl version ansible.builtin.command: argv: - - ipmctl + - "{{ llm_host_ipmctl_binary_path }}" - version register: llm_host_live_ipmctl_version changed_when: false when: llm_host_require_ipmctl_effective | bool - - name: Verify live ipmctl has no pending PMem goal + - name: Verify live ipmctl memory resources + ansible.builtin.command: + argv: + - "{{ llm_host_ipmctl_binary_path }}" + - show + - -memoryresources + register: llm_host_live_ipmctl_memoryresources + changed_when: false + when: llm_host_require_ipmctl_effective | bool + + - name: Collect live ipmctl current or pending goal diagnostic ansible.builtin.command: argv: - - ipmctl + - "{{ llm_host_ipmctl_binary_path }}" - show - -a - -goal register: llm_host_live_ipmctl_goal changed_when: false + failed_when: false when: llm_host_require_ipmctl_effective | bool - - name: Require live ipmctl identity and settled goal state + - name: Report live ipmctl goal diagnostic + ansible.builtin.debug: + msg: + command: "{{ llm_host_ipmctl_binary_path }} show -a -goal" + rc: "{{ llm_host_live_ipmctl_goal.rc }}" + stdout: "{{ llm_host_live_ipmctl_goal.stdout }}" + stderr: "{{ llm_host_live_ipmctl_goal.stderr }}" + when: llm_host_require_ipmctl_effective | bool + + - name: Require live ipmctl identity and memory resources ansible.builtin.assert: that: - llm_host_live_ipmctl_version.rc | int == 0 - - llm_host_ipmctl_facts.ipmctl.inventory.binary.version in llm_host_live_ipmctl_version.stdout - - llm_host_live_ipmctl_goal.rc | int == 0 - >- - not ( - llm_host_live_ipmctl_goal.stdout - | regex_search('(?im)^\\s*Status\\s*(?:=|:|\\|)\\s*New\\b') - ) + ( + llm_host_live_ipmctl_version.stdout + | regex_search('[0-9]{2}\\.[0-9]{2}\\.[0-9]{2}\\.[0-9]{4}') + | default('') + ) == llm_host_ipmctl_expected_version + - llm_host_live_ipmctl_memoryresources.rc | int == 0 fail_msg: >- - Live ipmctl does not match the producer-owned facts or reports a - pending PMem goal. Revalidate ipmctl before host validation. + Live /usr/local ipmctl has the wrong version or cannot report memory + resources. Goal output is diagnostic and requires human review. when: llm_host_require_ipmctl_effective | bool - name: Enforce host memory reserve @@ -565,11 +544,9 @@ producers: ipmctl: required: {{ llm_host_require_ipmctl_effective | bool | to_json }} - path: {{ llm_host_ipmctl_facts_path | to_json }} - schema_version: {{ llm_host_ipmctl_facts.ipmctl.schema_version | default(0) | int }} - source_profile: {{ llm_host_ipmctl_facts.ipmctl.source.profile | default('') | to_json }} - current_mode: {{ llm_host_ipmctl_facts.ipmctl.inventory.memory_resources.current_mode | default('unknown') | to_json }} - settled: {{ llm_host_ipmctl_facts.ipmctl.readiness.settled | default(false) | bool | to_json }} + binary: {{ llm_host_ipmctl_binary_path | to_json }} + expected_version: {{ llm_host_ipmctl_expected_version | to_json }} + memory_resources_available: {{ (llm_host_live_ipmctl_memoryresources.rc | default(1) | int == 0) | to_json }} gpu: required: {{ llm_host_require_nvidia_effective | bool | to_json }} path: {{ llm_host_gpu_facts_path | to_json }} @@ -659,7 +636,7 @@ - "Physical cores/logical CPUs: {{ llm_host_inventory.cpu.physical_core_count }}/{{ llm_host_inventory.cpu.logical_count }}" - "Physical-core CPU list: {{ llm_host_inventory.cpu.selected_cpu_list }}" - "Memory Mode evidence: {{ llm_host_inventory.memory_mode.classification }}" - - "ipmctl required/settled: {{ llm_host_require_ipmctl_effective }}/{{ llm_host_ipmctl_facts.ipmctl.readiness.settled | default(false) }}" + - "ipmctl required: {{ llm_host_require_ipmctl_effective }}" - "Host reserve: {{ llm_host_reserve_gib_effective }} GiB" - "NVIDIA/NVLink/P2P required: {{ llm_host_require_nvidia_effective }}/{{ llm_host_require_nvlink_effective }}/{{ llm_host_require_p2p_effective }}" - "Shared LLM host readiness: READY" diff --git a/ansible/files/ipmctl/apply-patch.yml b/ansible/files/ipmctl/apply-patch.yml new file mode 100644 index 0000000..7374739 --- /dev/null +++ b/ansible/files/ipmctl/apply-patch.yml @@ -0,0 +1,96 @@ +--- +- name: "Inspect patch {{ ipmctl_patch.id }}" + ansible.builtin.stat: + path: "{{ ipmctl_patch_root }}/{{ ipmctl_patch.filename }}" + follow: false + checksum_algorithm: sha256 + register: ipmctl_patch_file_stat + +- name: "Require patch checksum {{ ipmctl_patch.id }}" + ansible.builtin.assert: + that: + - ipmctl_patch_file_stat.stat.isreg | default(false) + - ipmctl_patch_file_stat.stat.checksum | default('') == ipmctl_patch.sha256 + fail_msg: "Compatibility patch checksum is invalid: {{ ipmctl_patch.filename }}" + +- name: "Resolve patch root {{ ipmctl_patch.id }}" + ansible.builtin.set_fact: + ipmctl_patch_apply_root: >- + {{ ipmctl_edk2_source_dir if ipmctl_patch.repository == 'edk2' else ipmctl_source_dir }} + +- name: "Hash patch preimage {{ ipmctl_patch.id }}" + ansible.builtin.command: + argv: [/usr/bin/sha256sum, "{{ ipmctl_patch_apply_root }}/{{ ipmctl_patch.target }}"] + register: ipmctl_patch_preimage + changed_when: false + +- name: "Inspect patch target {{ ipmctl_patch.id }}" + ansible.builtin.command: + argv: + - /usr/bin/git + - -C + - "{{ ipmctl_patch_apply_root }}" + - apply + - --numstat + - "{{ ipmctl_patch_root }}/{{ ipmctl_patch.filename }}" + register: ipmctl_patch_numstat + changed_when: false + +- name: "Require exact patch preimage and target {{ ipmctl_patch.id }}" + ansible.builtin.assert: + that: + - ipmctl_patch_preimage.stdout.split(' ') | first == ipmctl_patch.preimage_sha256 + - ipmctl_patch_numstat.stdout_lines | length == 1 + - ipmctl_patch_numstat.stdout_lines[0].split('\t')[2] == ipmctl_patch.target + fail_msg: "Compatibility patch preimage or target drifted: {{ ipmctl_patch.id }}" + +- name: "Preflight patch {{ ipmctl_patch.id }}" + ansible.builtin.command: + argv: + - /usr/bin/git + - -C + - "{{ ipmctl_patch_apply_root }}" + - apply + - --check + - --whitespace=error-all + - "{{ ipmctl_patch_root }}/{{ ipmctl_patch.filename }}" + changed_when: false + +- name: "Apply patch {{ ipmctl_patch.id }}" + ansible.builtin.command: + argv: + - /usr/bin/git + - -C + - "{{ ipmctl_patch_apply_root }}" + - apply + - --whitespace=error-all + - "{{ ipmctl_patch_root }}/{{ ipmctl_patch.filename }}" + +- name: "Verify reverse applicability {{ ipmctl_patch.id }}" + ansible.builtin.command: + argv: + - /usr/bin/git + - -C + - "{{ ipmctl_patch_apply_root }}" + - apply + - --reverse + - --check + - "{{ ipmctl_patch_root }}/{{ ipmctl_patch.filename }}" + changed_when: false + +- name: "Hash patch postimage {{ ipmctl_patch.id }}" + ansible.builtin.command: + argv: [/usr/bin/sha256sum, "{{ ipmctl_patch_apply_root }}/{{ ipmctl_patch.target }}"] + register: ipmctl_patch_postimage + changed_when: false + +- name: "Check patched worktree {{ ipmctl_patch.id }}" + ansible.builtin.command: + argv: [/usr/bin/git, -C, "{{ ipmctl_patch_apply_root }}", diff, --check] + changed_when: false + +- name: "Require exact patch postimage {{ ipmctl_patch.id }}" + ansible.builtin.assert: + that: + - ipmctl_patch_postimage.stdout.split(' ') | first == ipmctl_patch.postimage_sha256 + fail_msg: "Compatibility patch postimage drifted: {{ ipmctl_patch.id }}" diff --git a/ansible/files/ipmctl/compatibility-matrix.yml b/ansible/files/ipmctl/compatibility-matrix.yml deleted file mode 100644 index ba36ac1..0000000 --- a/ansible/files/ipmctl/compatibility-matrix.yml +++ /dev/null @@ -1,23 +0,0 @@ -{ - "schema_version": 1, - "profiles": [ - { - "feature": "ipmctl", - "id": "trixie-v03.00.00.0538", - "repository_url": "https://github.com/intel/ipmctl.git", - "release": "v03.00.00.0538", - "commit": "a71f2fb1c90dd07f9862b71c789881132193e8f9", - "edk2_repository_url": "https://github.com/tianocore/edk2.git", - "edk2_release": "edk2-stable202111", - "edk2_commit": "bb1bba3d776733c41dbfa2d1dc0fe234819a79f2", - "binary_version": "03.00.00.0538", - "os_patch_script": "patch_OS.sh", - "os_patch": "src/os/patches/0001-Ignore-STATIC_ASSERTs-and-NULL-define-for-os-and-ut-builds.patch", - "distribution": "Debian", - "release_major": "13", - "architecture": "amd64", - "install_prefix": "/usr/local", - "allowed_build_types": ["release", "debug"] - } - ] -} diff --git a/ansible/files/ipmctl/ipmctl-inventory.py b/ansible/files/ipmctl/ipmctl-inventory.py deleted file mode 100755 index 9637492..0000000 --- a/ansible/files/ipmctl/ipmctl-inventory.py +++ /dev/null @@ -1,319 +0,0 @@ -#!/usr/bin/env python3 -"""Collect and normalize read-only ipmctl and ndctl observations.""" - -from __future__ import annotations - -import argparse -import datetime as dt -import json -import re -import subprocess -from pathlib import Path -from typing import Any - - -COMMANDS = { - "version": ["ipmctl", "version"], - "dimms": ["ipmctl", "show", "-a", "-dimm"], - "topology": ["ipmctl", "show", "-a", "-topology"], - "memory_resources": ["ipmctl", "show", "-u", "B", "-memoryresources"], - "regions": ["ipmctl", "show", "-a", "-region"], - "sensors": ["ipmctl", "show", "-sensor"], - "capabilities": ["ipmctl", "show", "-a", "-system", "-capabilities"], - "goal": ["ipmctl", "show", "-a", "-goal"], - "ndctl_dimms": ["ndctl", "list", "-D"], - "ndctl_regions": ["ndctl", "list", "-R"], - "ndctl_namespaces": ["ndctl", "list", "-N"], -} - - -def safe_name(value: str) -> str: - return value.replace("_", "-") - - -def fixture_path( - fixture_dir: Path | None, - fixture_base_dir: Path | None, - filename: str, -) -> Path | None: - for directory in (fixture_dir, fixture_base_dir): - if directory is not None and (directory / filename).exists(): - return directory / filename - return None - - -def execute( - argv: list[str], - fixture_dir: Path | None, - fixture_base_dir: Path | None, - log_dir: Path | None, - name: str, -) -> dict[str, Any]: - if fixture_dir: - stdout_path = fixture_path( - fixture_dir, fixture_base_dir, f"{safe_name(name)}.txt" - ) - rc_path = fixture_path( - fixture_dir, fixture_base_dir, f"{safe_name(name)}.rc" - ) - stdout = stdout_path.read_text(encoding="utf-8") if stdout_path else "" - rc = int(rc_path.read_text(encoding="utf-8").strip()) if rc_path else 127 - stderr = "" - else: - try: - result = subprocess.run(argv, check=False, capture_output=True, text=True) - stdout, stderr, rc = result.stdout, result.stderr, result.returncode - except FileNotFoundError as error: - stdout, stderr, rc = "", str(error), 127 - if log_dir: - log_dir.mkdir(parents=True, exist_ok=True) - (log_dir / f"{safe_name(name)}.txt").write_text(stdout, encoding="utf-8") - (log_dir / f"{safe_name(name)}.stderr.txt").write_text(stderr, encoding="utf-8") - (log_dir / f"{safe_name(name)}.rc").write_text(f"{rc}\n", encoding="utf-8") - return {"argv": argv, "rc": rc, "stdout": stdout, "stderr": stderr} - - -def parse_json_list(text: str) -> list[Any]: - try: - value = json.loads(text or "[]") - except json.JSONDecodeError: - return [] - return value if isinstance(value, list) else [value] - - -def pipe_table_records(text: str) -> list[dict[str, str]]: - lines = text.splitlines() - for index, line in enumerate(lines): - if "|" not in line: - continue - header = [column.strip() for column in line.strip().strip("|").split("|")] - if len(header) < 2 or len(set(header)) != len(header): - continue - separator_index = index + 1 - while separator_index < len(lines) and not lines[separator_index].strip(): - separator_index += 1 - if separator_index >= len(lines) or not re.fullmatch( - r"[\s=+-]+", lines[separator_index] - ): - continue - records: list[dict[str, str]] = [] - for row_line in lines[separator_index + 1 :]: - if not row_line.strip(): - break - if "|" not in row_line: - continue - row = [ - column.strip() - for column in row_line.strip().strip("|").split("|") - ] - if len(row) != len(header): - continue - records.append(dict(zip(header, row))) - if records: - return records - return [] - - -def values_for(text: str, label: str) -> list[str]: - pattern = re.compile( - rf"(?im)^\s*(?:---)?{re.escape(label)}\s*(?:=|:)\s*(.*?)" - rf"(?:---)?\s*$" - ) - values = [match.group(1).strip(" |-") for match in pattern.finditer(text)] - values.extend( - record[label].strip() - for record in pipe_table_records(text) - if label in record and record[label].strip() - ) - return values - - -def first_value(text: str, label: str) -> str: - values = values_for(text, label) - return values[0] if values else "" - - -def capacity_bytes(text: str, label: str) -> int: - value = first_value(text, label) - if not value: - match = re.search( - rf"(?im)^\s*{re.escape(label)}\s*\|\s*(.*?)\s*$", text - ) - value = match.group(1).strip(" |") if match else "" - match = re.search(r"([0-9][0-9,]*)", value) - return int(match.group(1).replace(",", "")) if match else 0 - - -def contains_all_state(text: str, label: str, accepted: set[str]) -> bool: - values = [value.lower() for value in values_for(text, label)] - return bool(values) and all(value in accepted for value in values) - - -def normalized_words(value: str) -> str: - return re.sub(r"[^a-z0-9]", "", value.lower()) - - -def security_state_safe(value: str) -> bool: - tokens = set(re.findall(r"[a-z]+", value.lower())) - return "locked" not in tokens and bool(tokens & {"disabled", "unlocked"}) - - -def normalize(observations: dict[str, dict[str, Any]], log_dir: Path | None) -> dict[str, Any]: - dimms = observations["dimms"]["stdout"] - topology = observations["topology"]["stdout"] - memory = observations["memory_resources"]["stdout"] - region_output = observations["regions"]["stdout"] - capabilities = observations["capabilities"]["stdout"] - goal = observations["goal"]["stdout"] - namespaces = parse_json_list(observations["ndctl_namespaces"]["stdout"]) - regions = parse_json_list(observations["ndctl_regions"]["stdout"]) - ndctl_dimms = parse_json_list(observations["ndctl_dimms"]["stdout"]) - - volatile_pmem = capacity_bytes(memory, "Volatile PMem module Capacity") - app_direct = capacity_bytes(memory, "AppDirect PMem module Capacity") - cache_ddr = capacity_bytes(memory, "Cache DDR Capacity") - current_volatile_mode = first_value(capabilities, "CurrentVolatileMode") - current_volatile_mode_normalized = normalized_words(current_volatile_mode) - region_types = values_for(region_output, "PersistentMemoryType") - normalized_region_types = { - normalized_words(value) for value in region_types if value - } - if current_volatile_mode_normalized in {"2lm", "memorymode"} and volatile_pmem > 0: - current_mode = "mixed" if app_direct > 0 else "memory-mode" - elif app_direct > 0: - if normalized_region_types == {"appdirect"}: - current_mode = "app-direct" - elif normalized_region_types == {"appdirectnotinterleaved"}: - current_mode = "app-direct-not-interleaved" - else: - current_mode = "app-direct-unknown" - else: - current_mode = "unknown" - - pending_goal = bool(re.search(r"(?im)^\s*Status\s*(?:=|:|\|)\s*New\b", goal)) - dimm_ids = values_for(dimms, "DimmID") - topology_records = pipe_table_records(topology) - topology_dimm_ids = values_for(topology, "DimmID") - topology_socket_values = [ - record.get("SocketID", "") - for record in topology_records - if record.get("DimmID", "") in dimm_ids - ] or values_for(topology, "SocketID") - sockets = sorted( - { - int(value, 0) - for value in topology_socket_values - if re.fullmatch(r"(?:0x[0-9a-fA-F]+|[0-9]+)", value) - } - ) - topology_verified = ( - bool(dimm_ids) - and bool(sockets) - and set(dimm_ids).issubset(set(topology_dimm_ids)) - ) - version_text = observations["version"]["stdout"].strip() - modes_supported = ( - first_value(capabilities, "ModesSupported") - or first_value(dimms, "ModesSupported") - ) - normalized_modes = normalized_words(modes_supported) - security_values = values_for(dimms, "SecurityState") or values_for(dimms, "LockState") - security_safe = bool(security_values) and all( - security_state_safe(value) for value in security_values - ) - inventory_ready = ( - all(value["rc"] == 0 for value in observations.values()) - and bool(dimm_ids) - and topology_verified - ) - return { - "schema_version": 1, - "generated_at": dt.datetime.now(dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"), - "binary": { - "available": observations["version"]["rc"] == 0, - "version_rc": observations["version"]["rc"], - "version": version_text, - }, - "hardware": { - "present": observations["dimms"]["rc"] == 0 and bool(dimm_ids), - "dimm_ids": dimm_ids, - "socket_ids": sockets, - "topology_verified": topology_verified, - "manageable": contains_all_state(dimms, "ManageabilityState", {"manageable"}), - "healthy": contains_all_state(dimms, "HealthState", {"healthy", "normal"}), - "security_safe_for_goal": security_safe, - }, - "capabilities": { - "command_rc": observations["capabilities"]["rc"], - "platform_config_supported": first_value(capabilities, "PlatformConfigSupported") == "1", - "current_volatile_mode": current_volatile_mode, - "allowed_volatile_mode": first_value(capabilities, "AllowedVolatileMode"), - "allowed_app_direct_mode": first_value(capabilities, "AllowedAppDirectMode"), - "modes_supported": modes_supported, - "memory_mode_supported": ( - "2lm" in normalized_modes or "memorymode" in normalized_modes - ), - "app_direct_supported": "appdirect" in normalized_modes, - }, - "memory_resources": { - "command_rc": observations["memory_resources"]["rc"], - "volatile_pmem_bytes": volatile_pmem, - "app_direct_pmem_bytes": app_direct, - "cache_ddr_bytes": cache_ddr, - "current_mode": current_mode, - "memory_mode_verified": current_mode in {"memory-mode", "mixed"} and cache_ddr > 0, - }, - "regions": { - "persistent_memory_types": region_types, - }, - "pending_goal": { - "command_rc": observations["goal"]["rc"], - "present": pending_goal, - }, - "ndctl": { - "dimms": ndctl_dimms, - "regions": regions, - "namespaces": namespaces, - "namespace_count": len(namespaces), - }, - "commands": { - key: { - "rc": value["rc"], - "log": str(log_dir / f"{safe_name(key)}.txt") if log_dir else "", - } - for key, value in observations.items() - }, - "readiness": { - "tool_ready": observations["version"]["rc"] == 0, - "inventory_ready": inventory_ready, - "goal_change_supported": ( - inventory_ready - and first_value(capabilities, "PlatformConfigSupported") == "1" - ), - "settled": not pending_goal, - }, - } - - -def main() -> int: - parser = argparse.ArgumentParser() - parser.add_argument("--fixture-dir", type=Path) - parser.add_argument("--fixture-base-dir", type=Path) - parser.add_argument("--log-dir", type=Path) - args = parser.parse_args() - observations = { - name: execute( - argv, - args.fixture_dir, - args.fixture_base_dir, - args.log_dir, - name, - ) - for name, argv in COMMANDS.items() - } - print(json.dumps(normalize(observations, args.log_dir), sort_keys=True)) - return 0 - - -if __name__ == "__main__": - raise SystemExit(main()) diff --git a/ansible/files/ipmctl/patches/0001-edk2-stable202511-host-os-build.patch b/ansible/files/ipmctl/patches/0001-edk2-stable202511-host-os-build.patch new file mode 100644 index 0000000..55598f4 --- /dev/null +++ b/ansible/files/ipmctl/patches/0001-edk2-stable202511-host-os-build.patch @@ -0,0 +1,22 @@ +Subject: [PATCH] [PATCH]: ignore static asserts and null define for os and ut + builds +Upstream-Status: Backport +Signed-off-by: Teoh Suh Haw +--- + MdePkg/Include/Base.h | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h +index 0ce635c3b94bef63765dc4c9c807ab22333eff68..1a61fe3b91b31528503ad413332880d27e0f3da8 100644 +GIT binary patch +delta 241 +zcmbRAjOpHUrVS_MEi=;;6jM^uGV@YX6g2#U + +delta 81 +zcmccjoN3ZCrVS_MC$lOjZ#Ga^ +Date: Wed, 18 May 2022 12:24:03 +0800 +Subject: [PATCH] CMakeLists: disable Werror + +gcc12 highlights minor warnings that cause the build to fail. Ignore +those until they aren't fixed upstream. + +Upstream-Status: Inappropriate + +Signed-off-by: Anuj Mittal +--- + CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 418483f7..c019fea0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -146,7 +146,7 @@ else() + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-strict-aliasing -D_FORTIFY_SOURCE=2") + if(LNX_BUILD) + #A few warnings yet to resolve under esx +- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Werror") ++ #set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Werror") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Werror") + endif() + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ggdb") +@@ -791,4 +791,4 @@ if(ESX_BUILD) + include(CMake/esx.cmake) + endif() + +-add_subdirectory(src/os/nvm_api_sample) +\ No newline at end of file ++add_subdirectory(src/os/nvm_api_sample) +-- +2.35.3 diff --git a/ansible/files/ipmctl/patches/0003-ipmctl-remove-pie-from-shared-linker-flags.patch b/ansible/files/ipmctl/patches/0003-ipmctl-remove-pie-from-shared-linker-flags.patch new file mode 100644 index 0000000..18f245e --- /dev/null +++ b/ansible/files/ipmctl/patches/0003-ipmctl-remove-pie-from-shared-linker-flags.patch @@ -0,0 +1,38 @@ +From 5b8b59a18f4a54ba912faad861f0af3fdcf127c6 Mon Sep 17 00:00:00 2001 +From: Yogesh Tyagi +Date: Wed, 10 Sep 2025 21:15:53 +0800 +Subject: [PATCH] CMakeLists: fix build failure by removing -pie from shared + library targets + +With CMake 4.1.0 the build of libipmctl started failing with: + + error: undefined reference to `main` in *.S + +- `-pie` is only valid when linking executables (PIE), not shared + libraries. +- When applied to a shared library, the linker expects a `main` + symbol, causing the undefined reference error. +- Remove `-pie` from shared libraries linker flag + +Upstream-Status: Submitted [https://github.com/intel/ipmctl/pull/221] + +Signed-off-by: Yogesh Tyagi +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1c07e682..d7aab78f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -156,7 +156,7 @@ endif() + if(UNIX) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_MSABI_VA_FUNCS -std=c99 -Wformat -Wformat-security -D_XOPEN_SOURCE=500 -Wall -Wfatal-errors -MMD -fPIC -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wformat -Wformat-security -D_XOPEN_SOURCE=500 -Drestrict=__restrict__ -Wall -Wfatal-errors -MMD -fPIC -fno-strict-aliasing") +- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now -pie") ++ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now") + elseif(MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GS /DynamicBase /sdl") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS /DynamicBase /sdl") +-- +2.37.3 diff --git a/ansible/files/ipmctl/patches/README.md b/ansible/files/ipmctl/patches/README.md new file mode 100644 index 0000000..83c6182 --- /dev/null +++ b/ansible/files/ipmctl/patches/README.md @@ -0,0 +1,27 @@ +# ipmctl Debian 13 compatibility patches + +These patches are applied only to the pinned source tuple documented by the +ipmctl playbook. Installation never discovers or downloads patches at runtime. + +- `0001-edk2-stable202511-host-os-build.patch` is regenerated against EDK2 + commit `46548b1adac82211d8d11da12dd914f41e7aa775`. It preserves that + commit's CRLF `MdePkg/Include/Base.h` blob and implements the host-build + guards carried by meta-intel. The binary Git delta keeps line endings exact; + the playbook verifies its SHA-256 + `ac6f0ea143c357c582135472defe8e936a63d7997221a29d4d0e4c349d7ac013`, + single target, and pre/postimage values. Original attribution and status are + retained from the [exact meta-intel source](https://github.com/YoeDistro/meta-intel/blob/8877caca6b1fe6efe33c756698ce6ecdcaea2238/dynamic-layers/openembedded-layer/recipes-support/ipmctl/ipmctl/0001-Ignore-STATIC_ASSERTs-and-NULL-define-for-os-and-ut-builds.patch). +- `0002-ipmctl-disable-c-release-werror.patch` and + `0003-ipmctl-remove-pie-from-shared-linker-flags.patch` are the meta-intel + patches at revision `8877caca6b1fe6efe33c756698ce6ecdcaea2238`. + Their SHA-256 values are respectively + `d1928dc874219578abbc9eab5cc7a826ccf88457bd148f268aff367d134321b8` + and `f926a6b07ad33b09f09032e6fd06a9229855d9d0501cfc7e67ecbb4c3c28a031`. + +Provenance: + +- https://github.com/YoeDistro/meta-intel/tree/8877caca6b1fe6efe33c756698ce6ecdcaea2238/dynamic-layers/openembedded-layer/recipes-support/ipmctl/ipmctl +- https://github.com/YoeDistro/meta-intel/blob/8877caca6b1fe6efe33c756698ce6ecdcaea2238/dynamic-layers/openembedded-layer/recipes-support/ipmctl/ipmctl/0001-CMakeLists-disable-Werror.patch +- https://github.com/YoeDistro/meta-intel/blob/8877caca6b1fe6efe33c756698ce6ecdcaea2238/dynamic-layers/openembedded-layer/recipes-support/ipmctl/ipmctl/0001-CMakeLists-fix-build-failure-by-removing-pie-from-sh.patch +- https://github.com/intel/ipmctl/releases/tag/v03.00.00.0538 +- https://github.com/tianocore/edk2/releases/tag/edk2-stable202511 diff --git a/ansible/files/ipmctl/source-profile.py b/ansible/files/ipmctl/source-profile.py deleted file mode 100755 index dbfb28a..0000000 --- a/ansible/files/ipmctl/source-profile.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env python3 -"""Validate one exact reviewed ipmctl and edk2 source tuple.""" - -from __future__ import annotations - -import argparse -import json -import re -import sys -from pathlib import Path -from urllib.parse import urlsplit - - -FULL_SHA = re.compile(r"^[0-9a-f]{40}$") -TOKEN = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._+-]*$") - - -def fail(message: str) -> None: - print(f"ipmctl-source-profile: {message}", file=sys.stderr) - raise SystemExit(64) - - -def validate_url(value: str, label: str) -> None: - parsed = urlsplit(value) - if ( - parsed.scheme != "https" - or not parsed.hostname - or parsed.username is not None - or parsed.password is not None - or parsed.query - or parsed.fragment - or not parsed.path.endswith(".git") - or ".." in parsed.path.split("/") - or re.search(r"[\x00-\x20\x7f`$;&|<>\\]", value) - ): - fail(f"{label} must be a credential-free HTTPS Git URL ending in .git") - - -def main() -> int: - parser = argparse.ArgumentParser() - parser.add_argument("--matrix", required=True, type=Path) - parser.add_argument("--profile", required=True) - parser.add_argument("--repository-url", required=True) - parser.add_argument("--release", required=True) - parser.add_argument("--commit", required=True) - parser.add_argument("--edk2-repository-url", required=True) - parser.add_argument("--edk2-release", required=True) - parser.add_argument("--edk2-commit", required=True) - args = parser.parse_args() - - for value, label in ( - (args.profile, "profile"), - (args.release, "release"), - (args.edk2_release, "edk2 release"), - ): - if not TOKEN.fullmatch(value): - fail(f"{label} contains unsupported characters") - validate_url(args.repository_url, "repository URL") - validate_url(args.edk2_repository_url, "edk2 repository URL") - if not FULL_SHA.fullmatch(args.commit): - fail("commit must be a lowercase full 40-character SHA") - if not FULL_SHA.fullmatch(args.edk2_commit): - fail("edk2 commit must be a lowercase full 40-character SHA") - - try: - document = json.loads(args.matrix.read_text(encoding="utf-8")) - except (OSError, json.JSONDecodeError) as error: - fail(f"cannot decode compatibility matrix: {error}") - profiles = document.get("profiles", []) - matches = [ - profile - for profile in profiles - if isinstance(profile, dict) - and profile.get("feature") == "ipmctl" - and profile.get("id") == args.profile - ] - if document.get("schema_version") != 1 or len(matches) != 1: - fail("matrix must contain exactly one matching schema-version-1 profile") - - profile = matches[0] - requested = { - "repository_url": args.repository_url, - "release": args.release, - "commit": args.commit, - "edk2_repository_url": args.edk2_repository_url, - "edk2_release": args.edk2_release, - "edk2_commit": args.edk2_commit, - } - mismatches = { - key: {"reviewed": profile.get(key), "requested": value} - for key, value in requested.items() - if profile.get(key) != value - } - if mismatches: - fail("source tuple is not reviewed: " + json.dumps(mismatches, sort_keys=True)) - if not re.fullmatch( - r"[0-9]{2}\.[0-9]{2}\.[0-9]{2}\.[0-9]{4}", - str(profile.get("binary_version", "")), - ): - fail("reviewed profile must declare a four-component binary_version") - if profile.get("os_patch_script") != "patch_OS.sh": - fail("reviewed profile must use the pinned upstream patch_OS.sh") - if profile.get("os_patch") != ( - "src/os/patches/" - "0001-Ignore-STATIC_ASSERTs-and-NULL-define-for-os-and-ut-builds.patch" - ): - fail("reviewed profile contains an unexpected upstream OS patch") - print(json.dumps(profile, sort_keys=True)) - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/ansible/files/llm/host-inventory.py b/ansible/files/llm/host-inventory.py index d2367e2..cdae282 100755 --- a/ansible/files/llm/host-inventory.py +++ b/ansible/files/llm/host-inventory.py @@ -199,7 +199,8 @@ def positive_capacity(text: str) -> bool: def collect_memory_mode(source: Source) -> dict[str, Any]: ipmctl_rc, ipmctl_text = source.command( - ["ipmctl", "show", "-memoryresources"], "ipmctl-memoryresources" + ["/usr/local/bin/ipmctl", "show", "-memoryresources"], + "ipmctl-memoryresources", ) dmidecode_rc, dmidecode_text = source.command( ["dmidecode", "--type", "memory"], "dmidecode-memory" diff --git a/ansible/packages.yml b/ansible/packages.yml index 04a4d7f..bacff29 100644 --- a/ansible/packages.yml +++ b/ansible/packages.yml @@ -126,7 +126,7 @@ groups: - linux-cpupower - ndctl ipmctl_build: - description: Opt-in Debian 13 source build and PMem inventory dependencies for pinned ipmctl; never installed by baseline playbooks. + description: Opt-in Debian 13 build and read-only verification dependencies for pinned ipmctl; never installed by baseline playbooks. packages: - git - ca-certificates diff --git a/docs/actions/publish/readme.md b/docs/actions/publish/readme.md index c0581ef..3ad2618 100644 --- a/docs/actions/publish/readme.md +++ b/docs/actions/publish/readme.md @@ -45,3 +45,7 @@ PUBLISH_DIR=/tmp/debian-pages DOCS_SITE_ROOT=/debian \ The output directory is disposable generated content. Do not hand-edit `static/`; change its source and rebuild instead. + +Pull requests run runtime validation and build this artifact without +deployment. Only a successful push to `main` grants the deploy job write +permission and publishes the previously built artifact to the `www` branch. diff --git a/docs/actions/readme.md b/docs/actions/readme.md index d0b090f..cbc8773 100644 --- a/docs/actions/readme.md +++ b/docs/actions/readme.md @@ -55,6 +55,5 @@ only on the remote GPU host. `www.pages.sh` replaces its selected publish directory. Contract validation only reads project content, aside from temporary fixture locations. The -dedicated ipmctl source-build action clones and compiles the reviewed source -pins in an isolated Debian 13 CI job; it does not install onto the Actions -runner host. +ipmctl contract validates the vendored patch pack and exact pins statically; +source compilation and hardware acceptance occur only on the target host. diff --git a/docs/actions/test/ipmctl-contract/readme.md b/docs/actions/test/ipmctl-contract/readme.md index 12771ad..adb082e 100644 --- a/docs/actions/test/ipmctl-contract/readme.md +++ b/docs/actions/test/ipmctl-contract/readme.md @@ -1,21 +1,34 @@ --- -title: ipmctl contract actions +title: ipmctl contract action section: Actions / Test / ipmctl source_path: actions/test.ipmctl-contract.sh --- -# ipmctl contract actions +# ipmctl contract action -`actions/test.ipmctl-contract.sh` checks the runner interface, exact ipmctl and -edk2 pins, fixture normalization, facts, host integration, and destructive -goal isolation. GitHub Actions enables remote tag verification. +`actions/test.ipmctl-contract.sh` performs repository-local validation of the +Debian 13 ipmctl feature. It checks: -`actions/test.ipmctl-source-build.sh` runs only in the Debian 13 GitHub Actions -container. It builds the exact reviewed Release tuple, installs into an -isolated prefix, runs Intel's pinned `updateedk.sh` and `patch_OS.sh` sequence, -injects the reviewed `BUILDNUM`, confirms that Release still enables `-Werror`, -checks the exact `ipmctl version`, and rejects unexpected patch targets or -unresolved libraries. +- the two-mode `install` and `verify` runner interface; +- exact ipmctl and EDK2 tags, commits, and expected binary version; +- all three vendored patch SHA-256 values and sole target declarations; +- strict preimage, apply, reverse-check, postimage, and diff-check tasks; +- unmanaged-install refusal, managed receipt, and idempotence gates; +- read-only verification and LLM live-ipmctl integration; +- removal of the old source-profile, inventory, goal, and hosted-build paths; +- Bash syntax, YAML parsing, embedded shell syntax, and Ansible syntax when + the validation environment provides Ansible. -Neither action runs PMem discovery or creates a goal. Hardware acceptance is -performed separately on the remote Optane host. +```bash +bash actions/test.ipmctl-contract.sh +``` + +For a minimal local check without Ansible syntax validation: + +```bash +bash actions/test.ipmctl-contract.sh --shell-only +``` + +The action does not clone source, compile ipmctl, install packages, run PMem +discovery, or change PMem state. Exact-source compilation and the four +read-only hardware probes are acceptance steps on the Debian 13 PMem host. diff --git a/docs/actions/validate/runtime/readme.md b/docs/actions/validate/runtime/readme.md index 1c4f77e..a1d9a2c 100644 --- a/docs/actions/validate/runtime/readme.md +++ b/docs/actions/validate/runtime/readme.md @@ -20,8 +20,8 @@ This action has no supported flags. CI provides pinned Ansible and PyYAML dependencies for real YAML parsing and the fixture-backed fact contracts. Locally, use the focused `--shell-only` actions listed on the [Actions index](/debian/actions/) when Python and Ansible execution is not -appropriate. Reviewed ipmctl source compilation runs in its separate Debian -13 GitHub Actions job. +appropriate. The ipmctl contract checks exact pins, vendored patch hashes, +targets, runner safety, and YAML without cloning or compiling upstream source. The orchestrator does not install host packages, execute host playbooks, compile CUDA code, reconfigure PMem, or access GPU/PMem hardware. diff --git a/docs/cli/ipmctl/readme.md b/docs/cli/ipmctl/readme.md index 8fa860c..bc729ee 100644 --- a/docs/cli/ipmctl/readme.md +++ b/docs/cli/ipmctl/readme.md @@ -7,267 +7,144 @@ script_url: https://devs-guide.github.io/debian/setup/cli/ipmctl.sh # Intel Optane ipmctl runner -`ipmctl.sh` installs one reviewed Intel Optane PMem utility from source, -captures authoritative PMem facts, and separates ordinary installation from -destructive memory-allocation goals. +`ipmctl.sh` installs one reviewed Intel Optane PMem CLI build on Debian 13 +amd64 and provides a small read-only verification mode. Debian Trixie does not +publish an `ipmctl` binary package, so the runner builds from exact upstream +source instead of mixing packages from another Debian release. Intel archived +ipmctl and does not promise further fixes or releases, so this repository owns +and discloses its finite downstream build policy. -Debian 13 does not publish an `ipmctl` package. Do not add Bookworm or Sid to a -Trixie host to obtain it. Apply fails if an installed package or configured APT -candidate exposes that cross-release migration. Remove the foreign source -through a separately reviewed package-repository change first. This runner -instead pins the newest upstream 03.x release, which upstream describes as -supporting every Intel Optane PMem generation: +The runner does not create or delete PMem goals, format DIMMs, manage +namespaces, change firmware or security state, or reboot the host. The +installed `ipmctl` program remains an administrative tool, so any command not +shown here is outside this automation and requires separate human review. + +## Reviewed source tuple | Source | Reviewed value | | --- | --- | | ipmctl repository | `https://github.com/intel/ipmctl.git` | | ipmctl tag | `v03.00.00.0538` | | ipmctl commit | `a71f2fb1c90dd07f9862b71c789881132193e8f9` | -| edk2 repository | `https://github.com/tianocore/edk2.git` | -| edk2 tag | `edk2-stable202111` | -| edk2 commit | `bb1bba3d776733c41dbfa2d1dc0fe234819a79f2` | -| managed binary version | `03.00.00.0538` | -| upstream Linux patch script | `patch_OS.sh` | +| expected version | `03.00.00.0538` | +| EDK2 repository | `https://github.com/tianocore/edk2.git` | +| EDK2 tag | `edk2-stable202511` | +| EDK2 commit | `46548b1adac82211d8d11da12dd914f41e7aa775` | | install prefix | `/usr/local` | -The release includes build-procedure fixes and a PBR parser crash fix. This is -a project-reviewed Debian 13 source build, not upstream Debian 13 -certification. The upstream repository is archived, so changing either source -pin requires a new compatibility review. - -References: +Three repository-owned, checksum-pinned compatibility patches are applied: -- [Debian package search](https://packages.debian.org/ipmctl) -- [upstream 03.x README](https://github.com/intel/ipmctl/blob/v03.00.00.0538/README.md) -- [v03.00.00.0538 release](https://github.com/intel/ipmctl/releases/tag/v03.00.00.0538) -- [upstream Linux build failure and patch procedure](https://github.com/intel/ipmctl/issues/199) -- [upstream CMake dependency policy](https://github.com/intel/ipmctl/blob/v03.00.00.0538/CMakeLists.txt) -- [Debian 13 libndctl6](https://packages.debian.org/trixie/libs/libndctl6) -- [ipmctl module output contract](https://docs.pmem.io/ipmctl-user-guide/module-discovery/show-device) -- [ipmctl topology output contract](https://docs.pmem.io/ipmctl-user-guide/module-discovery/show-topology) -- [ipmctl goal safety and syntax](https://docs.pmem.io/ipmctl-user-guide/provisioning/create-memory-allocation-goal) +1. An exact EDK2 `MdePkg/Include/Base.h` host-build patch regenerated against + the pinned CRLF source blob. +2. The meta-intel patch that removes Release `-Werror` from the C compiler + flags for this archived source. +3. The meta-intel patch that removes PIE from shared-library linker flags. -## Modes - -| Mode | Behavior | -| --- | --- | -| `preflight` | Unprivileged read-only report. It does not clone source, install packages, write facts, or change PMem. | -| `apply` | Installs optional build dependencies, builds the reviewed source, installs under `/usr/local`, inventories PMem, and writes facts. It never creates or deletes a goal. | -| `validate` | Runs privileged read-only inventory and refreshes the managed fact. | -| `goal-plan` | Runs all destructive-operation gates and prints the exact proposed goal command without changing PMem. | -| `goal-apply` | Repeats the plan, requires an exact `/dev/tty` confirmation, and creates one whole-capacity goal. | +Every patch is checked for its file checksum, sole target, exact preimage, +strict applicability, reverse applicability, exact postimage, and clean Git +diff before compilation. This replaces Intel's drifting `patch_OS.sh` and +`updateedk.sh` path with a small reproducible patch pack. -## Source installation +References: -Start with the read-only report: +- [Intel ipmctl v03.00.00.0538](https://github.com/intel/ipmctl/releases/tag/v03.00.00.0538) +- [Intel Linux build issue 199](https://github.com/intel/ipmctl/issues/199) +- [meta-intel ipmctl recipe](https://github.com/YoeDistro/meta-intel/tree/8877caca6b1fe6efe33c756698ce6ecdcaea2238/dynamic-layers/openembedded-layer/recipes-support/ipmctl/ipmctl) +- [EDK2 stable202511](https://github.com/tianocore/edk2/releases/tag/edk2-stable202511) +- [Debian package search for ipmctl](https://packages.debian.org/search?keywords=ipmctl) -```bash -wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh | \ - bash -s -- preflight \ - --profile=trixie-v03.00.00.0538 \ - --repository-url=https://github.com/intel/ipmctl.git \ - --release=v03.00.00.0538 \ - --commit=a71f2fb1c90dd07f9862b71c789881132193e8f9 \ - --edk2-repository-url=https://github.com/tianocore/edk2.git \ - --edk2-release=edk2-stable202111 \ - --edk2-commit=bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 \ - --build-type=release \ - --no-install-build-tools -``` +## Install -Build and install the reviewed Release profile: +Run as the non-root account that should own the source cache. The runner asks +for sudo through `/dev/tty`, installs only the opt-in `ipmctl_build` dependency +group, builds as the invoking user, and installs into `/usr/local` as root. ```bash wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh | \ - bash -s -- apply \ - --profile=trixie-v03.00.00.0538 \ - --repository-url=https://github.com/intel/ipmctl.git \ - --release=v03.00.00.0538 \ - --commit=a71f2fb1c90dd07f9862b71c789881132193e8f9 \ - --edk2-repository-url=https://github.com/tianocore/edk2.git \ - --edk2-release=edk2-stable202111 \ - --edk2-commit=bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 \ - --build-type=release \ - --install-build-tools + bash -s -- install ``` -With `--install-build-tools`, the runner authenticates sudo once and installs -only the opt-in `ipmctl_build` package group. It then fetches and verifies both -reviewed Git tags as the invoking user. Source-network access never runs under -sudo. - -The pinned Linux build order is `updateedk.sh`, `patch_OS.sh`, then CMake. -The reviewed EDK2 `stable202111` source contains the `Base.h` preimage required -by Intel's upstream patch, which disables the EDK2 `NULL` definition and -incompatible UEFI static assertions only for OS/unit-test builds. This -preserves the Release build's `-Werror` policy on Debian 13 and avoids a -project-owned EDK2 fork. - -The `.0499` and `.0538` upstream tags point to the same ipmctl commit, while -`.0499` is the annotated tag preferred by an unconstrained `git describe`. -Both CI and the remote build therefore pass -`-DBUILDNUM=03.00.00.0538` explicitly and verify that exact installed binary -version. Source tag, source commit, and binary version remain separate -provenance fields. - -Managed facts created before these binary-version and upstream-patch -provenance fields are considered stale. The next `apply` rebuilds the managed -installation once using the corrected sequence; later matching runs remain -idempotent. - -Then perform privileged read-only validation: +For an audit-friendly remote run, download and review the exact published +entrypoint first: ```bash -wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh | \ - sudo bash -s -- validate \ - --profile=trixie-v03.00.00.0538 \ - --repository-url=https://github.com/intel/ipmctl.git \ - --release=v03.00.00.0538 \ - --commit=a71f2fb1c90dd07f9862b71c789881132193e8f9 \ - --edk2-repository-url=https://github.com/tianocore/edk2.git \ - --edk2-release=edk2-stable202111 \ - --edk2-commit=bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 \ - --build-type=release \ - --no-install-build-tools +wget -qO /tmp/devs-guide-ipmctl.sh \ + https://devs-guide.github.io/debian/setup/cli/ipmctl.sh +less /tmp/devs-guide-ipmctl.sh +bash /tmp/devs-guide-ipmctl.sh install ``` -Release builds use upstream `-Werror`. A compiler warning therefore stops the -build and leaves its evidence in `/var/log/ipmctl//build.txt`. There is no -automatic fallback. After human review, repeat `apply` with -`--build-type=debug`; Debug disables Release optimization as well as -Release-only `-Werror`, so it is a different managed profile state and build -workspace. A non-current apply replaces only that selected mutable workspace -under `/opt/build/ipmctl`; reviewed source and immutable run logs remain. +The exact Git tags and commits are verified before patches are applied. CMake +uses a Release build with two parallel jobs. A successful install records its +commits, patch checksums, toolchain, binary checksum, and install manifest at: -```bash -wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh | \ - bash -s -- apply \ - --profile=trixie-v03.00.00.0538 \ - --repository-url=https://github.com/intel/ipmctl.git \ - --release=v03.00.00.0538 \ - --commit=a71f2fb1c90dd07f9862b71c789881132193e8f9 \ - --edk2-repository-url=https://github.com/tianocore/edk2.git \ - --edk2-release=edk2-stable202111 \ - --edk2-commit=bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 \ - --build-type=debug \ - --no-install-build-tools +```text +/var/lib/devs-guide/ipmctl/receipt.json ``` -## Goal workflow - -Only whole-capacity profiles are supported: +A repeat install skips source fetching and compilation only when the receipt, +binary checksum, exact version, and complete runtime linkage still match. +The installer refuses to overwrite an unmanaged `/usr/local/bin/ipmctl`. +Failed build workspaces remain under the invoking user's +`~/.cache/devs-guide/ipmctl/runs/` for inspection. -- `memory-mode` creates `MemoryMode=100`. -- `app-direct` creates `MemoryMode=0 PersistentMemoryType=AppDirect`. -- `app-direct-not-interleaved` creates - `MemoryMode=0 PersistentMemoryType=AppDirectNotInterleaved`. +## Verify -Always plan first: +Verification does not bootstrap Ansible or install packages. It requires the +exact `/usr/local/bin/ipmctl` version and no unresolved `ldd` dependencies, +then runs four privileged read-only probes: ```bash wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh | \ - bash -s -- goal-plan \ - --profile=trixie-v03.00.00.0538 \ - --repository-url=https://github.com/intel/ipmctl.git \ - --release=v03.00.00.0538 \ - --commit=a71f2fb1c90dd07f9862b71c789881132193e8f9 \ - --edk2-repository-url=https://github.com/tianocore/edk2.git \ - --edk2-release=edk2-stable202111 \ - --edk2-commit=bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 \ - --build-type=release \ - --goal=memory-mode \ - --socket=all \ - --no-install-build-tools + sudo bash -s -- verify ``` -After reviewing the plan, explicitly request the destructive operation: +The probes are equivalent to: ```bash -wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh | \ - bash -s -- goal-apply \ - --profile=trixie-v03.00.00.0538 \ - --repository-url=https://github.com/intel/ipmctl.git \ - --release=v03.00.00.0538 \ - --commit=a71f2fb1c90dd07f9862b71c789881132193e8f9 \ - --edk2-repository-url=https://github.com/tianocore/edk2.git \ - --edk2-release=edk2-stable202111 \ - --edk2-commit=bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 \ - --build-type=release \ - --goal=memory-mode \ - --socket=all \ - --no-install-build-tools \ - --allow-destructive-goal-change -``` - -The runner displays a privileged live plan, then requires typing exactly: - -```text -I UNDERSTAND PMEM GOAL CHANGES DESTROY DATA AND REQUIRE REBOOT +sudo /usr/local/bin/ipmctl show -a -dimm +sudo /usr/local/bin/ipmctl show -topology +sudo /usr/local/bin/ipmctl show -memoryresources +sudo /usr/local/bin/ipmctl show -a -goal ``` -There is no noninteractive bypass. The runner refuses existing namespaces, -pending goals, unsupported modes, partial or unknown socket targets, unhealthy -or unmanageable modules, and locked security state. It does not delete -namespaces, delete PCD, change firmware or security, or reboot. +Output is printed in labeled sections for a human to review. A hardware probe +failure is a warning distinct from a broken software installation. -When the requested whole-capacity mode is already active across every detected -PMem socket and no goal is pending, `goal-apply` is a no-op. It skips the -confirmation and mutation, then performs a read-only validation to refresh the -managed facts. - -Creating a goal can destroy App Direct data. Back up and separately -decommission namespaces before goal work. If a command partially fails, do not -repeat it blindly; inspect `/var/log/ipmctl/` and: - -```bash -sudo ipmctl show -a -goal -sudo ipmctl show -a -dimm -sudo ipmctl show -a -system -capabilities -sudo ipmctl show -a -region -sudo ndctl list -R -sudo ndctl list -N -``` - -After a successful non-no-op goal, reboot through the host's normal maintenance -process. The runner never reboots. Then rerun `ipmctl.sh validate` before -refreshing LLM host facts. - -## Flag reference - -| Flag | Behavior | +| Exit | Meaning | | --- | --- | -| `--profile=PROFILE` | Selects one reviewed source/platform profile. | -| `--repository-url=URL` | Exact credential-free ipmctl HTTPS Git URL. | -| `--release=TAG` | Exact reviewed ipmctl tag. | -| `--commit=SHA` | Exact lowercase 40-character ipmctl commit. | -| `--edk2-repository-url=URL` | Exact credential-free edk2 HTTPS Git URL. | -| `--edk2-release=TAG` | Exact reviewed edk2 tag. | -| `--edk2-commit=SHA` | Exact lowercase 40-character edk2 commit. | -| `--build-type=release\|debug` | Chooses an explicitly reviewed build type; no fallback occurs. | -| `--install-build-tools` | Opts `apply` into the `ipmctl_build` package transaction. | -| `--no-install-build-tools` | Forbids package installation. | -| `--goal=MODE` | Selects one supported whole-capacity goal. Goal modes only. | -| `--socket=all\|LIST` | Explicit socket target required by goal modes. In the first implementation, a numeric list must contain every detected PMem socket; partial-socket changes fail closed. | -| `--allow-destructive-goal-change` | Required intent flag for `goal-apply`; it does not bypass `/dev/tty` confirmation. | -| `--help` | Prints help without staging or changing the host. | - -## Facts and LLM host order - -This runner owns `/etc/ansible/debian/facts/ipmctl.yml`. Immutable command -evidence lives under `/var/log/ipmctl`, and install/goal transaction records -live under `/var/lib/ansible/debian/ipmctl/transactions`. - -The `icelake-pmem-dual-3090` LLM host profile requires these facts to show a -live, inventoried, settled Memory Mode configuration. Use this order: - -1. `ipmctl.sh apply` -2. idempotent second `ipmctl.sh apply` -3. `ipmctl.sh validate` -4. optional separately accepted `goal-plan` and `goal-apply` -5. maintenance reboot when a goal was created -6. `ipmctl.sh validate` -7. `setup/cli/llm/host.sh validate --require-ipmctl --require-memory-mode` - -GitHub Actions verifies source pins, parser fixtures, runner contracts, and the -Debian 13 source build. Hardware discovery and goal acceptance occur only on -the remote PMem host, never on a developer workstation. +| `0` | Software and all requested read-only probes passed. | +| `1` | Binary version, linkage, or another software check failed. | +| `2` | Software passed, but at least one hardware probe needs review. | +| `3` | Platform, privilege, staging, or another prerequisite blocked the run. | +| `64` | Invalid mode or option. | + +Only `install`, `verify`, and `--help` are accepted. PMem allocation changes +remain a manual maintenance operation outside this runner. + +## Remote acceptance + +Before merge, fetch the candidate commit into the intended Debian 13 amd64 +PMem-200 server and run from that checked-out repository. Do not substitute an +unpublished Pages URL for the reviewed candidate files. + +1. Capture `/etc/os-release`, architecture, kernel, GCC/G++, CMake, Python, and + the installed build-dependency versions for the pull-request evidence. +2. Run `bash setup/cli/ipmctl.sh install` once and retain the complete output. +3. Run `bash setup/cli/ipmctl.sh install` again and confirm it reports the + matching installation rather than rebuilding. +4. Run `bash setup/cli/ipmctl.sh verify` and retain all four labeled probe + sections. +5. Confirm the expected version, complete linkage, receipt and manifest, + detected DIMMs, topology, memory resources, and that any current or pending + goal is understood. +6. Only then run the LLM host validator with `--require-ipmctl` and, when + appropriate, `--require-memory-mode`. + +After review, merge, and `www` publication, fetch the published runner and run +`verify` again. Reinstall from the public URL only if the published content +differs from the accepted candidate or a reinstall is intentional. + +GitHub Actions checks the static runner, playbook, patch checksums, YAML, and +publication contract. It deliberately does not rebuild archived Intel source +or pretend to validate PMem hardware in a hosted runner. diff --git a/docs/cli/llm/host/readme.md b/docs/cli/llm/host/readme.md index 0c5d4b7..3101ba9 100644 --- a/docs/cli/llm/host/readme.md +++ b/docs/cli/llm/host/readme.md @@ -103,8 +103,8 @@ For a checked-out repository, use the same modes and flags directly: | `--allow-low-host-reserve` | Permits validation while current `MemAvailable` is below the requested reserve. Use only after reviewing active workloads. | | `--gpu-reserve-mib=N` | Per-device VRAM reservation exported for later runtimes. It does not allocate or test VRAM. Default: 4096 MiB. | | `--require-physical-cores=N` | Requires at least N physical cores and records one logical CPU from each core. | -| `--require-memory-mode` | Requires `verified` ipmctl evidence or `consistent` DMI persistent-memory evidence. Unknown evidence fails closed. | -| `--require-ipmctl` | Requires current schema-1 `/etc/ansible/debian/facts/ipmctl.yml`, a matching live binary, complete inventory, and matching fact/live evidence that no PMem goal is pending. | +| `--require-memory-mode` | Requires live `/usr/local/bin/ipmctl` evidence with positive Memory Mode capacity. DMI-only `consistent` evidence is informational and fails this hard requirement. Also enables `--require-ipmctl`. | +| `--require-ipmctl` | Requires live `/usr/local/bin/ipmctl` version `03.00.00.0538` and readable memory resources. Current/pending goal output is printed for human review but is not interpreted as a second inventory database. | | `--require-nvidia` | Requires schema-1 GPU/NVIDIA facts and matching live UUIDs, loaded driver, `nvidia-smi`, `nvcc`, and CUDA runtime headers. | | `--require-nvlink` | Also requires a current schema-2 NVLink fact with a physical pair, NVLink route, and positive link evidence. Requires `--require-nvidia`. | | `--require-p2p` | Also requires a completed passing directed CUDA P2P result. Requires `--require-nvlink`. | @@ -211,17 +211,18 @@ The runner writes: - `/opt/llm/bin/llm-host-numa` - `/opt/llm/bin/llm-host-env` -It consumes but never owns: +It checks `/usr/local/bin/ipmctl` directly when ipmctl is required. It consumes +but never owns these GPU producer facts: -- `/etc/ansible/debian/facts/ipmctl.yml` - `/etc/ansible/debian/facts/gpu.yml` - `/etc/ansible/debian/facts/nvidia.yml` - `/etc/ansible/debian/facts/nvlink.yml` If a PMem goal, driver, CUDA toolkit, kernel, GPU, NVLink bridge, or GPU ordering changes, refresh those producers before rerunning host validation. -After a PMem goal and maintenance reboot, run `ipmctl.sh validate` first. The -host gate rejects pending PMem goals and stale producer identity. +After a PMem goal and maintenance reboot, run `ipmctl.sh verify` first. The +host gate independently rejects an unexpected version or unreadable memory +resources and prints current/pending goal output for human review. Managed paths include `/opt/src`, `/opt/venvs`, `/opt/llm`, and the `/models` subtree. Missing directories are created for the selected owner. Existing @@ -231,12 +232,13 @@ ownership repair. ## Memory Mode classification -`verified` means live inventory reported positive Memory Mode capacity. -`consistent` means DMI records provide persistent-memory evidence but the -stronger query is unavailable. `unknown` makes no claim. The generic profile -can record `unknown`; `--require-memory-mode` rejects it. The exact Ice Lake -profile also requires source-managed ipmctl facts with positive PMem volatile -capacity, DDR cache capacity, and no pending goal. +`verified` means live `/usr/local/bin/ipmctl` inventory reported positive +Memory Mode capacity. `consistent` means DMI records provide +persistent-memory evidence but the stronger query is unavailable. `unknown` +makes no claim. The generic profile can record either weaker classification; +`--require-memory-mode` rejects both. The exact Ice Lake profile also requires +the reviewed live ipmctl version and readable memory resources. Goal output +remains a diagnostic reviewed during remote acceptance. PCIe or NVLink bandwidth is not hard-coded here. Link-rate evidence remains owned by the NVLink producer and is treated as positive/active evidence rather diff --git a/setup/cli/ipmctl.sh b/setup/cli/ipmctl.sh index 7d50b05..aa226b0 100755 --- a/setup/cli/ipmctl.sh +++ b/setup/cli/ipmctl.sh @@ -1,15 +1,15 @@ #!/usr/bin/env bash # Published path: https://devs-guide.github.io/debian/setup/cli/ipmctl.sh -# Pinned Intel Optane PMem inventory, source build, and guarded goal runner. -# -# wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh | \ -# bash -s -- preflight --profile=trixie-v03.00.00.0538 +# Pinned Debian 13 source installer and read-only Intel Optane PMem verifier. set -euo pipefail +readonly EXIT_SOFTWARE=1 +readonly EXIT_HARDWARE=2 readonly EXIT_BLOCKED=3 readonly EXIT_USAGE=64 -readonly GOAL_CONFIRMATION="I UNDERSTAND PMEM GOAL CHANGES DESTROY DATA AND REQUIRE REBOOT" +readonly IPMCTL_BIN=/usr/local/bin/ipmctl +readonly IPMCTL_VERSION=03.00.00.0538 log() { printf '[setup.cli.ipmctl] %s\n' "$*" >&2; } log.error() { printf '[setup.cli.ipmctl][error] %s\n' "$*" >&2; } @@ -27,195 +27,73 @@ PLAYBOOK_ROOT="" PACKAGE_PLAYBOOK_PATH="" FEATURE_PLAYBOOK_PATH="" EXTRA_VARS_PATH="" -PREFLIGHT_REPORT_PATH="" -GOAL_PLAN_RESULT_PATH="" -SOURCE_PROFILE_HELPER_PATH="" -SOURCE_MATRIX_PATH="" -STAGED_IPMCTL_SOURCE="" -STAGED_EDK2_SOURCE="" RUNNER_HELPER_PATH="" COMMON_HELPER_PATH="" RUNNER_LOCAL_REPO_ROOT="" +BUILD_USER="" +BUILD_HOME="" +BUILD_GROUP="" +FEATURE_MODE="${DEBIAN_IPMCTL_MODE:-install}" +SHOW_HELP=0 GROUP_VARS_FILES=("all.yml" "debian.yml") FEATURE_PLAYBOOKS=("install.packages.yml" "cli/ipmctl.yml") RUNTIME_SUPPORT_REFS=( "packages.yml" - "files/ipmctl/source-profile.py" - "files/ipmctl/ipmctl-inventory.py" - "files/ipmctl/compatibility-matrix.yml" + "files/ipmctl/apply-patch.yml" + "files/ipmctl/patches/README.md" + "files/ipmctl/patches/0001-edk2-stable202511-host-os-build.patch" + "files/ipmctl/patches/0002-ipmctl-disable-c-release-werror.patch" + "files/ipmctl/patches/0003-ipmctl-remove-pie-from-shared-linker-flags.patch" ) FEATURE_TEMPLATE_REFS=() declare -a FEATURE_GROUP_VARS_ARGS=() declare -a FEATURE_PLAYBOOK_PATHS=() -FEATURE_MODE="${DEBIAN_IPMCTL_MODE:-preflight}" -PROFILE="${DEBIAN_IPMCTL_PROFILE:-trixie-v03.00.00.0538}" -REPOSITORY_URL="${DEBIAN_IPMCTL_REPOSITORY_URL:-https://github.com/intel/ipmctl.git}" -RELEASE="${DEBIAN_IPMCTL_RELEASE:-v03.00.00.0538}" -COMMIT="${DEBIAN_IPMCTL_COMMIT:-a71f2fb1c90dd07f9862b71c789881132193e8f9}" -EDK2_REPOSITORY_URL="${DEBIAN_IPMCTL_EDK2_REPOSITORY_URL:-https://github.com/tianocore/edk2.git}" -EDK2_RELEASE="${DEBIAN_IPMCTL_EDK2_RELEASE:-edk2-stable202111}" -EDK2_COMMIT="${DEBIAN_IPMCTL_EDK2_COMMIT:-bb1bba3d776733c41dbfa2d1dc0fe234819a79f2}" -BUILD_TYPE="${DEBIAN_IPMCTL_BUILD_TYPE:-release}" -INSTALL_BUILD_TOOLS="${DEBIAN_IPMCTL_INSTALL_BUILD_TOOLS:-false}" -GOAL="${DEBIAN_IPMCTL_GOAL:-}" -SOCKET_TARGET="${DEBIAN_IPMCTL_SOCKET:-}" -ALLOW_DESTRUCTIVE_GOAL_CHANGE="${DEBIAN_IPMCTL_ALLOW_DESTRUCTIVE_GOAL_CHANGE:-false}" -GOAL_CONFIRMATION_AUTHORIZED=false -SHOW_HELP=0 - usage() { cat <<'EOF_USAGE' -Usage: ipmctl.sh [preflight|apply|validate|goal-plan|goal-apply] [options] +Usage: ipmctl.sh [install|verify] Modes: - preflight Unprivileged read-only policy and host report. - apply Build, install, inventory, and persist facts only. - validate Refresh privileged read-only inventory and facts. - goal-plan Print a privileged read-only PMem goal plan. - goal-apply Re-plan, confirm exactly, and create one goal. - -Options: - --profile=trixie-v03.00.00.0538 - --repository-url=HTTPS_GIT_URL - --release=TAG - --commit=FULL_40_CHARACTER_SHA - --edk2-repository-url=HTTPS_GIT_URL - --edk2-release=TAG - --edk2-commit=FULL_40_CHARACTER_SHA - --build-type=release|debug - --install-build-tools - --no-install-build-tools - --goal=memory-mode|app-direct|app-direct-not-interleaved - --socket=all|COMMA_SEPARATED_SOCKET_IDS - --allow-destructive-goal-change - --help - -Reviewed Debian 13 source install: - wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh | \ - bash -s -- apply \ - --profile=trixie-v03.00.00.0538 \ - --repository-url=https://github.com/intel/ipmctl.git \ - --release=v03.00.00.0538 \ - --commit=a71f2fb1c90dd07f9862b71c789881132193e8f9 \ - --edk2-repository-url=https://github.com/tianocore/edk2.git \ - --edk2-release=edk2-stable202111 \ - --edk2-commit=bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 \ - --build-type=release \ - --install-build-tools - -Destructive Memory Mode workflow: - wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh | \ - bash -s -- goal-plan \ - --profile=trixie-v03.00.00.0538 \ - --repository-url=https://github.com/intel/ipmctl.git \ - --release=v03.00.00.0538 \ - --commit=a71f2fb1c90dd07f9862b71c789881132193e8f9 \ - --edk2-repository-url=https://github.com/tianocore/edk2.git \ - --edk2-release=edk2-stable202111 \ - --edk2-commit=bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 \ - --build-type=release \ - --goal=memory-mode \ - --socket=all \ - --no-install-build-tools + install Build and install the reviewed Debian 13 source tuple, then verify. + verify Run software checks and four read-only PMem probes. - wget -qO- https://devs-guide.github.io/debian/setup/cli/ipmctl.sh | \ - bash -s -- goal-apply \ - --profile=trixie-v03.00.00.0538 \ - --repository-url=https://github.com/intel/ipmctl.git \ - --release=v03.00.00.0538 \ - --commit=a71f2fb1c90dd07f9862b71c789881132193e8f9 \ - --edk2-repository-url=https://github.com/tianocore/edk2.git \ - --edk2-release=edk2-stable202111 \ - --edk2-commit=bb1bba3d776733c41dbfa2d1dc0fe234819a79f2 \ - --build-type=release \ - --goal=memory-mode \ - --socket=all \ - --no-install-build-tools \ - --allow-destructive-goal-change - -goal-apply can destroy App Direct data and requires a reboot. It never deletes -namespaces or PCD, changes firmware/security, or reboots. There is no -noninteractive confirmation bypass. +The runner supports Debian 13 amd64 only. It never creates or deletes a PMem +goal, changes firmware or security state, formats a DIMM, manages namespaces, +or schedules a reboot. The installed ipmctl binary itself remains a powerful +administrative tool; destructive commands are manual and outside this runner. EOF_USAGE } parse.arguments() { - local first=1 argument="" - while (($#)); do - argument="$1" - shift - if [[ "${first}" -eq 1 && "${argument}" != --* ]]; then - FEATURE_MODE="${argument}" - first=0 - continue - fi - first=0 - case "${argument}" in - --help|-h) SHOW_HELP=1 ;; - --profile=*) PROFILE="${argument#*=}" ;; - --repository-url=*) REPOSITORY_URL="${argument#*=}" ;; - --release=*) RELEASE="${argument#*=}" ;; - --commit=*) COMMIT="${argument#*=}" ;; - --edk2-repository-url=*) EDK2_REPOSITORY_URL="${argument#*=}" ;; - --edk2-release=*) EDK2_RELEASE="${argument#*=}" ;; - --edk2-commit=*) EDK2_COMMIT="${argument#*=}" ;; - --build-type=*) BUILD_TYPE="${argument#*=}" ;; - --install-build-tools) INSTALL_BUILD_TOOLS=true ;; - --no-install-build-tools) INSTALL_BUILD_TOOLS=false ;; - --goal=*) GOAL="${argument#*=}" ;; - --socket=*) SOCKET_TARGET="${argument#*=}" ;; - --allow-destructive-goal-change) ALLOW_DESTRUCTIVE_GOAL_CHANGE=true ;; - --*) invalid "Unsupported option: ${argument}" ;; - *) invalid "Unexpected argument: ${argument}" ;; - esac - done -} - -validate.repository.url() { - local value="$1" label="$2" - [[ "${value}" =~ ^https://[A-Za-z0-9.-]+(/[A-Za-z0-9._+~-]+)+[.]git$ ]] || - invalid "${label} must be a credential-free HTTPS Git URL ending in .git." - [[ "${value}" != *"@"* && "${value}" != *"?"* && "${value}" != *"#"* ]] || - invalid "${label} cannot contain credentials, a query, or a fragment." + (($# <= 1)) || invalid "Only one mode is accepted." + case "${1:-${FEATURE_MODE}}" in + install|verify) FEATURE_MODE="${1:-${FEATURE_MODE}}" ;; + --help|-h) SHOW_HELP=1 ;; + --*) invalid "Unsupported option: ${1}" ;; + *) invalid "Unsupported mode: ${1}" ;; + esac } -validate.configuration() { - case "${FEATURE_MODE}" in preflight|apply|validate|goal-plan|goal-apply) ;; *) invalid "Unsupported mode: ${FEATURE_MODE}" ;; esac - [[ "${PROFILE}" =~ ^[A-Za-z0-9][A-Za-z0-9._+-]*$ ]] || invalid "Invalid profile." - [[ "${RELEASE}" =~ ^[A-Za-z0-9][A-Za-z0-9._+-]*$ ]] || invalid "Invalid release." - [[ "${EDK2_RELEASE}" =~ ^[A-Za-z0-9][A-Za-z0-9._+-]*$ ]] || invalid "Invalid edk2 release." - [[ "${COMMIT}" =~ ^[0-9a-f]{40}$ ]] || invalid "--commit must be a lowercase full 40-character SHA." - [[ "${EDK2_COMMIT}" =~ ^[0-9a-f]{40}$ ]] || invalid "--edk2-commit must be a lowercase full 40-character SHA." - validate.repository.url "${REPOSITORY_URL}" --repository-url - validate.repository.url "${EDK2_REPOSITORY_URL}" --edk2-repository-url - case "${BUILD_TYPE}" in release|debug) ;; *) invalid "--build-type must be release or debug." ;; esac - case "${INSTALL_BUILD_TOOLS}" in true|false) ;; *) invalid "Invalid build-tool policy." ;; esac - case "${ALLOW_DESTRUCTIVE_GOAL_CHANGE}" in true|false) ;; *) invalid "Invalid destructive-goal policy." ;; esac - if [[ "${FEATURE_MODE}" == goal-plan || "${FEATURE_MODE}" == goal-apply ]]; then - case "${GOAL}" in memory-mode|app-direct|app-direct-not-interleaved) ;; *) invalid "Goal modes require an explicit supported --goal." ;; esac - [[ "${SOCKET_TARGET}" == all || "${SOCKET_TARGET}" =~ ^[0-9]+(,[0-9]+)*$ ]] || - invalid "Goal modes require --socket=all or a comma-separated socket list." - elif [[ -n "${GOAL}" || -n "${SOCKET_TARGET}" || "${ALLOW_DESTRUCTIVE_GOAL_CHANGE}" == true ]]; then - invalid "Goal options are accepted only by goal-plan or goal-apply." - fi - if [[ "${FEATURE_MODE}" == goal-apply && "${ALLOW_DESTRUCTIVE_GOAL_CHANGE}" != true ]]; then - invalid "goal-apply requires --allow-destructive-goal-change." - fi - [[ "${FEATURE_MODE}" == apply || "${INSTALL_BUILD_TOOLS}" != true ]] || - invalid "--install-build-tools is accepted only by apply." +require.platform() { + local platform_id="" platform_version="" architecture="" + [[ -r /etc/os-release ]] || { log.error "Debian os-release metadata is unavailable."; return "${EXIT_BLOCKED}"; } + # shellcheck disable=SC1091 + source /etc/os-release + platform_id="${ID:-}" + platform_version="${VERSION_ID:-}" + architecture="$(dpkg --print-architecture 2>/dev/null || true)" + [[ "${platform_id}" == debian && "${platform_version}" == 13 && "${architecture}" == amd64 ]] || { + log.error "Supported platform is Debian 13 amd64; found ${platform_id:-unknown} ${platform_version:-unknown} ${architecture:-unknown}." + return "${EXIT_BLOCKED}" + } } configure.runtime.paths() { TMP_DIR="${RUNNER_RUNTIME_DIR}" PLAYBOOK_ROOT="${TMP_DIR}/runtime" EXTRA_VARS_PATH="${TMP_DIR}/cli.ipmctl.extra-vars.yml" - PREFLIGHT_REPORT_PATH="${TMP_DIR}/preflight.txt" - GOAL_PLAN_RESULT_PATH="${TMP_DIR}/goal-plan.result" COMMON_HELPER_PATH="${TMP_DIR}/${COMMON_HELPER_NAME}" - SOURCE_PROFILE_HELPER_PATH="${PLAYBOOK_ROOT}/files/ipmctl/source-profile.py" - SOURCE_MATRIX_PATH="${PLAYBOOK_ROOT}/files/ipmctl/compatibility-matrix.yml" } source.runner.common() { @@ -229,6 +107,7 @@ source.runner.common() { repo_root="$(cd "${script_dir}/../.." && pwd -P)" RUNNER_LOCAL_REPO_ROOT="${repo_root}" RUNNER_HELPER_PATH="$(cd "$(dirname "${local_helper}")" && pwd)/$(basename "${local_helper}")" + # shellcheck source=setup/runner.common.sh source "${RUNNER_HELPER_PATH}" runner.create.runtime ipmctl "${RUNNER_TMP_PARENT}" configure.runtime.paths @@ -236,14 +115,17 @@ source.runner.common() { fi ;; esac + command -v wget >/dev/null 2>&1 || { log.error "wget is required."; exit "${EXIT_BLOCKED}"; } bootstrap_dir="$(mktemp -d "${RUNNER_TMP_PARENT%/}/devs-guide-ipmctl.XXXXXX")" chmod 0700 "${bootstrap_dir}" RUNNER_HELPER_PATH="${bootstrap_dir}/${RUNNER_HELPER_NAME}" - log "Fetching shared runner helper: ${RUNNER_HELPER_URL}" - wget -qO "${RUNNER_HELPER_PATH}" "${RUNNER_HELPER_URL}" && [[ -s "${RUNNER_HELPER_PATH}" ]] || - { log.error "Failed to fetch ${RUNNER_HELPER_URL}"; exit "${EXIT_BLOCKED}"; } + if ! wget -qO "${RUNNER_HELPER_PATH}" "${RUNNER_HELPER_URL}" || [[ ! -s "${RUNNER_HELPER_PATH}" ]]; then + log.error "Failed to fetch ${RUNNER_HELPER_URL}." + exit "${EXIT_BLOCKED}" + fi bash -n "${RUNNER_HELPER_PATH}" || { log.error "Downloaded runner helper is invalid."; exit "${EXIT_BLOCKED}"; } + # shellcheck disable=SC1090 source "${RUNNER_HELPER_PATH}" runner.adopt.runtime ipmctl "${bootstrap_dir}" configure.runtime.paths @@ -252,57 +134,45 @@ source.runner.common() { source.release.common() { local local_setup_root="" [[ -z "${RUNNER_LOCAL_REPO_ROOT}" ]] || local_setup_root="${RUNNER_LOCAL_REPO_ROOT}/setup" - runner.source.release.common "${local_setup_root}" "${PAGES_BASE_URL}/setup" "${TMP_DIR}" "${COMMON_HELPER_NAME}" || - { log.error "Unable to stage the shared release helper."; exit "${EXIT_BLOCKED}"; } + runner.source.release.common "${local_setup_root}" "${PAGES_BASE_URL}/setup" "${TMP_DIR}" "${COMMON_HELPER_NAME}" || { + log.error "Unable to stage the shared release helper." + exit "${EXIT_BLOCKED}" + } } prepare.feature.files() { local local_ansible_root="" [[ -z "${RUNNER_LOCAL_REPO_ROOT}" ]] || local_ansible_root="${RUNNER_LOCAL_REPO_ROOT}/ansible" - runner.prepare.ansible.feature "${local_ansible_root}" "${PAGES_BASE_URL}/ansible" "${PLAYBOOK_ROOT}" || - { log.error "Unable to stage the ipmctl feature."; exit "${EXIT_BLOCKED}"; } + runner.prepare.ansible.feature "${local_ansible_root}" "${PAGES_BASE_URL}/ansible" "${PLAYBOOK_ROOT}" || { + log.error "Unable to stage the ipmctl feature." + exit "${EXIT_BLOCKED}" + } PACKAGE_PLAYBOOK_PATH="${FEATURE_PLAYBOOK_PATHS[0]}" FEATURE_PLAYBOOK_PATH="${FEATURE_PLAYBOOK_PATHS[1]}" } -validate.reviewed.source() { - python3 "${SOURCE_PROFILE_HELPER_PATH}" \ - --matrix "${SOURCE_MATRIX_PATH}" \ - --profile "${PROFILE}" \ - --repository-url "${REPOSITORY_URL}" \ - --release "${RELEASE}" \ - --commit "${COMMIT}" \ - --edk2-repository-url "${EDK2_REPOSITORY_URL}" \ - --edk2-release "${EDK2_RELEASE}" \ - --edk2-commit "${EDK2_COMMIT}" >/dev/null || - { log.error "The requested ipmctl/edk2 source tuple is not reviewed."; exit "${EXIT_BLOCKED}"; } -} - -stage.one.source() { - local destination="$1" repository="$2" release="$3" commit="$4" label="$5" resolved="" - git init -q "${destination}" - git -C "${destination}" remote add origin "${repository}" - log "Fetching reviewed ${label} tag ${release} as the invoking user." - git -C "${destination}" fetch -q --depth=1 origin "refs/tags/${release}:refs/tags/${release}" - resolved="$(git -C "${destination}" rev-list -n 1 "refs/tags/${release}")" - [[ "${resolved}" == "${commit}" ]] || - { log.error "${label} tag ${release} resolves to ${resolved}, not ${commit}."; exit "${EXIT_BLOCKED}"; } - git -C "${destination}" -c advice.detachedHead=false checkout -q --detach "${commit}" - [[ -z "$(git -C "${destination}" status --porcelain)" ]] || - { log.error "Staged ${label} source is unexpectedly dirty."; exit "${EXIT_BLOCKED}"; } -} - -stage.reviewed.sources() { - command -v git >/dev/null 2>&1 || { log.error "git is required to stage reviewed source."; exit "${EXIT_BLOCKED}"; } - STAGED_IPMCTL_SOURCE="${TMP_DIR}/upstream/ipmctl" - STAGED_EDK2_SOURCE="${TMP_DIR}/upstream/edk2" - mkdir -p "${TMP_DIR}/upstream" - stage.one.source "${STAGED_IPMCTL_SOURCE}" "${REPOSITORY_URL}" "${RELEASE}" "${COMMIT}" ipmctl - stage.one.source "${STAGED_EDK2_SOURCE}" "${EDK2_REPOSITORY_URL}" "${EDK2_RELEASE}" "${EDK2_COMMIT}" edk2 +resolve.build.identity() { + local passwd_record="" + if [[ "${EUID:-$(id -u)}" -eq 0 ]]; then + BUILD_USER="${SUDO_USER:-}" + [[ -n "${BUILD_USER}" && "${BUILD_USER}" != root ]] || { + log.error "Run install as a non-root user with sudo access; a direct root invocation is not accepted." + return "${EXIT_BLOCKED}" + } + else + BUILD_USER="$(id -un)" + fi + BUILD_GROUP="$(id -gn "${BUILD_USER}" 2>/dev/null || true)" + passwd_record="$(getent passwd "${BUILD_USER}" 2>/dev/null || true)" + BUILD_HOME="$(printf '%s\n' "${passwd_record}" | cut -d: -f6)" + [[ "${BUILD_USER}" =~ ^[a-z_][a-z0-9_-]*[$]?$ && "${BUILD_GROUP}" =~ ^[a-z_][a-z0-9_-]*[$]?$ && "${BUILD_HOME}" == /* && -d "${BUILD_HOME}" ]] || { + log.error "Unable to resolve a safe build user and home directory." + return "${EXIT_BLOCKED}" + } } write.extra.vars.file() { - cat > "${EXTRA_VARS_PATH}" <"${EXTRA_VARS_PATH}" < "${PREFLIGHT_REPORT_PATH}" - runner.report.text "${PREFLIGHT_REPORT_PATH}" "Managed ipmctl facts" /etc/ansible/debian/facts/ipmctl.yml - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Debian release" sed -n '1,20p' /etc/os-release - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Installed ipmctl binary" sh -c 'command -v ipmctl && ipmctl version' - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Debian ipmctl package policy" apt-cache policy ipmctl - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Intel Optane PMem modules" ipmctl show -a -dimm - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Intel Optane PMem topology" ipmctl show -topology - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Persistent-memory resources" ipmctl show -u B -memoryresources - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Persistent-memory regions" ipmctl show -a -region - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Persistent-memory capabilities" ipmctl show -a -system -capabilities - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Pending persistent-memory goal" ipmctl show -a -goal - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Linux persistent-memory devices" ndctl list -D - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Linux persistent-memory regions" ndctl list -R - runner.report.command "${PREFLIGHT_REPORT_PATH}" "Linux persistent-memory namespaces" ndctl list -N - printf '\n## Reviewed source policy\nprofile=%s\nipmctl=%s %s %s\nedk2=%s %s %s\nbuild_type=%s\n' \ - "${PROFILE}" "${REPOSITORY_URL}" "${RELEASE}" "${COMMIT}" \ - "${EDK2_REPOSITORY_URL}" "${EDK2_RELEASE}" "${EDK2_COMMIT}" "${BUILD_TYPE}" | - tee -a "${PREFLIGHT_REPORT_PATH}" - log "Preflight is read-only: no source was cloned, package installed, fact written, or PMem goal changed." -} - -run.package.playbook() { - runner.run.ansible.playbooks "${EXTRA_VARS_PATH}" "${PACKAGE_PLAYBOOK_PATH}" +software.verify() { + local version_output="" version_token="" linkage_output="" + [[ -x "${IPMCTL_BIN}" ]] || { log.error "Reviewed binary is unavailable: ${IPMCTL_BIN}"; return "${EXIT_SOFTWARE}"; } + if ! version_output="$(${IPMCTL_BIN} version 2>&1)"; then + log.error "ipmctl version failed: ${version_output}" + return "${EXIT_SOFTWARE}" + fi + version_token="$(printf '%s\n' "${version_output}" | grep -Eo '[0-9]{2}[.][0-9]{2}[.][0-9]{2}[.][0-9]{4}' | head -n1 || true)" + [[ "${version_token}" == "${IPMCTL_VERSION}" ]] || { + log.error "Expected ipmctl ${IPMCTL_VERSION}; observed ${version_token:-unknown}." + return "${EXIT_SOFTWARE}" + } + if ! linkage_output="$(ldd "${IPMCTL_BIN}" 2>&1)"; then + log.error "Unable to inspect ipmctl runtime linkage: ${linkage_output}" + return "${EXIT_SOFTWARE}" + fi + [[ "${linkage_output}" != *"not found"* ]] || { + log.error "ipmctl has unresolved runtime linkage." + printf '%s\n' "${linkage_output}" >&2 + return "${EXIT_SOFTWARE}" + } + printf '[PASS] software version=%s binary=%s\n' "${version_token}" "${IPMCTL_BIN}" + printf '%s\n' "${linkage_output}" } -run.feature.playbook() { - runner.run.ansible.playbooks "${EXTRA_VARS_PATH}" "${FEATURE_PLAYBOOK_PATH}" +hardware.probe() { + local id="$1" label="$2" output_path="" error_path="" status=0 + shift 2 + output_path="${RUNNER_RUNTIME_DIR}/${id}.stdout" + error_path="${RUNNER_RUNTIME_DIR}/${id}.stderr" + if runner.run.as.root "${IPMCTL_BIN}" "$@" >"${output_path}" 2>"${error_path}"; then + status=0 + else + status=$? + fi + printf '\n## %s\n' "${label}" + [[ ! -s "${output_path}" ]] || sed -n '1,320p' "${output_path}" + [[ ! -s "${error_path}" ]] || sed -n '1,160p' "${error_path}" >&2 + if [[ "${status}" -eq 0 ]]; then + if [[ ! -s "${output_path}" ]]; then + printf '[WARN] %s returned no output\n' "${label}" >&2 + return 1 + fi + printf '[PASS] %s\n' "${label}" + else + printf '[WARN] %s (exit=%s)\n' "${label}" "${status}" >&2 + fi + return "${status}" } -ensure.local.ansible.as.root() { - runner.ensure.local.ansible +run.verify() { + local hardware_warning=0 + local dimms_result=WARN topology_result=WARN memoryresources_result=WARN goal_result=WARN + software.verify || return "${EXIT_SOFTWARE}" + runner.ensure.privileged.session || return "${EXIT_BLOCKED}" + if hardware.probe dimms "PMem DIMMs" show -a -dimm; then dimms_result=PASS; else hardware_warning=1; fi + if hardware.probe topology "PMem topology" show -topology; then topology_result=PASS; else hardware_warning=1; fi + if hardware.probe memoryresources "PMem memory resources" show -memoryresources; then memoryresources_result=PASS; else hardware_warning=1; fi + if hardware.probe goal "PMem current or pending goal" show -a -goal; then goal_result=PASS; else hardware_warning=1; fi + printf '\n%-24s | %-6s | %s\n' Probe Result Meaning + printf '%-24s-+-%-6s-+-%s\n' '------------------------' '------' '---------------------------------------------' + printf '%-24s | %-6s | %s\n' 'version/linkage' PASS 'CLI installation health' + printf '%-24s | %-6s | %s\n' DIMMs "${dimms_result}" 'module discovery' + printf '%-24s | %-6s | %s\n' topology "${topology_result}" 'platform topology/PMTT visibility' + printf '%-24s | %-6s | %s\n' 'memory resources' "${memoryresources_result}" 'current volatile/App Direct allocation' + printf '%-24s | %-6s | %s\n' 'current/pending goal' "${goal_result}" 'read-only goal report' + if [[ "${hardware_warning}" -ne 0 ]]; then + log "Software is installed, but one or more hardware probes require human review." + return "${EXIT_HARDWARE}" + fi + log "Software and all read-only hardware probes passed." } -run.managed.mode() { - runner.ensure.privileged.session || exit "${EXIT_BLOCKED}" - [[ -x "${ANSIBLE_VENV_BIN}" ]] || ensure.local.ansible.as.root - if [[ "${FEATURE_MODE}" == apply && "${INSTALL_BUILD_TOOLS}" == true ]]; then - write.extra.vars.file - log "Installing the opt-in ipmctl source-build package group." - run.package.playbook - fi - if [[ "${FEATURE_MODE}" == apply ]]; then - stage.reviewed.sources - fi - if [[ "${FEATURE_MODE}" == goal-apply ]]; then - FEATURE_MODE=goal-plan - write.extra.vars.file - run.feature.playbook - if grep -Fxq 'no_op=true' "${GOAL_PLAN_RESULT_PATH}"; then - log "Requested PMem mode is already active and settled; refreshing facts without confirmation or mutation." - FEATURE_MODE=validate - write.extra.vars.file - run.feature.playbook - return 0 - fi - runner.confirm.exact \ - "The displayed ipmctl goal can destroy App Direct data and requires a BIOS reboot to apply. No namespace, PCD, firmware, security, or reboot operation will be performed automatically." \ - "${GOAL_CONFIRMATION}" - GOAL_CONFIRMATION_AUTHORIZED=true - FEATURE_MODE=goal-apply - fi +run.install() { + resolve.build.identity + source.release.common + prepare.feature.files + runner.ensure.privileged.session || return "${EXIT_BLOCKED}" + [[ -x "${ANSIBLE_VENV_BIN}" ]] || runner.ensure.local.ansible write.extra.vars.file - run.feature.playbook + log "Installing the reviewed ipmctl build dependency group." + runner.run.ansible.playbooks "${EXTRA_VARS_PATH}" "${PACKAGE_PLAYBOOK_PATH}" + log "Building and installing the pinned ipmctl source tuple." + runner.run.ansible.playbooks "${EXTRA_VARS_PATH}" "${FEATURE_PLAYBOOK_PATH}" + run.verify } main() { parse.arguments "$@" [[ "${SHOW_HELP}" -eq 0 ]] || { usage; return 0; } - validate.configuration + require.platform source.runner.common - source.release.common - require.debian - prepare.feature.files - validate.reviewed.source - if [[ "${FEATURE_MODE}" == preflight ]]; then - run.read.only.preflight + if [[ "${FEATURE_MODE}" == install ]]; then + run.install else - run.managed.mode + run.verify fi } diff --git a/setup/cli/llm/host.sh b/setup/cli/llm/host.sh index af2c0d9..1edbab4 100755 --- a/setup/cli/llm/host.sh +++ b/setup/cli/llm/host.sh @@ -291,15 +291,14 @@ run.read.only.preflight() { runner.report.text "${PREFLIGHT_REPORT_PATH}" "Shared GPU facts" /etc/ansible/debian/facts/gpu.yml runner.report.text "${PREFLIGHT_REPORT_PATH}" "NVIDIA readiness facts" /etc/ansible/debian/facts/nvidia.yml runner.report.text "${PREFLIGHT_REPORT_PATH}" "NVLink readiness facts" /etc/ansible/debian/facts/nvlink.yml - runner.report.text "${PREFLIGHT_REPORT_PATH}" "ipmctl readiness facts" /etc/ansible/debian/facts/ipmctl.yml + report.command "Reviewed ipmctl version" /usr/local/bin/ipmctl version report.command "CPU summary" lscpu report.command "CPU topology" lscpu --parse=CPU,SOCKET,CORE,ONLINE,NODE report.command "Host memory" sed -n '1,24p' /proc/meminfo report.command "NUMA topology" numactl --hardware report.command "NVIDIA runtime inventory" nvidia-smi --query-gpu=index,name,uuid,pci.bus_id,memory.total,driver_version,compute_cap --format=csv,noheader - report.command "Persistent-memory resources" ipmctl show -memoryresources - report.command "Persistent-memory system capabilities" ipmctl show -a -system -capabilities - report.command "Pending persistent-memory goal" ipmctl show -a -goal + report.command "Persistent-memory resources" /usr/local/bin/ipmctl show -memoryresources + report.command "Pending persistent-memory goal" /usr/local/bin/ipmctl show -a -goal log "Preflight is read-only: it did not install packages, create directories, write facts, download models, or alter kernel, CPU, memory, swap, NVIDIA, or boot policy." }