diff --git a/.pipelines/pipeline-tester.yml b/.pipelines/pipeline-tester.yml index d7c558582..2d9fa31c4 100644 --- a/.pipelines/pipeline-tester.yml +++ b/.pipelines/pipeline-tester.yml @@ -62,11 +62,6 @@ resources: name: platform-pipelines ref: refs/heads/main - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - - repository: platform-telemetry name: platform-telemetry type: git diff --git a/.pipelines/templates/e2e-template.yml b/.pipelines/templates/e2e-template.yml index 52248b10c..6c041711f 100644 --- a/.pipelines/templates/e2e-template.yml +++ b/.pipelines/templates/e2e-template.yml @@ -241,8 +241,9 @@ stages: # Run CodeQL for this in CI only runCodeql: true - # dom0 is failing for not known reasons ... comment out for now to unblock, longterm this may - # be removed from Trident pipelines alltogether in favor of being only test-images + # dom0 is failing for not known reasons ... comment out for now to unblock. + # If this stage is re-enabled later, update the disabled template first to finish + # the migration away from the old test-images repository references. # - ${{ if or(eq(parameters.stageType, 'ci'), eq(parameters.stageType, 'pr-e2e')) }}: # # Build Trident test image (dom0: mshv+ch) # - template: stages/build_image/trident-mshvch-dom0-testimg.yml diff --git a/.pipelines/templates/stages/build_image/build-image-template.yml b/.pipelines/templates/stages/build_image/build-image-template.yml index c82df4a7b..5bfde5a8a 100644 --- a/.pipelines/templates/stages/build_image/build-image-template.yml +++ b/.pipelines/templates/stages/build_image/build-image-template.yml @@ -1,4 +1,3 @@ -# TODO: Migrate test images to Trident repository and build them locally #16117 parameters: - name: tridentSourceDirectory type: string @@ -69,7 +68,9 @@ steps: set -eux if which tdnf; then - sudo tdnf install -y veritysetup + # nss-tools provides certutil while pesign provides efikeygen & pesign, + # which are required for producing a signed image to enable SecureBoot + sudo tdnf install -y veritysetup nss-tools pesign sudo systemctl start docker else # Ubuntu is used for building and testing of VM images suitable for @@ -140,8 +141,8 @@ steps: # Move Trident RPMs to bin/RPMS/ (builder expects bin/RPMS/*.rpm) if [ -d "$(Build.ArtifactStagingDirectory)/trident" ]; then - mkdir -p bin/RPMS/x86_64 - mv "$(Build.ArtifactStagingDirectory)/trident"/*.rpm bin/RPMS/x86_64/ + mkdir -p bin/RPMS + find "$(Build.ArtifactStagingDirectory)/trident" -name '*.rpm' -exec mv {} bin/RPMS/ \; rm -rf "$(Build.ArtifactStagingDirectory)/trident" fi displayName: "Prepare and move requirements" diff --git a/.pipelines/templates/stages/build_image/build-image.yml b/.pipelines/templates/stages/build_image/build-image.yml index d02b3d4fc..873a74d03 100644 --- a/.pipelines/templates/stages/build_image/build-image.yml +++ b/.pipelines/templates/stages/build_image/build-image.yml @@ -77,13 +77,14 @@ stages: parameters: tridentSourceDirectory: $(TRIDENT_SOURCE_DIR) - - template: .pipelines/templates/build-image.yml@test-images + - template: ../build_image/build-image-template.yml parameters: + tridentSourceDirectory: $(TRIDENT_SOURCE_DIR) imageName: ${{ parameters.imageName }} - clones: ${{ parameters.clones }} baseimgBuildType: $(BASEIMG_BUILD_TYPE) baseimgVersion: $(BASEIMG_VERSION) rpmsVersion: $(RPMS_VERSION) azureLinuxVersion: ${{ variables.BASEIMG_AZURE_LINUX_VERSION }} micBuildType: ${{ parameters.micBuildType }} micVersion: ${{ parameters.micVersion }} + clones: ${{ parameters.clones }} diff --git a/.pipelines/testing-trident.yml b/.pipelines/testing-trident.yml index a9d9c7f57..cd2bb0838 100644 --- a/.pipelines/testing-trident.yml +++ b/.pipelines/testing-trident.yml @@ -79,11 +79,6 @@ variables: resources: repositories: - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - - repository: platform-tests type: git name: platform-tests diff --git a/.pipelines/trident-ci.yml b/.pipelines/trident-ci.yml index f03dc65a5..2a3fa00ab 100644 --- a/.pipelines/trident-ci.yml +++ b/.pipelines/trident-ci.yml @@ -25,28 +25,6 @@ resources: type: git name: platform-tests - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - trigger: - batch: true - branches: - include: - - main - paths: - include: - - Makefile - - testimages.py - - builder/** - - platform-integration-images/** - - .pipelines/**/*trident* - exclude: - - platform-integration-images/mshvch-testimage/** - - platform-integration-images/k8s-testimage/** - - platform-integration-images/qemu-guest-testimage/** - - platform-integration-images/remote-qemu-guest-k8s-testimage/** - - repository: platform-pipelines type: git name: platform-pipelines diff --git a/.pipelines/trident-cicd-for-prism.yml b/.pipelines/trident-cicd-for-prism.yml index 6806bd09f..21bbfe387 100644 --- a/.pipelines/trident-cicd-for-prism.yml +++ b/.pipelines/trident-cicd-for-prism.yml @@ -40,11 +40,6 @@ resources: name: platform-pipelines ref: refs/heads/main - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - - repository: platform-telemetry name: platform-telemetry type: git diff --git a/.pipelines/trident-cicd.yml b/.pipelines/trident-cicd.yml index afeb4a0b4..e0e7ace9a 100644 --- a/.pipelines/trident-cicd.yml +++ b/.pipelines/trident-cicd.yml @@ -40,11 +40,6 @@ resources: name: platform-pipelines ref: refs/heads/main - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - - repository: platform-telemetry name: platform-telemetry type: git diff --git a/.pipelines/trident-full-validation.yml b/.pipelines/trident-full-validation.yml index e39d6633d..cfa3b792d 100644 --- a/.pipelines/trident-full-validation.yml +++ b/.pipelines/trident-full-validation.yml @@ -41,11 +41,6 @@ resources: name: platform-pipelines ref: refs/heads/main - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - - repository: platform-telemetry name: platform-telemetry type: git diff --git a/.pipelines/trident-pr-e2e-azure.yml b/.pipelines/trident-pr-e2e-azure.yml index b9638f8e3..30d486ba9 100644 --- a/.pipelines/trident-pr-e2e-azure.yml +++ b/.pipelines/trident-pr-e2e-azure.yml @@ -26,11 +26,6 @@ resources: type: git name: platform-tests - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - - repository: platform-pipelines type: git name: platform-pipelines diff --git a/.pipelines/trident-pr-e2e.yml b/.pipelines/trident-pr-e2e.yml index e8f2b20b4..88bc160cf 100644 --- a/.pipelines/trident-pr-e2e.yml +++ b/.pipelines/trident-pr-e2e.yml @@ -16,11 +16,6 @@ resources: type: git name: platform-tests - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - - repository: platform-pipelines type: git name: platform-pipelines diff --git a/.pipelines/trident-prerelease.yml b/.pipelines/trident-prerelease.yml index 429ba7e2f..08ddfc334 100644 --- a/.pipelines/trident-prerelease.yml +++ b/.pipelines/trident-prerelease.yml @@ -43,11 +43,6 @@ resources: name: platform-pipelines ref: refs/heads/main - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - - repository: platform-telemetry name: platform-telemetry type: git diff --git a/.pipelines/trident-scale-official.yml b/.pipelines/trident-scale-official.yml index f44a9bc96..23ca091e8 100644 --- a/.pipelines/trident-scale-official.yml +++ b/.pipelines/trident-scale-official.yml @@ -96,11 +96,6 @@ resources: name: platform-pipelines ref: refs/heads/main - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - - repository: platform-telemetry name: platform-telemetry type: git diff --git a/.pipelines/trident-scale.yml b/.pipelines/trident-scale.yml index e083e8a98..c1bb1e2f1 100644 --- a/.pipelines/trident-scale.yml +++ b/.pipelines/trident-scale.yml @@ -71,11 +71,6 @@ resources: name: platform-pipelines ref: refs/heads/main - - repository: test-images - type: git - name: test-images - ref: refs/heads/main - - repository: platform-telemetry name: platform-telemetry type: git diff --git a/tests/images/builder/builder.py b/tests/images/builder/builder.py index 77a8b0a78..3c066d021 100644 --- a/tests/images/builder/builder.py +++ b/tests/images/builder/builder.py @@ -443,7 +443,6 @@ def build_signed_image( sign.sign_boot_artifacts( ca_nss_key_db, leaf_key_name, - image.get_items_to_sign(), inject_files_yaml_path, output_artifacts_dir, ) diff --git a/tests/images/builder/sign.py b/tests/images/builder/sign.py index a1370a173..0045feef8 100644 --- a/tests/images/builder/sign.py +++ b/tests/images/builder/sign.py @@ -6,7 +6,7 @@ import threading from pathlib import Path -from typing import List +from typing import Optional from builder.context_managers import temp_dir @@ -38,6 +38,39 @@ IC_ARTIFACT_NAME_SYSTEMD_BOOT = "systemd-boot" IC_ARTIFACT_NAME_VERITY_HASH = "verity-hash" +_KERNEL_FLAG_SUPPORTED = None +_PESIGN_CERT_ARG = None + + +def _efikeygen_supports_kernel_flag() -> bool: + global _KERNEL_FLAG_SUPPORTED + + if _KERNEL_FLAG_SUPPORTED is None: + result = subprocess.run( + ["efikeygen", "--help"], capture_output=True, text=True, check=False + ) + help_output = f"{result.stdout}\n{result.stderr}" + _KERNEL_FLAG_SUPPORTED = "--kernel" in help_output + log.debug(f"efikeygen --kernel support: {_KERNEL_FLAG_SUPPORTED}") + + return _KERNEL_FLAG_SUPPORTED + + +def _get_pesign_certificate_arg() -> str: + global _PESIGN_CERT_ARG + + if _PESIGN_CERT_ARG is None: + result = subprocess.run( + ["pesign", "--help"], capture_output=True, text=True, check=False + ) + help_output = f"{result.stdout}\n{result.stderr}" + _PESIGN_CERT_ARG = ( + "--certficate" if "--certficate" in help_output else "--certificate" + ) + log.debug(f"Using pesign certificate argument: {_PESIGN_CERT_ARG}") + + return _PESIGN_CERT_ARG + def generate_ca_certificate(tmp_dir: Path): """ @@ -99,22 +132,23 @@ def generate_leaf_certificate(ca_nss_key_db: Path, id: str): # Generate unique leaf key name leaf_key_name = f"{KEY_NAME}_{id}" + cmd = [ + "efikeygen", + "-n", + leaf_key_name, + "-c", + f"CN={KEY_CN} {id}", + "--signer", + CA_NAME, + "-d", + str(ca_nss_key_db), + ] + + if _efikeygen_supports_kernel_flag(): + cmd.append("--kernel") + # Generate signing key/cert, signed by CA in the shared DB - subprocess.run( - [ - "efikeygen", - "-n", - leaf_key_name, - "-c", - f"CN={KEY_CN} {id}", - "--signer", - CA_NAME, - "-d", - str(ca_nss_key_db), - "--kernel", - ], - check=True, - ) + subprocess.run(cmd, check=True) log.debug( f"Process with PID {threading.get_ident()} generated leaf key {leaf_key_name} in {ca_nss_key_db}" @@ -173,7 +207,6 @@ def publish_ca_certificate(ca_nss_key_db: Path, output_dir: Path): def sign_boot_artifacts( ca_nss_key_db: Path, leaf_key_name: str, - items_to_sign: List[str], inject_files_yaml_path: Path, output_artifacts_dir: Path, ): @@ -183,105 +216,71 @@ def sign_boot_artifacts( Args: ca_nss_key_db: Path to the NSS key database for the CA certificate leaf_key_name: Name of the leaf certificate - items_to_sign: List of items to sign inject_files_yaml_path: Full path to inject-files.yaml output_artifacts_dir: Dir where artifacts are output by Image Customizer """ - # Print contents of inject_files_yaml_path with open(inject_files_yaml_path, "r") as f: data = f.read() log.debug(f"Contents of {inject_files_yaml_path}:\n{data}") inject_files_config = yaml.safe_load(data) - # Map artifact types to file-matching regex - item_regex = { - IC_ARTIFACT_NAME_UKIS: r"vmlinuz.*\.efi", - IC_ARTIFACT_NAME_SHIM: r"bootx64\.efi", - IC_ARTIFACT_NAME_SYSTEMD_BOOT: r"systemd-bootx64\.efi", - IC_ARTIFACT_NAME_VERITY_HASH: r".*hash.*", - } - - # Print items to sign - log.debug(f"Items to sign: {items_to_sign}") - - # Handle signing for each item that requires it - for item in items_to_sign: - regex = item_regex.get(item) - if not regex: - continue - - # Find unsigned and signed artifact filepaths matching this regex - unsigned_artifact_path = get_artifact_path( - inject_files_config, output_artifacts_dir, regex, False + for entry in inject_files_config.get("injectFiles", []): + artifact_type = entry.get("type", "") + signed_path_str = entry.get("source") + unsigned_path_str = entry.get("unsignedSource", "") + + if not signed_path_str: + raise RuntimeError(f"Missing source in inject-files entry: {entry}") + + if not unsigned_path_str: + # MIC v1.1+ uses the same path for unsigned and signed files. + unsigned_path_str = signed_path_str + + signed_rel_path = ( + signed_path_str[2:] if signed_path_str.startswith("./") else signed_path_str ) - signed_artifact_path = get_artifact_path( - inject_files_config, output_artifacts_dir, regex, True + unsigned_rel_path = ( + unsigned_path_str[2:] + if unsigned_path_str.startswith("./") + else unsigned_path_str ) + signed_path = output_artifacts_dir.absolute() / signed_rel_path + unsigned_path = output_artifacts_dir.absolute() / unsigned_rel_path - # Create parent directory of signed artifact if it doesn't exist - signed_artifact_path.parent.mkdir(parents=True, exist_ok=True) - signed_artifact_path.parent.chmod(0o700) + if not artifact_type: + artifact_type = get_artifact_type_from_name(unsigned_path.name) - # Specify if item is verity-hash since it requires a different signing logic - if item == IC_ARTIFACT_NAME_VERITY_HASH: - log.info( - f"Signing verity hash file {unsigned_artifact_path} to {signed_artifact_path}" - ) + log.info( + f"Signing file of type '{artifact_type}' at {unsigned_path} to {signed_path}" + ) + if artifact_type == IC_ARTIFACT_NAME_VERITY_HASH: sign_verity_hash( ca_nss_key_db, leaf_key_name, - unsigned_artifact_path, - signed_artifact_path, + unsigned_path, + signed_path, ) else: - log.info( - f"Signing {item} file {unsigned_artifact_path} to {signed_artifact_path}" - ) sign_pe_artifact( ca_nss_key_db, leaf_key_name, - unsigned_artifact_path, - signed_artifact_path, + unsigned_path, + signed_path, ) -def get_artifact_path( - inject_files_config: dict, - output_artifacts_dir: Path, - file_regex: str, - signed: bool, -) -> Path: - """ - Loads inject-files.yaml, searches each entry for a field matching the regex, - and returns the normalized full path to the artifact. - - Args: - inject_files_config: Dictionary loaded from the YAML file - output_artifacts_dir: Directory where artifacts are stored - file_regex: Regex to match artifact file names - signed: If True, returns the signed artifact path, i.e. "source"; otherwise, returns the - unsigned artifact path, i.e. "unsignedSource" - - Returns: - Full artifact path as string if found. +def get_artifact_type_from_name(name: str) -> Optional[str]: + if re.match(r"vmlinuz.*\.efi", name): + return IC_ARTIFACT_NAME_UKIS + if re.match(r"bootx64\.efi", name): + return IC_ARTIFACT_NAME_SHIM + if re.match(r"systemd-bootx64\.efi", name): + return IC_ARTIFACT_NAME_SYSTEMD_BOOT + if re.match(r".*hash.*", name): + return IC_ARTIFACT_NAME_VERITY_HASH - Raises: - Exception: RuntimeError if artifact not found. - """ - pattern = re.compile(file_regex) - - for entry in inject_files_config.get("injectFiles", []): - if signed: - source_type = "source" - else: - source_type = "unsignedSource" - source_name = entry.get(source_type, "") - if pattern.fullmatch(os.path.basename(source_name)): - rel_path = source_name[2:] if source_name.startswith("./") else source_name - return output_artifacts_dir.absolute() / rel_path - - raise RuntimeError(f"No matching entry found for pattern '{file_regex}'") + return None def sign_verity_hash( @@ -302,16 +301,31 @@ def sign_verity_hash( Raises: Exception: If pesign fails. """ - # Create parent directory of signed artifact if it doesn't exist + log.debug( + f"Process with PID {threading.get_ident()} is signing {unsigned_verity_hash_path}" + ) signed_verity_hash_path.parent.mkdir(parents=True, exist_ok=True) signed_verity_hash_path.parent.chmod(0o700) - with temp_dir() as tmpdir: - # Sign the verity hash file + with temp_dir(sudo=True) as tmpdir: + tmp_signed_artifact = ( + tmpdir + / f"{unsigned_verity_hash_path.stem}.signed{unsigned_verity_hash_path.suffix}" + ) + tmp_unsigned_artifact = ( + tmpdir + / f"{unsigned_verity_hash_path.stem}.unsigned{unsigned_verity_hash_path.suffix}" + ) key_path = tmpdir / "key.p12" key_crt_path = tmpdir / "key.crt" - # Export PKCS12 key + + subprocess.run( + ["sudo", "cp", str(unsigned_verity_hash_path), str(tmp_unsigned_artifact)], + check=True, + ) + + log.debug(f"Exporting PKCS12 key to {key_path}") subprocess.run( [ "pk12util", @@ -326,7 +340,8 @@ def sign_verity_hash( ], check=True, ) - # Extract cert + + log.debug(f"Extracting cert from PKCS12 key to {key_crt_path}") subprocess.run( [ "openssl", @@ -343,7 +358,9 @@ def sign_verity_hash( check=True, ) - # smime sign + log.debug( + f"Signing verity hash file at {tmp_unsigned_artifact} using openssl smime" + ) subprocess.run( [ "openssl", @@ -352,7 +369,7 @@ def sign_verity_hash( "-noattr", "-binary", "-in", - str(unsigned_verity_hash_path), + str(tmp_unsigned_artifact), "-signer", str(key_crt_path), "-passin", @@ -360,26 +377,38 @@ def sign_verity_hash( "-outform", "der", "-out", - str(signed_verity_hash_path), + str(tmp_signed_artifact), ], check=True, ) - # Print certs for debug/validation as in bash + try: + result = subprocess.run( + [ + "openssl", + "pkcs7", + "-inform", + "DER", + "-in", + str(tmp_signed_artifact), + "-print_certs", + "-text", + ], + check=True, + capture_output=True, + text=True, + ) + log.debug(f"Certs for {unsigned_verity_hash_path}:\n{result.stdout}") + except subprocess.CalledProcessError as e: + log.error(f"Failed to print certs for {unsigned_verity_hash_path}: {e}") + subprocess.run( - [ - "openssl", - "pkcs7", - "-inform", - "DER", - "-in", - str(signed_verity_hash_path), - "-print_certs", - "-text", - ], + ["sudo", "cp", str(tmp_signed_artifact), str(signed_verity_hash_path)], check=True, ) + log.debug(f"Signed verity-hash artifact generated at {signed_verity_hash_path}") + def sign_pe_artifact( ca_nss_key_db: Path, @@ -403,21 +432,43 @@ def sign_pe_artifact( f"Process with PID {threading.get_ident()} is signing {unsigned_artifact_path} to {signed_artifact_path}" ) - # Sign as a PE binary - subprocess.run( - [ - "pesign", - "--certdir", - str(ca_nss_key_db), - "--certificate", - leaf_key_name, - "--sign", - "--in", - str(unsigned_artifact_path), - "--out", - str(signed_artifact_path), - "--force", - ], - check=True, - ) + with temp_dir(sudo=True) as tmpdir: + tmp_signed_artifact = ( + tmpdir + / f"{unsigned_artifact_path.stem}.signed{unsigned_artifact_path.suffix}" + ) + tmp_unsigned_artifact = ( + tmpdir + / f"{unsigned_artifact_path.stem}.unsigned{unsigned_artifact_path.suffix}" + ) + + subprocess.run( + ["sudo", "cp", str(unsigned_artifact_path), str(tmp_unsigned_artifact)], + check=True, + ) + + cert_arg = _get_pesign_certificate_arg() + + subprocess.run( + [ + "pesign", + "--certdir", + str(ca_nss_key_db), + cert_arg, + leaf_key_name, + "--sign", + "--in", + str(tmp_unsigned_artifact), + "--out", + str(tmp_signed_artifact), + "--force", + ], + check=True, + ) + + subprocess.run( + ["sudo", "cp", str(tmp_signed_artifact), str(signed_artifact_path)], + check=True, + ) + log.debug(f"Artifact signed to {signed_artifact_path}") diff --git a/tests/images/testimages.py b/tests/images/testimages.py index 09fefe00d..9ab341cba 100755 --- a/tests/images/testimages.py +++ b/tests/images/testimages.py @@ -24,6 +24,31 @@ DEFINED_IMAGES: List[ImageConfig] = [ + # Installer images + ImageConfig( + "trident-installer", + config="trident-installer", + output_format=OutputFormat.ISO, + ), + ImageConfig( + "trident-split-installer", + config="trident-installer", + config_file="base/baseimg-split.yaml", + output_format=OutputFormat.ISO, + ), + ImageConfig( + "trident-installer-arm64", + config="trident-installer", + output_format=OutputFormat.ISO, + base_image=BaseImage.CORE_ARM64, + architecture=SystemArchitecture.ARM64, + ), + ImageConfig( + "trident-container-installer", + config="trident-container-installer", + output_format=OutputFormat.ISO, + requires_trident=False, + ), ImageConfig( "trident-direct-streaming-installer-amd64", config="trident-installer", @@ -38,11 +63,44 @@ base_image=BaseImage.CORE_ARM64, architecture=SystemArchitecture.ARM64, ), + # Test images ImageConfig( "trident-functest", output_format=OutputFormat.QCOW2, requires_trident=False, ), + ImageConfig("trident-testimage"), + ImageConfig( + "trident-testimage-arm64", + config="trident-testimage", + base_image=BaseImage.CORE_ARM64, + architecture=SystemArchitecture.ARM64, + ), + ImageConfig("trident-verity-testimage"), + ImageConfig( + "trident-usrverity-testimage", + config="trident-verity-testimage", + config_file="usr/host.yaml", + requires_ukify=True, + ), + ImageConfig( + "trident-container-verity-testimage", + config="trident-verity-testimage", + config_file="base/baseimg-container.yaml", + requires_trident=False, + ), + ImageConfig( + "trident-container-usrverity-testimage", + config="trident-verity-testimage", + config_file="usr/container.yaml", + requires_ukify=True, + requires_trident=False, + ), + ImageConfig( + "trident-container-testimage", + requires_trident=False, + ), + # Direct streaming images ImageConfig( "azurelinux-direct-streaming-testimage-amd64", config="azurelinux-direct-streaming-testimage", @@ -55,6 +113,7 @@ base_image=BaseImage.CORE_ARM64, architecture=SystemArchitecture.ARM64, ), + # AZL installer ImageConfig( "azl-installer", config_file=Path("installer-iso.yaml"), @@ -65,6 +124,7 @@ Path("tests/images/azl-installer/iso/images/trident-testimage.cosi"), ], ), + # VM test images ImageConfig( "trident-vm-grub-testimage", base_image=BaseImage.QEMU_GUEST, diff --git a/tests/images/trident-container-installer/README.md b/tests/images/trident-container-installer/README.md new file mode 100644 index 000000000..19ebcd492 --- /dev/null +++ b/tests/images/trident-container-installer/README.md @@ -0,0 +1,20 @@ +# 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 +python3 tests/images/testimages.py build trident-container-installer +``` + +Output is written to `artifacts/trident-container-installer.iso` by default. +Use `--output-dir ` to change the output location. diff --git a/tests/images/trident-container-installer/base/baseimg.yaml b/tests/images/trident-container-installer/base/baseimg.yaml new file mode 100644 index 000000000..12e3f0d6a --- /dev/null +++ b/tests/images/trident-container-installer/base/baseimg.yaml @@ -0,0 +1,77 @@ +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 + - squashfs-tools + - tar + - vim + + additionalFiles: + - source: files/getty@.service + destination: /usr/lib/systemd/system/getty@.service + - source: files/serial-getty@.service + destination: /usr/lib/systemd/system/serial-getty@.service + - source: files/root.profile + destination: /root/.profile + - source: files/trident-container.service + destination: /usr/lib/systemd/system/trident-container.service + + services: + enable: + - trident-container + - sshd + +scripts: + postCustomization: + - path: scripts/post-install.sh + +iso: + additionalFiles: + - source: files/config-placeholder.yaml + destination: /trident-config.yaml + - source: files/override-placeholder.conf + destination: /trident-override.conf + kernelCommandLine: + extraCommandLine: + - enforcing=0 + - console=tty0 + - console=ttyS0 + - rd.luks=0 diff --git a/tests/images/trident-container-installer/base/files/config-placeholder.yaml b/tests/images/trident-container-installer/base/files/config-placeholder.yaml new file mode 100644 index 000000000..88bb0938c --- /dev/null +++ b/tests/images/trident-container-installer/base/files/config-placeholder.yaml @@ -0,0 +1 @@ +#8505c8ab802dd717290331acd0592804c4e413b030150c53f5018ac998b7831d:/etc/trident/config.yaml:############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################ diff --git a/tests/images/trident-container-installer/base/files/getty@.service b/tests/images/trident-container-installer/base/files/getty@.service new file mode 100644 index 000000000..10d313181 --- /dev/null +++ b/tests/images/trident-container-installer/base/files/getty@.service @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: LGPL-2.1+ +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Getty on %I +Documentation=man:agetty(8) man:systemd-getty-generator(8) +Documentation=http://0pointer.de/blog/projects/serial-console.html +After=systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target +After=rc-local.service + +# If additional gettys are spawned during boot then we should make +# sure that this is synchronized before getty.target, even though +# getty.target didn't actually pull it in. +Before=getty.target +IgnoreOnIsolate=yes + +# IgnoreOnIsolate causes issues with sulogin, if someone isolates +# rescue.target or starts rescue.service from multi-user.target or +# graphical.target. +Conflicts=rescue.service +Before=rescue.service + +# On systems without virtual consoles, don't start any getty. Note +# that serial gettys are covered by serial-getty@.service, not this +# unit. +ConditionPathExists=/dev/tty0 + +[Service] +# the VT is cleared by TTYVTDisallocate +# The '-o' option value tells agetty to replace 'login' arguments with an +# option to preserve environment (-p), followed by '--' for safety, and then +# the entered username. +ExecStart=-/sbin/agetty --autologin root --noclear %I linux +Type=idle +Restart=always +RestartSec=0 +UtmpIdentifier=%I +TTYPath=/dev/%I +TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes +KillMode=process +IgnoreSIGPIPE=no +SendSIGHUP=yes + +# Unset locale for the console getty since the console has problems +# displaying some internationalized messages. +UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION + +[Install] +WantedBy=getty.target +DefaultInstance=tty1 diff --git a/tests/images/trident-container-installer/base/files/override-placeholder.conf b/tests/images/trident-container-installer/base/files/override-placeholder.conf new file mode 100644 index 000000000..438677498 --- /dev/null +++ b/tests/images/trident-container-installer/base/files/override-placeholder.conf @@ -0,0 +1 @@ +#8505c8ab802dd717290331acd0592804c4e413b030150c53f5018ac998b7831d:/trident_cdrom/trident-override.conf:############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################ diff --git a/tests/images/trident-container-installer/base/files/root.profile b/tests/images/trident-container-installer/base/files/root.profile new file mode 100644 index 000000000..14baf5c9e --- /dev/null +++ b/tests/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/images/trident-container-installer/base/files/serial-getty@.service b/tests/images/trident-container-installer/base/files/serial-getty@.service new file mode 100644 index 000000000..2f65391a8 --- /dev/null +++ b/tests/images/trident-container-installer/base/files/serial-getty@.service @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: LGPL-2.1+ +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Serial Getty on %I +Documentation=man:agetty(8) man:systemd-getty-generator(8) +Documentation=http://0pointer.de/blog/projects/serial-console.html +BindsTo=dev-%i.device +After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target +After=rc-local.service + +# If additional gettys are spawned during boot then we should make +# sure that this is synchronized before getty.target, even though +# getty.target didn't actually pull it in. +Before=getty.target +IgnoreOnIsolate=yes + +# IgnoreOnIsolate causes issues with sulogin, if someone isolates +# rescue.target or starts rescue.service from multi-user.target or +# graphical.target. +Conflicts=rescue.service +Before=rescue.service + +[Service] +# The '-o' option value tells agetty to replace 'login' arguments with an +# option to preserve environment (-p), followed by '--' for safety, and then +# the entered username. +ExecStart=-/sbin/agetty --autologin root --keep-baud 115200,38400,9600 %I screen +Type=idle +Restart=always +UtmpIdentifier=%I +TTYPath=/dev/%I +TTYReset=yes +TTYVHangup=yes +KillMode=process +IgnoreSIGPIPE=no +SendSIGHUP=yes + +[Install] +WantedBy=getty.target diff --git a/tests/images/trident-container-installer/base/files/trident-container.service b/tests/images/trident-container-installer/base/files/trident-container.service new file mode 100644 index 000000000..2c93c9396 --- /dev/null +++ b/tests/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/images/trident-container-installer/base/scripts/post-install.sh b/tests/images/trident-container-installer/base/scripts/post-install.sh new file mode 100755 index 000000000..5b2f4f7ca --- /dev/null +++ b/tests/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/images/trident-container-testimage/README.md b/tests/images/trident-container-testimage/README.md new file mode 100644 index 000000000..e8feada25 --- /dev/null +++ b/tests/images/trident-container-testimage/README.md @@ -0,0 +1,19 @@ +# 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 +python3 tests/images/testimages.py build trident-container-testimage +``` + +Output is written to `artifacts/trident-container-testimage.cosi` by default. +Use `--output-dir ` to change the output location. diff --git a/tests/images/trident-container-testimage/base/baseimg.yaml b/tests/images/trident-container-testimage/base/baseimg.yaml new file mode 100644 index 000000000..e31dfc3a9 --- /dev/null +++ b/tests/images/trident-container-testimage/base/baseimg.yaml @@ -0,0 +1,83 @@ +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: + # Replicates BM base image settings, that would otherwise be lost + extraCommandLine: + - console=tty0 + - console=ttyS0 + - rd.info + - log_buf_len=1M + + packages: + remove: + - grub2-efi-binary + + install: + # replace grub2-efi-binary with grub2-efi-binary-noprefix + - grub2-efi-binary-noprefix + - curl + - dnf + - efibootmgr + - iproute + - iptables + - lsof + - mdadm + - netplan + - openssh-server + - tpm2-tools + - vim + # Packages required for functional tests, which currently use this image: + - device-mapper + - dosfstools + - lvm2 + - veritysetup + # Optional dependencies for NTFS + - ntfs-3g + - ntfsprogs + + - docker-cli + - moby-engine + - squashfs-tools + - tar + + additionalFiles: + - source: files/trident-container.service + destination: /usr/lib/systemd/system/trident-container.service + + services: + enable: + - trident-container + - sshd + +scripts: + postCustomization: + - path: scripts/post-install.sh diff --git a/tests/images/trident-container-testimage/base/files/trident-container.service b/tests/images/trident-container-testimage/base/files/trident-container.service new file mode 100644 index 000000000..bba22a965 --- /dev/null +++ b/tests/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/images/trident-container-testimage/base/scripts/post-install.sh b/tests/images/trident-container-testimage/base/scripts/post-install.sh new file mode 100755 index 000000000..79da025b3 --- /dev/null +++ b/tests/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/images/trident-installer/base/baseimg-split.yaml b/tests/images/trident-installer/base/baseimg-split.yaml new file mode 100644 index 000000000..6c5867d8a --- /dev/null +++ b/tests/images/trident-installer/base/baseimg-split.yaml @@ -0,0 +1,86 @@ +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-mos-testimage + + packages: + install: + - curl + - device-mapper + - dnf + - dosfstools + - efibootmgr + - iproute + - iptables + - lsof + - mdadm + - netplan + # Optional dependencies for NTFS + - ntfs-3g + - ntfsprogs + - openssh-server + - squashfs-tools + - tar + - tpm2-tools + - trident + - vim + - veritysetup + + services: + enable: + - sshd + - trident-install + - tridentd.socket + + selinux: + mode: enforcing + + additionalFiles: + - source: files/getty@.service + destination: /usr/lib/systemd/system/getty@.service + - source: files/serial-getty@.service + destination: /usr/lib/systemd/system/serial-getty@.service + - source: files/root.profile + destination: /root/.profile + - source: files/trident-split-install.service + destination: /usr/lib/systemd/system/trident-install.service + +scripts: + postCustomization: + - path: post-install.sh + +iso: + additionalFiles: + - source: files/config-placeholder.yaml + destination: /trident-config.yaml + kernelCommandLine: + extraCommandLine: + - console=tty0 + - console=ttyS0 + - rd.luks=0 diff --git a/tests/images/trident-installer/base/baseimg.yaml b/tests/images/trident-installer/base/baseimg.yaml new file mode 100644 index 000000000..7f6bf691b --- /dev/null +++ b/tests/images/trident-installer/base/baseimg.yaml @@ -0,0 +1,96 @@ +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-mos-testimage + + packages: + install: + - binutils + - curl + - device-mapper + - dnf + - dosfstools + - efibootmgr + - iproute + - iptables + - lsof + - mdadm + - netplan + # Optional dependencies for NTFS + - ntfs-3g + - ntfsprogs + - openssh-server + # Package required for systemd-pcrlock & PCR-based encryption; can be removed once AZL 4.0 + # merges a fix to provide statically defined files inside the same package as the + # systemd-pcrlock binary, i.e. systemd-udev. + - trident-static-pcrlock-files + - squashfs-tools + - tar + - tpm2-tools + - trident + - vim + - veritysetup + - selinux-policy + - selinux-policy-devel + - audit + + services: + enable: + - sshd + - trident-install + - tridentd.socket + + additionalFiles: + - source: files/getty@.service + destination: /usr/lib/systemd/system/getty@.service + - source: files/serial-getty@.service + destination: /usr/lib/systemd/system/serial-getty@.service + - source: files/root.profile + destination: /root/.profile + - source: files/trident-install.service + destination: /usr/lib/systemd/system/trident-install.service + + selinux: + mode: enforcing + +scripts: + postCustomization: + - path: post-install.sh + +iso: + additionalFiles: + - source: files/config-placeholder.yaml + destination: /trident-config.yaml + - source: files/override-placeholder.conf + destination: /trident-override.conf + kernelCommandLine: + extraCommandLine: + - console=tty0 + - console=ttyS0 + - rd.luks=0 diff --git a/tests/images/trident-installer/base/files/config-placeholder.yaml b/tests/images/trident-installer/base/files/config-placeholder.yaml new file mode 100644 index 000000000..88bb0938c --- /dev/null +++ b/tests/images/trident-installer/base/files/config-placeholder.yaml @@ -0,0 +1 @@ +#8505c8ab802dd717290331acd0592804c4e413b030150c53f5018ac998b7831d:/etc/trident/config.yaml:############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################ diff --git a/tests/images/trident-installer/base/files/override-placeholder.conf b/tests/images/trident-installer/base/files/override-placeholder.conf new file mode 100644 index 000000000..438677498 --- /dev/null +++ b/tests/images/trident-installer/base/files/override-placeholder.conf @@ -0,0 +1 @@ +#8505c8ab802dd717290331acd0592804c4e413b030150c53f5018ac998b7831d:/trident_cdrom/trident-override.conf:############################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################ diff --git a/tests/images/trident-installer/base/files/trident-install.service b/tests/images/trident-installer/base/files/trident-install.service new file mode 100644 index 000000000..2057d49dd --- /dev/null +++ b/tests/images/trident-installer/base/files/trident-install.service @@ -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 diff --git a/tests/images/trident-installer/base/files/trident-split-install.service b/tests/images/trident-installer/base/files/trident-split-install.service new file mode 100644 index 000000000..bfb868b85 --- /dev/null +++ b/tests/images/trident-installer/base/files/trident-split-install.service @@ -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 diff --git a/tests/images/trident-installer/base/post-install.sh b/tests/images/trident-installer/base/post-install.sh index b7e6cade0..1bfa85174 100755 --- a/tests/images/trident-installer/base/post-install.sh +++ b/tests/images/trident-installer/base/post-install.sh @@ -1,5 +1,8 @@ +# 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 /run/initramfs/live /trident_cdrom +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 @@ -7,7 +10,12 @@ if [ ! -d /etc/trident ]; then fi if [ "$1" != "stream-image-test" ]; then - ln -s /trident_cdrom/trident-config.yaml /etc/trident/config.yaml + 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 @@ -20,4 +28,4 @@ if [ ! -d /etc/rcp-agent ]; then fi # Link rcp-agent config from the ISO -ln -s /trident_cdrom/rcp-agent.yaml /etc/rcp-agent/config.yaml +ln -s -T /trident_cdrom/rcp-agent.yaml /etc/rcp-agent/config.yaml \ No newline at end of file diff --git a/tests/images/trident-testimage/README.md b/tests/images/trident-testimage/README.md new file mode 100644 index 000000000..108ab80e1 --- /dev/null +++ b/tests/images/trident-testimage/README.md @@ -0,0 +1,24 @@ +# Trident Test Image + +This image is used for testing Trident on Azure Linux. For AMD64, the image +is based on the baremetal image, and for ARM64, it is based on the ARM64 core +image. In both cases, the configuration adds Trident as well as its dependencies. +It also includes openssh-server to allow for remote access. + +## Prerequisites + +- **Trident RPMs** in `bin/RPMS/`. Build them with: + ```bash + make bin/trident-rpms.tar.gz + ``` + +## Building + +From the repo root, run: + +```bash +python3 tests/images/testimages.py build trident-testimage +``` + +Output is written to `artifacts/trident-testimage.cosi` by default. Use +`--output-dir ` to change the output location. diff --git a/tests/images/trident-testimage/base/baseimg.yaml b/tests/images/trident-testimage/base/baseimg.yaml new file mode 100644 index 000000000..80951ff4d --- /dev/null +++ b/tests/images/trident-testimage/base/baseimg.yaml @@ -0,0 +1,83 @@ +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-testimg + + kernelCommandLine: + # Replicates BM base image settings, that would otherwise be lost + extraCommandLine: + - console=tty0 + - console=ttyS0 + - rd.info + - log_buf_len=1M + + packages: + remove: + - grub2-efi-binary + + install: + # replace grub2-efi-binary with grub2-efi-binary-noprefix + - grub2-efi-binary-noprefix + - curl + - dnf + - efibootmgr + - iproute + - iptables + - lsof + - mdadm + - netplan + - openssh-server + - tpm2-tools + - trident-service + - vim + - audit + # Packages required for functional tests, which currently use this image: + - device-mapper + - dosfstools + - lvm2 + - veritysetup + # Optional dependencies for NTFS + - ntfs-3g + - ntfsprogs + + services: + enable: + - sshd + - trident + - tridentd.socket + + additionalFiles: + # For tests, override the public trident.service behavior and use + # grpc-client commit. + - source: files/use-grpc-client-commit.conf + destination: /etc/systemd/system/trident.service.d/override.conf + +scripts: + postCustomization: + - path: post-install.sh diff --git a/tests/images/trident-testimage/base/files/use-grpc-client-commit.conf b/tests/images/trident-testimage/base/files/use-grpc-client-commit.conf new file mode 100644 index 000000000..958e0095c --- /dev/null +++ b/tests/images/trident-testimage/base/files/use-grpc-client-commit.conf @@ -0,0 +1,5 @@ +[Service] +ExecStart= +ExecStart=trident grpc-client commit +StandardOutput=journal+console +StandardError=journal+console diff --git a/tests/images/trident-testimage/base/post-install.sh b/tests/images/trident-testimage/base/post-install.sh new file mode 100755 index 000000000..79da025b3 --- /dev/null +++ b/tests/images/trident-testimage/base/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/images/trident-verity-testimage/README.md b/tests/images/trident-verity-testimage/README.md new file mode 100644 index 000000000..0c8dd782a --- /dev/null +++ b/tests/images/trident-verity-testimage/README.md @@ -0,0 +1,25 @@ +# Trident Verity Test Image + +This image is used for testing Trident on Azure Linux with `dm-verity` enabled. It +is based on the baremetal image and adds Trident as well as its dependencies. It +also adds openssh-server to allow for remote access. In addition to the [Trident +Test Image](../trident-testimage/README.md), this image is configured to use +dm-verity. + +## Prerequisites + +- **Trident RPMs** in `bin/RPMS/`. Build them with: + ```bash + make bin/trident-rpms.tar.gz + ``` + +## Building + +From the repo root, run: + +```bash +python3 tests/images/testimages.py build trident-verity-testimage +``` + +Output is written to `artifacts/trident-verity-testimage.cosi` by default. Use +`--output-dir ` to change the output location. diff --git a/tests/images/trident-verity-testimage/base/baseimg-container.yaml b/tests/images/trident-verity-testimage/base/baseimg-container.yaml new file mode 100644 index 000000000..21dd824cb --- /dev/null +++ b/tests/images/trident-verity-testimage/base/baseimg-container.yaml @@ -0,0 +1,146 @@ +storage: + disks: + - partitionTableType: gpt + maxSize: 5G + partitions: + - id: esp + type: esp + size: 8M + + - id: boot + size: 1G + + - label: root + id: root + size: 2G + + - label: root-hash + id: verityhash + size: 128M + + - id: sysexts + size: 1G + + - id: confexts + size: 200M + + - id: var + size: grow + + bootType: efi + + verity: + - id: rootverity + name: root + dataDeviceId: root + hashDeviceId: verityhash + dataDeviceMountIdType: part-label + hashDeviceMountIdType: part-label + + filesystems: + - deviceId: esp + type: fat32 + mountPoint: + path: /boot/efi + options: umask=0077 + + - deviceId: boot + type: ext4 + mountPoint: + path: /boot + + - deviceId: rootverity + type: ext4 + mountPoint: + path: / + options: defaults,ro + + - deviceId: sysexts + type: ext4 + mountPoint: + path: /var/lib/extensions + + - deviceId: confexts + type: ext4 + mountPoint: + path: /var/lib/confexts + + - deviceId: var + type: ext4 + mountPoint: + path: /var + +os: + bootloader: + resetType: hard-reset + hostname: trident-container-verity-testimg + + selinux: + mode: disabled + + kernelCommandLine: + # Replicates BM base image settings, that would otherwise be lost + extraCommandLine: + - console=tty0 + - console=ttyS0 + - rd.info + - log_buf_len=1M + + packages: + remove: + - grub2-efi-binary + + # Package list carried over from base image. + install: + # replace grub2-efi-binary with grub2-efi-binary-noprefix + - grub2-efi-binary-noprefix + - curl + - device-mapper + - dnf + - docker-cli + # Required to create vfat filesystems, which at the moment is not needed + # from the runtime image; included here to unblock functional tests + - dosfstools + # Required to boot from the overlay supplied on the kernel command line + - dracut-overlayfs + - efibootmgr + - iproute + - iptables + - lsof + - lvm2 + - mdadm + - moby-engine + - netplan + - openssh-server + - systemd-udev + - tpm2-tools + - veritysetup + - squashfs-tools + - tar + - vim + + additionalFiles: + # Early boot one shot service to activate secondary rw /etc overlay + - source: etc-mount.service + destination: /etc/systemd/system/etc-mount.service + # Script invoked by the service above to mount the /etc rw overlay + - source: etc-mount.sh + destination: /usr/local/bin/etc-mount.sh + # SSH user needs sudo access for tests, and scripts cannot modify /etc + # directly, so modifying the wheel group as part of the image creation (note + # scripts could mount the rw etc from below instead) + - source: sudoers-wheel + destination: /etc/sudoers.d/wheel + - source: files/trident-container.service + destination: /usr/lib/systemd/system/trident-container.service + + services: + enable: + - etc-mount + - sshd + - trident-container + +scripts: + postCustomization: + # Script to create the /web directory + - path: create-web-dir.sh diff --git a/tests/images/trident-verity-testimage/base/baseimg.yaml b/tests/images/trident-verity-testimage/base/baseimg.yaml new file mode 100644 index 000000000..1477615dc --- /dev/null +++ b/tests/images/trident-verity-testimage/base/baseimg.yaml @@ -0,0 +1,146 @@ +storage: + disks: + - partitionTableType: gpt + maxSize: 5G + partitions: + - id: esp + type: esp + size: 8M + + - id: boot + size: 1G + + - label: root + id: root + size: 2G + + - label: root-hash + id: verityhash + size: 128M + + - id: sysexts + size: 1G + + - id: confexts + size: 200M + + - id: var + size: grow + + bootType: efi + + verity: + - id: rootverity + name: root + dataDeviceId: root + hashDeviceId: verityhash + dataDeviceMountIdType: part-label + hashDeviceMountIdType: part-label + + filesystems: + - deviceId: esp + type: fat32 + mountPoint: + path: /boot/efi + options: umask=0077 + + - deviceId: boot + type: ext4 + mountPoint: + path: /boot + + - deviceId: rootverity + type: ext4 + mountPoint: + path: / + options: defaults,ro + + - deviceId: sysexts + type: ext4 + mountPoint: + path: /var/lib/extensions + + - deviceId: confexts + type: ext4 + mountPoint: + path: /var/lib/confexts + + - deviceId: var + type: ext4 + mountPoint: + path: /var + +os: + bootloader: + resetType: hard-reset + hostname: trident-verity-testimg + + selinux: + mode: disabled + + kernelCommandLine: + # Replicates BM base image settings, that would otherwise be lost + extraCommandLine: + - console=tty0 + - console=ttyS0 + - rd.info + - log_buf_len=1M + + packages: + remove: + - grub2-efi-binary + + # Package list carried over from base image. + install: + # replace grub2-efi-binary with grub2-efi-binary-noprefix + - grub2-efi-binary-noprefix + - curl + - device-mapper + # Required to create vfat filesystems, which at the moment is not needed + # from the runtime image; included here to unblock functional tests + - dosfstools + # Required to boot from the overlay supplied on the kernel command line + - dracut-overlayfs + - efibootmgr + - iproute + - iptables + - lsof + - lvm2 + - mdadm + - netplan + - openssh-server + - systemd-udev + - tpm2-tools + - trident-service + - veritysetup + - vim + + additionalFiles: + # Early boot one shot service to activate secondary rw /etc overlay + - source: etc-mount.service + destination: /etc/systemd/system/etc-mount.service + # Script invoked by the service above to mount the /etc rw overlay + - source: etc-mount.sh + destination: /usr/local/bin/etc-mount.sh + # SSH user needs sudo access for tests, and scripts cannot modify /etc + # directly, so modifying the wheel group as part of the image creation (note + # scripts could mount the rw etc from below instead) + - source: sudoers-wheel + destination: /etc/sudoers.d/wheel + # For tests, override the public trident.service behavior and use + # grpc-client commit. + - source: files/use-grpc-client-commit.conf + destination: /etc/systemd/system/trident.service.d/override.conf + + services: + enable: + - etc-mount + - sshd + - trident + - tridentd.socket + +scripts: + postCustomization: + - path: trident-debug-log.sh + # Script to create the /web directory + - path: create-web-dir.sh diff --git a/tests/images/trident-verity-testimage/base/create-web-dir.sh b/tests/images/trident-verity-testimage/base/create-web-dir.sh new file mode 100755 index 000000000..71f393a31 --- /dev/null +++ b/tests/images/trident-verity-testimage/base/create-web-dir.sh @@ -0,0 +1,2 @@ +# Create the web directory for testing +mkdir -p /web \ No newline at end of file diff --git a/tests/images/trident-verity-testimage/base/etc-mount.service b/tests/images/trident-verity-testimage/base/etc-mount.service new file mode 100644 index 000000000..7883ddf82 --- /dev/null +++ b/tests/images/trident-verity-testimage/base/etc-mount.service @@ -0,0 +1,17 @@ +[Unit] +Description=/etc Mount Service +DefaultDependencies=no +Conflicts=umount.target +Before=local-fs.target umount.target +Requires=etc.mount +After=etc.mount +Requires=var-lib-trident\x2doverlay.mount +After=var-lib-trident\x2doverlay.mount + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=etc-mount.sh + +[Install] +WantedBy=local-fs.target \ No newline at end of file diff --git a/tests/images/trident-verity-testimage/base/etc-mount.sh b/tests/images/trident-verity-testimage/base/etc-mount.sh new file mode 100755 index 000000000..f9feb5db9 --- /dev/null +++ b/tests/images/trident-verity-testimage/base/etc-mount.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -eux + +mount -t overlay overlay -o lowerdir=/etc,upperdir=/var/lib/trident-overlay/etc-rw/upper,workdir=/var/lib/trident-overlay/etc-rw/work /etc +# Workaround for https://dev.azure.com/mariner-org/ECF/_workitems/edit/7349/ +chmod o+rx /etc \ No newline at end of file diff --git a/tests/images/trident-verity-testimage/base/etc.mount b/tests/images/trident-verity-testimage/base/etc.mount new file mode 100644 index 000000000..8dd53647f --- /dev/null +++ b/tests/images/trident-verity-testimage/base/etc.mount @@ -0,0 +1,10 @@ +[Unit] +Description=/etc Overlay Mount +DefaultDependencies=no +Conflicts=shutdown.target + +[Mount] +What=overlay +Where=/etc +Type=overlay +Options=lowerdir=/etc,upperdir=/var/lib/trident-overlay/etc/upper,workdir=/var/lib/trident-overlay/etc/work,rw \ No newline at end of file diff --git a/tests/images/trident-verity-testimage/base/files/trident-container.service b/tests/images/trident-verity-testimage/base/files/trident-container.service new file mode 100644 index 000000000..98ce5f3e4 --- /dev/null +++ b/tests/images/trident-verity-testimage/base/files/trident-container.service @@ -0,0 +1,14 @@ +[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" +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/images/trident-verity-testimage/base/files/use-grpc-client-commit.conf b/tests/images/trident-verity-testimage/base/files/use-grpc-client-commit.conf new file mode 100644 index 000000000..958e0095c --- /dev/null +++ b/tests/images/trident-verity-testimage/base/files/use-grpc-client-commit.conf @@ -0,0 +1,5 @@ +[Service] +ExecStart= +ExecStart=trident grpc-client commit +StandardOutput=journal+console +StandardError=journal+console diff --git a/tests/images/trident-verity-testimage/base/sudoers-wheel b/tests/images/trident-verity-testimage/base/sudoers-wheel new file mode 100644 index 000000000..c8b362960 --- /dev/null +++ b/tests/images/trident-verity-testimage/base/sudoers-wheel @@ -0,0 +1 @@ +%wheel ALL=(ALL:ALL) NOPASSWD: ALL \ No newline at end of file diff --git a/tests/images/trident-verity-testimage/base/trident-debug-log.sh b/tests/images/trident-verity-testimage/base/trident-debug-log.sh new file mode 100755 index 000000000..da03d7c14 --- /dev/null +++ b/tests/images/trident-verity-testimage/base/trident-debug-log.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +sed -i 's/--verbosity INFO/--verbosity DEBUG/' /usr/lib/systemd/system/trident.service \ No newline at end of file diff --git a/tests/images/trident-verity-testimage/usr/container.yaml b/tests/images/trident-verity-testimage/usr/container.yaml new file mode 100644 index 000000000..855cd0f10 --- /dev/null +++ b/tests/images/trident-verity-testimage/usr/container.yaml @@ -0,0 +1,130 @@ +storage: + disks: + - partitionTableType: gpt + maxSize: 5G + partitions: + - id: esp + type: esp + size: 500M + label: esp + + - id: boot + size: 150M + + - id: root + size: 2G + + - id: usr-data + label: usr + size: 1G + + - id: usr-hash + label: usr-hash + size: 128M + + bootType: efi + + verity: + - id: usr + name: usr + dataDeviceId: usr-data + hashDeviceId: usr-hash + dataDeviceMountIdType: uuid + hashDeviceMountIdType: uuid + + filesystems: + - deviceId: esp + type: fat32 + mountPoint: + path: /boot/efi + options: umask=0077 + + - deviceId: boot + type: ext4 + mountPoint: + path: /boot + + - deviceId: root + type: ext4 + mountPoint: + path: / + + - deviceId: usr + type: ext4 + mountPoint: + path: /usr + options: defaults,ro + +os: + bootloader: + resetType: hard-reset + hostname: trident-container-usrverity-testimg + + selinux: + mode: disabled + + kernelCommandLine: + # Replicates BM base image settings, that would otherwise be lost + extraCommandLine: + - console=tty0 + - console=ttyS0 + - rd.info + - log_buf_len=1M + - rd.hostonly=0 + + packages: + remove: + - grub2-efi-binary + + install: + - curl + - device-mapper + - docker-cli + - efibootmgr + - iproute + - iptables + - lvm2 + - mdadm + - moby-engine + - netplan + - openssh-server + - systemd-udev + - tpm2-tools + - veritysetup + - vim + - systemd-ukify + - systemd-boot + - efibootmgr + - squashfs-tools + - tar + + services: + enable: + - trident-container + - sshd + + uki: + mode: create + + additionalFiles: + # Add mdraid dracut module, this will enable installation on raid devices + - source: files/dracut-nohostonly.conf + destination: /usr/lib/dracut/dracut.conf.d/nohostonly.conf + - source: files/sudoers-wheel + destination: /etc/sudoers.d/wheel + - source: files/trident-container.service + destination: /usr/lib/systemd/system/trident-container.service + +output: + # Specifies config for output dir containining generated artifacts. This is + # required for later running inject-files command, so that the final image + # built via imagecustomizer is signed and SecureBoot can be enabled in E2E + # tests where UKI ROS is used. + artifacts: + items: + - ukis + path: ./output + +previewFeatures: + - uki + - output-artifacts diff --git a/tests/images/trident-verity-testimage/usr/files/dracut-nohostonly.conf b/tests/images/trident-verity-testimage/usr/files/dracut-nohostonly.conf new file mode 100644 index 000000000..18912360c --- /dev/null +++ b/tests/images/trident-verity-testimage/usr/files/dracut-nohostonly.conf @@ -0,0 +1 @@ +hostonly="no" diff --git a/tests/images/trident-verity-testimage/usr/files/sudoers-wheel b/tests/images/trident-verity-testimage/usr/files/sudoers-wheel new file mode 100644 index 000000000..c8b362960 --- /dev/null +++ b/tests/images/trident-verity-testimage/usr/files/sudoers-wheel @@ -0,0 +1 @@ +%wheel ALL=(ALL:ALL) NOPASSWD: ALL \ No newline at end of file diff --git a/tests/images/trident-verity-testimage/usr/files/trident-container.service b/tests/images/trident-verity-testimage/usr/files/trident-container.service new file mode 100644 index 000000000..98ce5f3e4 --- /dev/null +++ b/tests/images/trident-verity-testimage/usr/files/trident-container.service @@ -0,0 +1,14 @@ +[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" +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/images/trident-verity-testimage/usr/files/use-grpc-client-commit.conf b/tests/images/trident-verity-testimage/usr/files/use-grpc-client-commit.conf new file mode 100644 index 000000000..958e0095c --- /dev/null +++ b/tests/images/trident-verity-testimage/usr/files/use-grpc-client-commit.conf @@ -0,0 +1,5 @@ +[Service] +ExecStart= +ExecStart=trident grpc-client commit +StandardOutput=journal+console +StandardError=journal+console diff --git a/tests/images/trident-verity-testimage/usr/host.yaml b/tests/images/trident-verity-testimage/usr/host.yaml new file mode 100644 index 000000000..476178d80 --- /dev/null +++ b/tests/images/trident-verity-testimage/usr/host.yaml @@ -0,0 +1,136 @@ +storage: + disks: + - partitionTableType: gpt + maxSize: 5G + partitions: + - id: esp + type: esp + size: 500M + label: esp + + - id: boot + size: 150M + + - id: root + size: 2G + + - id: usr-data + label: usr + size: 1G + + - id: usr-hash + label: usr-hash + size: 128M + + bootType: efi + + verity: + - id: usr + name: usr + dataDeviceId: usr-data + hashDeviceId: usr-hash + dataDeviceMountIdType: uuid + hashDeviceMountIdType: uuid + + filesystems: + - deviceId: esp + type: fat32 + mountPoint: + path: /boot/efi + options: umask=0077 + + - deviceId: boot + type: ext4 + mountPoint: + path: /boot + + - deviceId: root + type: ext4 + mountPoint: + path: / + + - deviceId: usr + type: ext4 + mountPoint: + path: /usr + options: defaults,ro + +os: + bootloader: + resetType: hard-reset + hostname: trident-usrverity-testimg + + selinux: + mode: disabled + + kernelCommandLine: + # Replicates BM base image settings, that would otherwise be lost + extraCommandLine: + - console=tty0 + - console=ttyS0 + - rd.info + - log_buf_len=1M + - rd.hostonly=0 + + packages: + remove: + - grub2-efi-binary + + install: + - binutils + - curl + - device-mapper + - efibootmgr + - iproute + - iptables + - lvm2 + - mdadm + - netplan + - openssh-server + - systemd-udev + - tpm2-tools + - trident-service + # Package required for systemd-pcrlock & PCR-based encryption; can be removed once AZL 4.0 + # merges a fix to provide statically defined files inside the same package as the + # systemd-pcrlock binary, i.e. systemd-udev. + - trident-static-pcrlock-files + - veritysetup + - vim + - systemd-ukify + - systemd-boot + - efibootmgr + - audit + - selinux-policy-devel + + services: + enable: + - sshd + - trident + - tridentd.socket + uki: + mode: create + + additionalFiles: + - source: files/sudoers-wheel + destination: /etc/sudoers.d/wheel + # Add mdraid dracut module, this will enable installation on raid devices + - source: files/dracut-nohostonly.conf + destination: /usr/lib/dracut/dracut.conf.d/nohostonly.conf + # For tests, override the public trident.service behavior and use + # grpc-client commit. + - source: files/use-grpc-client-commit.conf + destination: /etc/systemd/system/trident.service.d/override.conf + +output: + # Specifies config for output dir containining generated artifacts. This is + # required for later running inject-files command, so that the final image + # built via imagecustomizer is signed and SecureBoot can be enabled in E2E + # tests where UKI ROS is used. + artifacts: + items: + - ukis + path: ./output + +previewFeatures: + - uki + - output-artifacts