diff --git a/tests/tailor-images/README.md b/tests/tailor-images/README.md index f3f8f0b382..69c5c17f89 100644 --- a/tests/tailor-images/README.md +++ b/tests/tailor-images/README.md @@ -49,6 +49,10 @@ remote source. The current families are: - `azl-installer` +- `azurelinux-direct-streaming-testimage` +- `foreign-direct-streaming-testimage` +- `trident-container-installer` +- `trident-container-testimage` - `trident-functest` - `trident-installer` - `trident-testimage` diff --git a/tests/tailor-images/azurelinux-direct-streaming-testimage/by-arch/arm64.yaml b/tests/tailor-images/azurelinux-direct-streaming-testimage/by-arch/arm64.yaml new file mode 100644 index 0000000000..7ff2d78da3 --- /dev/null +++ b/tests/tailor-images/azurelinux-direct-streaming-testimage/by-arch/arm64.yaml @@ -0,0 +1,2 @@ +base: + $include: ../common/matrix/base-core-arm64.yaml diff --git a/tests/tailor-images/azurelinux-direct-streaming-testimage/image.yaml b/tests/tailor-images/azurelinux-direct-streaming-testimage/image.yaml new file mode 100644 index 0000000000..5249abc246 --- /dev/null +++ b/tests/tailor-images/azurelinux-direct-streaming-testimage/image.yaml @@ -0,0 +1,20 @@ +name: azurelinux-direct-streaming-testimage + +matrix: + arch: [amd64, arm64] + +base: + ref: baremetal + +outputs: + - format: baremetal-image + +rpmSources: + - ../../../bin/RPMS + - ../../../artifacts/rpm-overrides + +extraDependencies: + - ../common + +config: + $include: ./tailor/baseimg.yaml diff --git a/tests/tailor-images/azurelinux-direct-streaming-testimage/tailor/baseimg.yaml b/tests/tailor-images/azurelinux-direct-streaming-testimage/tailor/baseimg.yaml new file mode 100644 index 0000000000..a6af1726ae --- /dev/null +++ b/tests/tailor-images/azurelinux-direct-streaming-testimage/tailor/baseimg.yaml @@ -0,0 +1,68 @@ +storage: + bootType: efi + disks: + - partitionTableType: gpt + maxSize: 15G + partitions: + - id: esp + type: esp + size: 50M + label: esp + - id: root-a + size: 4G + type: root + label: root-a + - id: root-b + size: 4G + type: root + label: root-b + - id: swap + size: 2G + type: swap + label: swap + filesystems: + - deviceId: esp + type: fat32 + mountPoint: + path: /boot/efi + options: umask=0077 + - deviceId: root-a + type: ext4 + mountPoint: + path: / +os: + bootloader: + resetType: hard-reset + hostname: trident-rawcosi-testimage + selinux: + mode: permissive + kernelCommandLine: + extraCommandLine: + - console=tty0 + - console=ttyS0 + - rd.info + - log_buf_len=1M + packages: + install: + - curl + - dnf + - efibootmgr + - iproute + - iptables + - lsof + - mdadm + - netplan + - openssh-server + - tpm2-tools + - vim + - audit + - device-mapper + - dosfstools + - lvm2 + - veritysetup + - ntfs-3g + - ntfsprogs + - selinux-policy + services: + enable: + - sshd diff --git a/tests/tailor-images/foreign-direct-streaming-testimage/by-arch+source/arm64+ubuntu-2204.yaml b/tests/tailor-images/foreign-direct-streaming-testimage/by-arch+source/arm64+ubuntu-2204.yaml new file mode 100644 index 0000000000..42a5d73548 --- /dev/null +++ b/tests/tailor-images/foreign-direct-streaming-testimage/by-arch+source/arm64+ubuntu-2204.yaml @@ -0,0 +1,7 @@ +base: + $set: + ref: ubuntu_2204_arm64 + +outputs: + $replace: + - format: baremetal-image diff --git a/tests/tailor-images/foreign-direct-streaming-testimage/by-arch+source/arm64+ubuntu-2404.yaml b/tests/tailor-images/foreign-direct-streaming-testimage/by-arch+source/arm64+ubuntu-2404.yaml new file mode 100644 index 0000000000..19c7d4ce27 --- /dev/null +++ b/tests/tailor-images/foreign-direct-streaming-testimage/by-arch+source/arm64+ubuntu-2404.yaml @@ -0,0 +1,7 @@ +base: + $set: + ref: ubuntu_2404_arm64 + +outputs: + $replace: + - format: baremetal-image diff --git a/tests/tailor-images/foreign-direct-streaming-testimage/by-source/gb200-2404.yaml b/tests/tailor-images/foreign-direct-streaming-testimage/by-source/gb200-2404.yaml new file mode 100644 index 0000000000..274d1a2b3e --- /dev/null +++ b/tests/tailor-images/foreign-direct-streaming-testimage/by-source/gb200-2404.yaml @@ -0,0 +1,7 @@ +base: + $set: + ref: gb200_2404_arm64 + +outputs: + $replace: + - format: baremetal-image diff --git a/tests/tailor-images/foreign-direct-streaming-testimage/by-source/ubuntu-2404.yaml b/tests/tailor-images/foreign-direct-streaming-testimage/by-source/ubuntu-2404.yaml new file mode 100644 index 0000000000..888cdf330e --- /dev/null +++ b/tests/tailor-images/foreign-direct-streaming-testimage/by-source/ubuntu-2404.yaml @@ -0,0 +1,7 @@ +base: + $set: + ref: ubuntu_2404_amd64 + +outputs: + $replace: + - format: baremetal-image diff --git a/tests/tailor-images/foreign-direct-streaming-testimage/image.yaml b/tests/tailor-images/foreign-direct-streaming-testimage/image.yaml new file mode 100644 index 0000000000..3d006bffb6 --- /dev/null +++ b/tests/tailor-images/foreign-direct-streaming-testimage/image.yaml @@ -0,0 +1,16 @@ +name: foreign-direct-streaming-testimage +operation: convert + +matrix: + arch: [amd64, arm64] + source: [ubuntu-2204, ubuntu-2404, gb200-2404] + +selectors: + exclude: + - { arch: amd64, source: gb200-2404 } + +base: + ref: ubuntu_2204_amd64 + +outputs: + - format: baremetal-image diff --git a/tests/tailor-images/tailor.yaml b/tests/tailor-images/tailor.yaml index 20bb35f413..419aad4e68 100644 --- a/tests/tailor-images/tailor.yaml +++ b/tests/tailor-images/tailor.yaml @@ -65,6 +65,10 @@ baseImages: images: members: - azl-installer + - azurelinux-direct-streaming-testimage + - foreign-direct-streaming-testimage + - trident-container-installer + - trident-container-testimage - trident-functest - trident-installer - trident-testimage diff --git a/tests/tailor-images/trident-container-installer/README.md b/tests/tailor-images/trident-container-installer/README.md new file mode 100644 index 0000000000..ab32274c66 --- /dev/null +++ b/tests/tailor-images/trident-container-installer/README.md @@ -0,0 +1,21 @@ +# Trident Container Installer ISO Test Image + +This image is used in the Trident test pipelines. At startup, it loads a +specified version of a container, which must be provided. Trident runs from +this container. The configuration for Trident can be patched into the ISO by +replacing it with the placeholder file (config-placeholder). + +This image does **not** include Trident RPMs — Trident is loaded from a +container at boot. + +## Building + +From the repo root, run: + +```bash +cargo run --manifest-path tools/tailor/Cargo.toml -- --manifest tests/tailor-images/tailor.yaml build trident-container-installer --output-dir ./artifacts +``` + +Output is written to `artifacts/trident-container-installer_amd64_iso.iso` by default +(tailor publishes under the cell's slug). +Use `--output-dir ` to change the output location. diff --git a/tests/tailor-images/trident-container-installer/base/files/root.profile b/tests/tailor-images/trident-container-installer/base/files/root.profile new file mode 100644 index 0000000000..14baf5c9e2 --- /dev/null +++ b/tests/tailor-images/trident-container-installer/base/files/root.profile @@ -0,0 +1,2 @@ +# Open journalctl immediately after autologin +journalctl -f --no-tail -u trident-container \ No newline at end of file diff --git a/tests/tailor-images/trident-container-installer/base/files/trident-container.service b/tests/tailor-images/trident-container-installer/base/files/trident-container.service new file mode 100644 index 0000000000..2c93c93962 --- /dev/null +++ b/tests/tailor-images/trident-container-installer/base/files/trident-container.service @@ -0,0 +1,16 @@ +[Unit] +Description=Trident Agent +Requires=docker.service +After=network.target network-online.target systemd-udev-settle.service docker.service + +[Service] +Type=oneshot +ExecStartPre=/bin/bash -c "set -e; mkdir -p /var/lib/trident" +ExecStartPre=/bin/bash -c "set -e; if ! docker image ls | grep -q 'trident/trident'; then curl $(grep -oP '^\s*phonehome: \\K.*(?=phonehome)' /etc/trident/config.yaml)files/trident-container.tar.gz -o /var/lib/trident/trident-container.tar.gz -f; fi" +ExecStartPre=/bin/bash -c "set -e; if ! docker image ls | grep -q 'trident/trident'; then docker load --input /var/lib/trident/trident-container.tar.gz; fi" +ExecStart=docker run --name trident_container --pull=never --rm --privileged -v /etc/trident:/etc/trident -v /etc/pki:/etc/pki:ro -v /run/initramfs/live:/trident_cdrom -v /var/lib/trident:/var/lib/trident -v /var/log:/var/log -v /:/host -v /dev:/dev -v /run:/run -v /sys:/sys --pid host --ipc host trident/trident:latest install --verbosity TRACE +StandardOutput=journal+console +StandardError=journal+console + +[Install] +WantedBy=multi-user.target diff --git a/tests/tailor-images/trident-container-installer/base/scripts/load-containerd-selinux-fix.sh b/tests/tailor-images/trident-container-installer/base/scripts/load-containerd-selinux-fix.sh new file mode 100755 index 0000000000..f908b04698 --- /dev/null +++ b/tests/tailor-images/trident-container-installer/base/scripts/load-containerd-selinux-fix.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Load SELinux policy module that grants the 'map' permission on +# container_runtime_t:file for container engines. This fixes containerd +# 2.2+ MountManager bbolt mmap() denials under enforcing mode. +semodule -i /usr/share/selinux/packages/containerd-mmap-fix.cil diff --git a/tests/tailor-images/trident-container-installer/base/scripts/post-install.sh b/tests/tailor-images/trident-container-installer/base/scripts/post-install.sh new file mode 100755 index 0000000000..5b2f4f7ca8 --- /dev/null +++ b/tests/tailor-images/trident-container-installer/base/scripts/post-install.sh @@ -0,0 +1,15 @@ +# Add the necessary directories for the audit logs so that auditd can start +mkdir -p /var/log/audit +# Use more intuitive path for the ISO mount +ln -s -T /run/initramfs/live /trident_cdrom + +# Load the config from the CDROM so that the user can patch it +if [ ! -d /etc/trident ]; then + mkdir /etc/trident +fi +ln -s -T /trident_cdrom/trident-config.yaml /etc/trident/config.yaml + +if [ ! -d /etc/systemd/system/trident-container.service.d ]; then + mkdir /etc/systemd/system/trident-container.service.d +fi +ln -s -T /trident_cdrom/trident-override.conf /etc/systemd/system/trident-container.service.d/override.conf \ No newline at end of file diff --git a/tests/tailor-images/trident-container-installer/image.yaml b/tests/tailor-images/trident-container-installer/image.yaml new file mode 100644 index 0000000000..46126e9637 --- /dev/null +++ b/tests/tailor-images/trident-container-installer/image.yaml @@ -0,0 +1,14 @@ +name: trident-container-installer + +base: + ref: baremetal + +outputs: + - format: iso + +extraDependencies: + - ./base + - ../common + +config: + $include: ./tailor/baseimg.yaml diff --git a/tests/tailor-images/trident-container-installer/tailor/baseimg.yaml b/tests/tailor-images/trident-container-installer/tailor/baseimg.yaml new file mode 100644 index 0000000000..926fc52269 --- /dev/null +++ b/tests/tailor-images/trident-container-installer/tailor/baseimg.yaml @@ -0,0 +1,71 @@ +storage: + bootType: efi + disks: + - partitionTableType: gpt + maxSize: 4G + partitions: + - id: esp + type: esp + size: 8M + - id: rootfs + size: grow + filesystems: + - deviceId: esp + type: fat32 + mountPoint: + path: /boot/efi + options: umask=0077 + - deviceId: rootfs + type: ext4 + mountPoint: + path: / +os: + bootloader: + resetType: hard-reset + hostname: trident-container-mos-testimg + packages: + install: + - curl + - device-mapper + - dnf + - docker-cli + - iproute + - iptables + - mdadm + - moby-engine + - openssh-server + - selinux-policy + - squashfs-tools + - tar + - vim + additionalFiles: + - source: ../common/files/getty@.service + destination: /usr/lib/systemd/system/getty@.service + - source: ../common/files/serial-getty@.service + destination: /usr/lib/systemd/system/serial-getty@.service + - source: base/files/root.profile + destination: /root/.profile + - source: base/files/trident-container.service + destination: /usr/lib/systemd/system/trident-container.service + - source: ../common/files/containerd-mmap-fix.cil + destination: /usr/share/selinux/packages/containerd-mmap-fix.cil + services: + enable: + - trident-container + - sshd +scripts: + postCustomization: + - path: base/scripts/post-install.sh + - path: base/scripts/load-containerd-selinux-fix.sh +iso: + additionalFiles: + - source: ../common/files/config-placeholder.yaml + destination: /trident-config.yaml + - source: ../common/files/override-placeholder.conf + destination: /trident-override.conf + kernelCommandLine: + extraCommandLine: + - enforcing=0 + - console=tty0 + - console=ttyS0 + - rd.luks=0 diff --git a/tests/tailor-images/trident-container-testimage/README.md b/tests/tailor-images/trident-container-testimage/README.md new file mode 100644 index 0000000000..619c7da2ee --- /dev/null +++ b/tests/tailor-images/trident-container-testimage/README.md @@ -0,0 +1,20 @@ +# Trident Container Test Image + +This image is an extension of the base baremetal image and includes various +helper utilities along with Docker runtime. It also adds openssh-server to +allow for remote access. + +This image does **not** include Trident RPMs — Trident runs from a container +loaded at runtime. + +## Building + +From the repo root, run: + +```bash +cargo run --manifest-path tools/tailor/Cargo.toml -- --manifest tests/tailor-images/tailor.yaml build trident-container-testimage --output-dir ./artifacts +``` + +Output is written to `artifacts/trident-container-testimage_amd64_cosi.cosi` by default +(tailor publishes under the cell's slug). +Use `--output-dir ` to change the output location. diff --git a/tests/tailor-images/trident-container-testimage/base/files/trident-container.service b/tests/tailor-images/trident-container-testimage/base/files/trident-container.service new file mode 100644 index 0000000000..bba22a9650 --- /dev/null +++ b/tests/tailor-images/trident-container-testimage/base/files/trident-container.service @@ -0,0 +1,16 @@ +[Unit] +Description=Trident Agent +Requires=docker.service +After=network.target network-online.target systemd-udev-settle.service docker.service + +[Service] +Type=oneshot +ExecStartPre=/bin/bash -c "set -e; if ! docker image ls | grep -q 'trident/trident'; then docker load --input /var/lib/trident/trident-container.tar.gz; fi" +# TODO: Remove line to enable SELinux, when bug #9508 is fixed. +ExecStartPre=/bin/bash -c "sudo setenforce 0" +ExecStart=docker run --name trident_container --pull=never --rm --privileged -v /etc/trident:/etc/trident -v /var/lib/trident:/var/lib/trident -v /var/log:/var/log -v /:/host -v /dev:/dev -v /run:/run -v /sys:/sys --pid host --ipc host trident/trident:latest commit --verbosity DEBUG +StandardOutput=journal+console +StandardError=journal+console + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/tests/tailor-images/trident-container-testimage/base/scripts/load-containerd-selinux-fix.sh b/tests/tailor-images/trident-container-testimage/base/scripts/load-containerd-selinux-fix.sh new file mode 100755 index 0000000000..f908b04698 --- /dev/null +++ b/tests/tailor-images/trident-container-testimage/base/scripts/load-containerd-selinux-fix.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Load SELinux policy module that grants the 'map' permission on +# container_runtime_t:file for container engines. This fixes containerd +# 2.2+ MountManager bbolt mmap() denials under enforcing mode. +semodule -i /usr/share/selinux/packages/containerd-mmap-fix.cil diff --git a/tests/tailor-images/trident-container-testimage/base/scripts/post-install.sh b/tests/tailor-images/trident-container-testimage/base/scripts/post-install.sh new file mode 100755 index 0000000000..79da025b3b --- /dev/null +++ b/tests/tailor-images/trident-container-testimage/base/scripts/post-install.sh @@ -0,0 +1,2 @@ +# Add the necessary directories for the audit logs so that auditd can start +mkdir -p /var/log/audit diff --git a/tests/tailor-images/trident-container-testimage/image.yaml b/tests/tailor-images/trident-container-testimage/image.yaml new file mode 100644 index 0000000000..8f08e93d1f --- /dev/null +++ b/tests/tailor-images/trident-container-testimage/image.yaml @@ -0,0 +1,14 @@ +name: trident-container-testimage + +base: + ref: baremetal + +outputs: + - format: cosi + +extraDependencies: + - ./base + - ../common + +config: + $include: ./tailor/baseimg.yaml diff --git a/tests/tailor-images/trident-container-testimage/tailor/baseimg.yaml b/tests/tailor-images/trident-container-testimage/tailor/baseimg.yaml new file mode 100644 index 0000000000..8eb64082e2 --- /dev/null +++ b/tests/tailor-images/trident-container-testimage/tailor/baseimg.yaml @@ -0,0 +1,71 @@ +storage: + bootType: efi + disks: + - partitionTableType: gpt + maxSize: 4G + partitions: + - id: esp + type: esp + size: 8M + - id: rootfs + size: grow + filesystems: + - deviceId: esp + type: fat32 + mountPoint: + path: /boot/efi + options: umask=0077 + - deviceId: rootfs + type: ext4 + mountPoint: + path: / +os: + bootloader: + resetType: hard-reset + hostname: trident-container-testimg + kernelCommandLine: + extraCommandLine: + - console=tty0 + - console=ttyS0 + - rd.info + - log_buf_len=1M + packages: + remove: + - grub2-efi-binary + install: + - grub2-efi-binary-noprefix + - curl + - dnf + - efibootmgr + - iproute + - iptables + - lsof + - mdadm + - netplan + - openssh-server + - tpm2-tools + - vim + - device-mapper + - dosfstools + - lvm2 + - veritysetup + - ntfs-3g + - ntfsprogs + - docker-cli + - moby-engine + - selinux-policy + - squashfs-tools + - tar + additionalFiles: + - source: base/files/trident-container.service + destination: /usr/lib/systemd/system/trident-container.service + - source: ../common/files/containerd-mmap-fix.cil + destination: /usr/share/selinux/packages/containerd-mmap-fix.cil + services: + enable: + - trident-container + - sshd +scripts: + postCustomization: + - path: base/scripts/post-install.sh + - path: base/scripts/load-containerd-selinux-fix.sh