Skip to content

Commit

Permalink
Add support to bare metal for direct image installation of SL Micro
Browse files Browse the repository at this point in the history
Enhancement poo#167021: SL Micro doesn't have installer like openSUSE
or SLE. Only raw images are supported. If we want to install SL Micro
to bare metal, we need to directly copy image to destination, this is
documented and supported way. The idea behind this extension, is to
use existing openQA boot modules for particular backends and boot SLE
installer, use installation console to mount nfs share from openQA and
deploy image to target disk. We need to modify grub configuration
before first boot, to be able to see menu in hardware consoles. root
password is configured by ignition, which has own separate parition on
the same disk. There are supported following backends and
architectures hmc/ppc64le, ipmi/x86_64/aarch64. Variables MIRROR_HTTP
and REPO_0 are needed to properly boot installer on hmc
backend. Variable IPXE_BOOT_FIXED must be defined for ipmi. There can
be used optional variables IPXE_BOOT_FIXED_DISTRI and
IPXE_BOOT_FIXED_VERSION to boot specific installer version.
  • Loading branch information
czerw committed Sep 26, 2024
1 parent 95a90cc commit b92937b
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 1 deletion.
11 changes: 11 additions & 0 deletions data/microos/ignition/config.ign
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"ignition": { "version": "3.0.0" },
"passwd": {
"users": [
{
"name": "root",
"passwordHash": "$6$eEm2HpuzI7dfE4i7$dbYiTRLhrqVvwryR7zmMEcnrp13IqZ3mzLbsx9EeHAX7849PibGVgX5vdPuaeYYIO7hVfcboI9/JDpGiDZhHf/"
}
]
}
}
12 changes: 11 additions & 1 deletion lib/main_ltp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ sub load_kernel_tests {

if (get_var('INSTALL_LTP')) {
if (is_transactional) {
is_s390x ? loadtest 'boot/boot_to_desktop' : loadtest 'microos/disk_boot';
# Handle specific boot requirements for different backends and architectures
if (is_s390x) {
loadtest 'boot/boot_to_desktop';
}
elsif ((is_ipmi || is_pvm)) {
loadtest 'installation/ipxe_install' if is_ipmi;
loadtest 'microos/install_image';
}
else {
loadtest 'microos/disk_boot';
}
replace_opensuse_repos_tests if is_repo_replacement_required;
loadtest 'transactional/host_config';
loadtest 'console/suseconnect_scc' if is_sle_micro;
Expand Down
99 changes: 99 additions & 0 deletions tests/microos/install_image.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# SUSE's openQA tests
#
# Copyright SUSE LLC
# SPDX-License-Identifier: FSFAP

# Summary: Install SL Micro image on bare metal disk
# Maintainer: Petr Cervinka <[email protected]>

use base 'opensusebasetest';
use strict;
use warnings;
use testapi;
use utils;

use Utils::Backends;
use Utils::Architectures 'is_x86_64';
use power_action_utils 'power_action';
use serial_terminal 'select_serial_terminal';

sub run {
select_serial_terminal;

# Use image name from HDD_1 variable
my $image = get_required_var('HDD_1');
# Use sda as target disk by default
my $device = get_var("MICRO_INSTALL_IMAGE_TARGET_DEVICE", "/dev/sda");
# Use partition prefix for nvme devices
my $prefix = $device =~ /nvme/ ? "n" : "";
# SL Micro x86_64 image has three partitions, aarch64 and ppc64le images have only two partitions
my $root_partition_id = is_x86_64 ? 3 : 2;
my $root_partition = "${device}" . $prefix . $root_partition_id;
# New partition id for ignition will be directly after root partition
my $ignition_partition_id = $root_partition_id + 1;
my $ignition_partition = "${device}" . $prefix . $ignition_partition_id;
record_info("Device information", "Device: ${device}\nRoot partition: ${root_partition}\nIgnition partition: ${ignition_partition}");

# Mount nfs share with images
assert_script_run("mount -o ro,noauto,nofail,nolock -t nfs openqa.suse.de:/var/lib/openqa/share /mnt");
assert_script_run("ls -als /mnt/factory/hdd/${image}");
# dd image to disk
assert_script_run("xzcat /mnt/factory/hdd/${image} | dd of=${device} bs=65536 status=progress", timeout => 300);
assert_script_run("sync");
assert_script_run("umount /mnt");

my $device_layout = script_output("lsblk");
record_info("Device layout", ${device_layout});

# Modify disk to be able to correctly boot and login
assert_script_run("mount ${root_partition} /mnt");
assert_script_run("btrfs property set /mnt ro false");
# Set correct serial console to be able to see login in first boot
assert_script_run("sed -i 's/console=ttyS0,115200/console=ttyS1,115200/g' /mnt/boot/grub2/grub.cfg") if is_x86_64;
# Upload original grub configuration
upload_logs("/mnt/etc/default/grub", failok => 1);
# Set permanent grub configuration
assert_script_run("sed -i 's/console=ttyS0,115200/console=ttyS1,115200/g' /mnt/etc/default/grub") if is_x86_64;
# Fully disable graphical terminal on legacy systems without UEFI
assert_script_run("sed -i 's/#GRUB_TERMINAL=console/GRUB_TERMINAL=console/g' /mnt/etc/default/grub") if (is_ipmi && !get_var('IPXE_UEFI'));
# We need to properly set grub terminal bsc#1230844, otherwise grub menu will not be visible in non graphical boot environments
assert_script_run("sed -i 's/GRUB_TERMINAL_INPUT=\".*\"/GRUB_TERMINAL_INPUT=\"console gfxterm\"/g' /mnt/etc/default/grub");
assert_script_run("sed -i 's/GRUB_TERMINAL_OUTPUT=\".*\"/GRUB_TERMINAL_OUTPUT=\"console gfxterm\"/g' /mnt/etc/default/grub");
# Enable root loging with password
assert_script_run("echo 'PermitRootLogin yes' > /mnt/etc/ssh/sshd_config.d/root.conf");
assert_script_run("btrfs property set /mnt ro true");
assert_script_run("umount /mnt");

# Setup ignition parition on the end of the same disk and resize root partition to use all the space
# script_output recommended in https://github.com/os-autoinst/os-autoinst-distri-opensuse/pull/20253/files#r1776549682
script_output("printf \"fix\n\" | parted ---pretend-input-tty ${device} print");
assert_script_run("parted ${device} --script mkpart primary ext4 98% 100%");
assert_script_run("mkfs.ext4 -F ${ignition_partition}");
assert_script_run("e2label ${ignition_partition} ignition");
assert_script_run("mount ${ignition_partition} /mnt/");
assert_script_run("mkdir /mnt/ignition");
assert_script_run("curl -v -o /mnt/ignition/config.ign " . data_url("microos/ignition/config.ign"));
assert_script_run('umount /mnt');

# Resize root filesystem to maximum size to use all space up to partition with ignition
assert_script_run("parted ${device} --script resize ${root_partition_id} 98%");
assert_script_run("mount ${root_partition} /mnt");
assert_script_run("btrfs filesystem resize max /mnt");
assert_script_run("umount /mnt");
assert_script_run("fdisk ${device} -l");
record_info("INFO", "${image} was installed on ${device}. System is going to be rebooted");

# We have to use force option to reboot command as installer doesn't have fully running systemd environment
power_action("reboot", textmode => 1, force => 1);

# We can't use reconnect_mgmt_console as it expects fully configured grub, which we don't have at this stage yet
select_console "sol", await_console => 0 if is_ipmi;
select_console 'powerhmc-ssh', await_console => 0 if is_pvm_hmc;
assert_screen("linux-login", 1800);
}

sub test_flags {
return {fatal => 1};
}

1;
1 change: 1 addition & 0 deletions variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ LVM_THIN_LV | boolean | false | Use thin provisioning logical volumes for partit
MACHINE | string | | Define machine name which defines worker specific configuration, including WORKER_CLASS.
MEDIACHECK | boolean | false | Enables `installation/mediacheck` test module.
MEMTEST | boolean | false | Enables `installation/memtest` test module.
MICRO_INSTALL_IMAGE_TARGET_DEVICE | string | /dev/sda | Target disk device for bare metal SL Micro installation.
MIRROR_{protocol} | string | | Specify source address
MM_MTU | integer | 1380 | Specifies the MTU to set in SUTs of MM tests usually started with `NICTYPE=tap`.
MOK_VERBOSITY | boolean | false | Enable verbosity feature of shim. Requires preinstalled `mokutil`.
Expand Down

0 comments on commit b92937b

Please sign in to comment.