Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/tailor-images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ for now and is removed in a follow-up cleanup PR.
Use the in-tree tailor binary via Cargo:

```bash
cargo run --manifest-path tools/tailor/Cargo.toml -- --manifest tests/tailor-images/tailor.yaml matrix trident-testimage --format json
cargo run --manifest-path tools/tailor/Cargo.toml -- --manifest tests/tailor-images/tailor.yaml matrix trident-installer --format json
```

Build examples:
Expand All @@ -20,6 +20,9 @@ cargo run --manifest-path tools/tailor/Cargo.toml -- --manifest tests/tailor-i

# trident-testimage-arm64
cargo run --manifest-path tools/tailor/Cargo.toml -- --manifest tests/tailor-images/tailor.yaml build trident-testimage -s arch=arm64 --output-dir ./artifacts

# trident-direct-streaming-installer-arm64
cargo run --manifest-path tools/tailor/Cargo.toml -- --manifest tests/tailor-images/tailor.yaml build trident-installer -s arch=arm64 -s variant=direct-streaming --output-dir ./artifacts
```

## Base images
Expand All @@ -45,5 +48,7 @@ remote source.

The current families are:

- `azl-installer`
- `trident-functest`
- `trident-installer`
- `trident-testimage`
20 changes: 20 additions & 0 deletions tests/tailor-images/azl-installer/image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: azl-installer

base:
ref: baremetal

outputs:
- format: iso

rpmSources:
- ../../../bin/RPMS
- ../../../artifacts/rpm-overrides

extraDependencies:
- ./installer-iso.yaml
- ./mos
- ./iso
- ../common

config:
$include: ./installer-iso.yaml
95 changes: 95 additions & 0 deletions tests/tailor-images/azl-installer/installer-iso.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
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:
hostname: azl-installer
bootloader:
resetType: hard-reset

selinux:
mode: disabled

kernelCommandLine:
extraCommandLine:
- console=tty0
- console=ttyS0
- rd.info
- log_buf_len=1M

packages:
install:
- curl
- device-mapper
- dnf
- dosfstools
- efibootmgr
- iproute
- iptables
- jq
- lsof
- mdadm
- nano
- netplan
- openssh-server
- squashfs-tools
- tar
- tpm2-tools
- trident-provisioning
- vim
- veritysetup
# Accessibility packages
- pcaudiolib

additionalFiles:
# Getty service files for root autologin
- 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: mos/scripts/installation.sh
destination: /root/installer/installation.sh

iso:
initramfsType: full-os

additionalFiles:
- source: iso/images/trident-testimage.cosi
destination: /images/azure-linux-core.cosi
- source: iso/bin/liveinstaller
destination: /installer/liveinstaller
- source: iso/files/config-placeholder.yaml
destination: /installer/trident-config.yaml.tmpl

kernelCommandLine:
extraCommandLine:
- console=tty0
- console=tty1
- console=ttyS0
- loglevel=6

scripts:
postCustomization:
- path: mos/scripts/startup-command.sh
2 changes: 2 additions & 0 deletions tests/tailor-images/azl-installer/iso/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/images/
/bin/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#8505c8ab802dd717290331acd0592804c4e413b030150c53f5018ac998b7831d:/installer/trident-config.yaml.tmpl:##############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
51 changes: 51 additions & 0 deletions tests/tailor-images/azl-installer/mos/scripts/installation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
set -ex
trap '/bin/bash' ERR

CDROM_MOUNT="/mnt/cdrom"
WORKING_DIR="/root/installer"
MAGIC_PLACEHOLDER="8505c8ab802dd717290331acd0592804c4e413b030150c53f5018ac998b7831d"

# Mount CD-ROM using symlink
mkdir -p "$CDROM_MOUNT"
mount /dev/cdrom "$CDROM_MOUNT"

# CD-ROM paths
LIVEINSTALLER_PATH="$CDROM_MOUNT/installer/liveinstaller"
POSSIBLE_HC_TEMPLATE="$CDROM_MOUNT/installer/trident-config.yaml.tmpl"
IMAGES_DIR="$CDROM_MOUNT/images/"

# WORKING_DIR paths
LIVEINSTALLER_BIN="$WORKING_DIR/liveinstaller"
TRIDENT_CONFIG_DESTINATION="/etc/trident/config.yaml"
LOG_FILE="$WORKING_DIR/liveinstaller.log"
OUTPUT_LOG="$WORKING_DIR/output_liveinstaller.log"

# Copy to WORKING_DIR to execute liveinstaller
cp "$LIVEINSTALLER_PATH" "$LIVEINSTALLER_BIN"

# Check if placeholder magic string is present (ISO not patched)
if grep -q "^#${MAGIC_PLACEHOLDER}:" "$POSSIBLE_HC_TEMPLATE"; then
# Placeholder found - execute attended installation (interactive UI)
cd "$WORKING_DIR"
"$LIVEINSTALLER_BIN" \
--images-dir="$IMAGES_DIR" \
--host-config-output="$TRIDENT_CONFIG_DESTINATION" \
--log-level=trace \
--log-file="$LOG_FILE" 2>&1 | tee "$OUTPUT_LOG"
else
# Placeholder was replaced by a Host Configuration - execute unattended installation
echo "Pre-configured Host Configuration found. Starting unattended installation..."
# Save template in WORKING_DIR in case of failure
TEMPLATE_FILE="$WORKING_DIR/template.yaml"
cp "$POSSIBLE_HC_TEMPLATE" "$TEMPLATE_FILE"
# Execute liveinstaller (unattended)
cd "$WORKING_DIR"
"$LIVEINSTALLER_BIN" \
--unattended \
--template-file="$TEMPLATE_FILE" \
--log-level=trace \
--log-file="$LOG_FILE" 2>&1 | tee "$OUTPUT_LOG"
fi

/bin/bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
INSTALLATION="/root/installer/installation.sh"
chmod +x "$INSTALLATION"

chsh -s "$INSTALLATION" root
2 changes: 2 additions & 0 deletions tests/tailor-images/tailor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ baseImages:

images:
members:
- azl-installer
- trident-functest
- trident-installer
- trident-testimage
19 changes: 19 additions & 0 deletions tests/tailor-images/trident-installer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Trident Installer ISO Test Image

This image is used by the Trident test pipelines. It contains a copy of Trident that launches at
startup and reads a configuration that can be patched into the ISO.

## Building

From the repo root, run:

```bash
cargo run --manifest-path tools/tailor/Cargo.toml -- --manifest tests/tailor-images/tailor.yaml build trident-installer -s arch=amd64 -s variant=default --output-dir ./artifacts
```

Other legacy variants map to selectors on the same family:

- `trident-split-installer` → `-s arch=amd64 -s variant=split`
- `trident-direct-streaming-installer-amd64` → `-s arch=amd64 -s variant=direct-streaming`
- `trident-installer-arm64` → `-s arch=arm64 -s variant=default`
- `trident-direct-streaming-installer-arm64` → `-s arch=arm64 -s variant=direct-streaming`

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Add short alias to see trident's logs
alias tridentlog="journalctl -u trident -u trident-network"

# Open journalctl immediately after autologin
journalctl -f --no-tail -u trident -u trident-network
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Trident Install Service
After=network.target network-online.target systemd-udev-settle.service

[Service]
ExecStart=trident install --verbosity DEBUG
Type=oneshot

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Trident Install Service
After=network.target network-online.target systemd-udev-settle.service

[Service]
ExecStart=echo stage
ExecStart=trident install --verbosity DEBUG --allowed-operations stage
ExecStart=echo finalize
ExecStart=trident install --verbosity DEBUG --allowed-operations finalize
Type=oneshot

[Install]
WantedBy=multi-user.target
31 changes: 31 additions & 0 deletions tests/tailor-images/trident-installer/base/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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 -p /etc/trident
fi

if [ "$1" != "stream-image-test" ]; then
ln -s -T /trident_cdrom/trident-config.yaml /etc/trident/config.yaml

if [ ! -d /etc/systemd/system/trident-install.service.d ]; then
mkdir -p /etc/systemd/system/trident-install.service.d
fi
ln -s -T /trident_cdrom/trident-override.conf /etc/systemd/system/trident-install.service.d/override.conf
else
# The stream image test purposefully does not have /etc/trident/config.yaml, so remove
# this condition from the systemd service to avoid it failing to start
sed -i 's|ConditionPathExists=/etc/trident/config.yaml||' /usr/lib/systemd/system/trident-install.service
fi

# Ensure /etc/rcp-agent/ exists
if [ ! -d /etc/rcp-agent ]; then
mkdir -p /etc/rcp-agent
fi

# Link rcp-agent config from the ISO
ln -s -T /trident_cdrom/rcp-agent.yaml /etc/rcp-agent/config.yaml
6 changes: 6 additions & 0 deletions tests/tailor-images/trident-installer/by-arch/arm64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
base:
$include: ../common/matrix/base-core-arm64.yaml

outputs:
$replace:
- format: iso
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
outputs:
$replace:
- format: iso

config:
os:
hostname:
$set: trident-direct-streaming-mos-testimage
packages:
update:
- systemd
install:
$remove:
- trident-static-pcrlock-files
- selinux-policy
- audit
$append:
- setools-console
- trident-selinux
- trident-install-service
services:
enable:
$remove:
- trident-install
$append:
- rcp-agent
disable:
- trident-install
additionalFiles:
$remove:
- source: base/files/trident-install.service
destination: /usr/lib/systemd/system/trident-install.service
$append:
- source: ../../../artifacts/rcp-agent
destination: /usr/bin/rcp-agent
- source: ../../../artifacts/rcp-agent.service
destination: /usr/lib/systemd/system/rcp-agent.service
scripts:
postCustomization:
$replace:
- path: base/post-install.sh
arguments:
- stream-image-test
iso:
additionalFiles:
$replace:
- source: base/files/pre-trident-script.sh
destination: /pre-trident-script.sh
- source: base/files/rcp-agent.yaml
destination: /rcp-agent.yaml
kernelCommandLine:
extraCommandLine:
$append:
- selinux=1

extraDependencies:
- ../../../artifacts/rcp-agent
- ../../../artifacts/rcp-agent.service
Loading
Loading