action #173935
closedcoordination #169654: [epic] Create test scenarios for Agama
Pass registration code to jsonnet files
0%
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
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");
}
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\"");
}
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.