diff --git a/lib/sles4sap_publiccloud.pm b/lib/sles4sap_publiccloud.pm index 5dd983cd449f..7d2dea44dc93 100644 --- a/lib/sles4sap_publiccloud.pm +++ b/lib/sles4sap_publiccloud.pm @@ -901,6 +901,8 @@ sub delete_network_peering { =item B - name of the container for PTF files (optional) +=item B - name of the LTSS extension to register. String has to be a valid one to be used to compose sles_modules variable, + then used as SUSEConnect or registercloudguest argument. Registration code for it will be get from SCC_REGCODE_LTSS variable. =back =cut @@ -921,14 +923,14 @@ sub create_playbook_section_list { my @playbook_list; unless ($args{registration} eq 'noreg') { + my @reg_args = ('registration.yaml'); + push @reg_args, '-e reg_code=' . get_required_var('SCC_REGCODE_SLES4SAP') . " -e email_address=''"; + push @reg_args, '-e use_suseconnect=true' if ($args{registration} eq 'suseconnect'); + push @reg_args, "-e sles_modules='[{\"key\":\"$args{ltss}\",\"value\":\"" . get_required_var('SCC_REGCODE_LTSS') . "\"}]'" if ($args{ltss}); + # Add registration module as first element - my $reg_code = '-e reg_code=' . get_required_var('SCC_REGCODE_SLES4SAP') . " -e email_address=''"; - if ($args{registration} eq 'suseconnect') { - push @playbook_list, "registration.yaml $reg_code -e use_suseconnect=true"; - } - else { - push @playbook_list, "registration.yaml $reg_code"; - } + push @playbook_list, join(' ', @reg_args); + # Add "fully patch system" module after registration module and before test start/configuration modules. # Temporary moved inside noreg condition to avoid test without Ansible to fails. # To be properly addressed in the caller and fully-patch-system can be placed back out of the if. diff --git a/t/12_sles4sap_publicccloud.t b/t/12_sles4sap_publicccloud.t index e167a387c21b..b2e8dcaaba5a 100644 --- a/t/12_sles4sap_publicccloud.t +++ b/t/12_sles4sap_publicccloud.t @@ -611,6 +611,19 @@ subtest '[create_playbook_section_list]' => sub { }; +subtest '[create_playbook_section_list] ltss' => sub { + set_var('SCC_REGCODE_SLES4SAP', 'Magellano'); + set_var('SCC_REGCODE_LTSS', 'Jofuku'); + set_var('USE_SAPCONF', 'Colombo'); + my $ansible_playbooks = create_playbook_section_list(ltss => 'XuFu'); + set_var('SCC_REGCODE_SLES4SAP', undef); + set_var('SCC_REGCODE_LTSS', undef); + set_var('USE_SAPCONF', undef); + note("\n --> " . join("\n --> ", @$ansible_playbooks)); + ok((any { /.*registration\.yaml.*sles_modules=.*key.*XuFu.*value.*Jofuku/ } @$ansible_playbooks), 'registration playbook is called with reg code from SCC_REGCODE_LTSS'); +}; + + subtest '[create_playbook_section_list] ha_enabled => 0' => sub { set_var('SCC_REGCODE_SLES4SAP', 'Magellano'); set_var('USE_SAPCONF', 'Colombo');