Project

General

Profile

Actions

action #173935

closed

coordination #169654: [epic] Create test scenarios for Agama

Pass registration code to jsonnet files

Added by JERiveraMoya 18 days ago. Updated 10 days ago.

Status:
Resolved
Priority:
High
Assignee:
Target version:
-
Start date:
2024-12-09
Due date:
% Done:

0%

Estimated time:

Description

Motivation

In the same way than for AutoYaST we cannot store the regcode in control version, so we need some mechanism to replace one or more variables, like the registration code in the jsonnet profile

Acceptance criteria

  • AC1: Pass registration code to jsonnet files so we don't store the profiles with secrets in git.
  • AC2: Consider if creating new module or existing module can be reused.

Suggestions

Option 1) The ideal option probably would be to use jsonnet as described in https://jsonnet.org/learning/tutorial.html (External variables), but we need to see availability of jsonnet package in workers, for example:
default_tw.json:

local lib = import 'library-ext.libsonnet';
{
  "product": {
    "id": "Tumbleweed",
    "registrationCode": std.extVar('registrationCode')
  },
  "user": {
    "fullName": "Bernhard M. Wiedemann",
    "password": "nots3cr3t",
    "userName": "bernhard"
  },
  "root": {
    "password": "nots3cr3t"
  }
}

Then we run jsonnet --ext-str registrationCode="111222" default_tw.json > default_tw_with_reg_code.json
Option 2) As a second option we can just do what we do with AutoYaST with regex in Perl to replace.
This is probably good enough given that jsonnet (well actually is in a 'go' package which has the same functionality) can be used in local to create complex structrures and we don't need to submit the package for each architecture (only now is available in x86_64):
https://build.opensuse.org/package/show/openSUSE:Factory/golang-github-google-jsonnet

See conversations:
https://suse.slack.com/archives/C02TLF25571/p1733737967351989
https://suse.slack.com/archives/C02CLB2LB7Z/p1733728788435359


Files

import_profile_status_422.png (5.15 KB) import_profile_status_422.png status 422 lmanfredi, 2024-12-11 08:21
Actions #1

Updated by JERiveraMoya 18 days ago

  • Description updated (diff)
Actions #2

Updated by JERiveraMoya 18 days ago

  • Description updated (diff)
Actions #3

Updated by lmanfredi 18 days ago

  • Status changed from Workable to In Progress
  • Assignee set to lmanfredi
Actions #4

Updated by JERiveraMoya 17 days ago

  • Description updated (diff)
Actions #5

Updated by JERiveraMoya 17 days ago

  • Description updated (diff)
Actions #6

Updated by lmanfredi 17 days ago

For option 2 could be used the existing code inside lib/autoyast.pm: the sub expand_variables.
So, the json profile default_sle.json should contains:

{
  "product": {
    "id": "SLES_16.0",
    "registrationCode": "{{SCC_REGCODE}}"
  },
...
Actions #7

Updated by lmanfredi 17 days ago

And to replace the placeholder:

sub run {
    select_console 'root-console';
    my $profile = get_required_var('AGAMA_PROFILE');

    my $content = expand_variables(get_test_data($profile));
    my $profile_expanded = 'profile.json';
    save_tmp_file($profile_expanded, $content);
    my $profile_url = autoinst_url . "/files/$profile_expanded";
    assert_script_run("curl -ks $profile_url");

    script_run("dmesg --console-off");
    assert_script_run("/usr/bin/agama profile import $profile_url", timeout => 300);
    script_run("dmesg --console-on");
}
Actions #8

Updated by lmanfredi 17 days ago

for unattended installation, inside tests/yam/agama/boot_agama.pm a new method to replace the placeholder

sub expand_profile {
    my ($self, $profile) = @_;
    my $content = expand_variables(get_test_data($profile));
    my $profile_expanded = 'profile.json';
    save_tmp_file($profile_expanded, $content);
    my $profile_url = autoinst_url . "/files/$profile_expanded";
    return $profile_url;
}

...

   if (my $agama_auto = get_var('AGAMA_AUTO')) {
        my $path = $self->expand_profile($agama_auto);
        set_var('EXTRABOOTPARAMS', get_var('EXTRABOOTPARAMS', '') . " agama.auto=\"$path\"");
    }

Actions #9

Updated by lmanfredi 16 days ago

Created WIP PR#20773

Actions #10

Updated by lmanfredi 16 days ago

Adding the SCC into profile gives an error when imported (agama profile import ...) (tested through sles_full_disk_encryption test case):
status 422 "Product does not require registration"

Actions #11

Updated by lmanfredi 16 days ago

Using a profile without SCC but with the same branch code, works fine, so the failures could be related with the SCC in profile, probably not supported at the moment

Actions #12

Updated by lmanfredi 10 days ago

Removed WIP for PR#20773

Actions #13

Updated by lmanfredi 10 days ago

Merged PR#20773

Actions #14

Updated by JERiveraMoya 10 days ago

  • Status changed from In Progress to Resolved

Once registration is ready, please keep an eye to send some small adjustment in a PR if needed and of course cleaning the files without registration.
Let's resolve the ticket.

Actions

Also available in: Atom PDF