From dbcbc22a37e646cc1640e3cfd212e2f28ae1e67c Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 2 Dec 2024 13:32:25 -0500 Subject: [PATCH] Fixes #38053 - Remove syspurpose addons from Foreman * In https://github.com/Katello/katello/pull/11196 we removed syspurpose addons from Katello. I didn't realize we had them in Foreman too. --- app/services/foreman/renderer/scope/macros/base.rb | 6 +++--- app/services/foreman/template_snapshot_service.rb | 1 - .../provisioning_templates/snippet/kickstart_rhsm.erb | 4 +--- .../provisioning_templates/snippet/redhat_register.erb | 10 +--------- .../cloud-init/CloudInit_default.host4dhcp.snap.txt | 2 -- .../finish/Kickstart_default_finish.host4dhcp.snap.txt | 2 -- .../provision/Kickstart_default.host4and6dhcp.snap.txt | 2 -- .../provision/Kickstart_default.host4dhcp.snap.txt | 2 -- .../provision/Kickstart_default.host4static.snap.txt | 2 -- .../provision/Kickstart_default.host6dhcp.snap.txt | 2 -- .../provision/Kickstart_default.host6static.snap.txt | 2 -- .../provision/Kickstart_default.rhel9_dhcp.snap.txt | 2 +- .../provision/Kickstart_default.rocky8_dhcp.snap.txt | 2 -- .../provision/Kickstart_default.rocky9_dhcp.snap.txt | 2 -- .../snippet/kickstart_rhsm.rhel9_dhcp.snap.txt | 2 +- .../Kickstart_default_user_data.host4dhcp.snap.txt | 2 -- 16 files changed, 7 insertions(+), 38 deletions(-) diff --git a/app/services/foreman/renderer/scope/macros/base.rb b/app/services/foreman/renderer/scope/macros/base.rb index 54dda4787f3..4175d817723 100644 --- a/app/services/foreman/renderer/scope/macros/base.rb +++ b/app/services/foreman/renderer/scope/macros/base.rb @@ -201,7 +201,7 @@ def default_template_url(template, hostgroup) apipie :method, 'Returns an array of all possible host status classes sorted alphabetically by status name' do desc "Useful to generate a report on all host statuses." returns array_of: 'HostStatus', desc: 'Array of host status objects' - example "all_host_statuses # => [Katello::PurposeAddonsStatus, HostStatus::BuildStatus, ForemanOpenscap::ComplianceStatus, HostStatus::ConfigurationStatus, Katello::ErrataStatus, HostStatus::ExecutionStatus, Katello::PurposeRoleStatus, Katello::PurposeSlaStatus, Katello::SubscriptionStatus, Katello::PurposeStatus, Katello::TraceStatus, Katello::PurposeUsageStatus] " + example "all_host_statuses # => [HostStatus::BuildStatus, ForemanOpenscap::ComplianceStatus, HostStatus::ConfigurationStatus, Katello::ErrataStatus, HostStatus::ExecutionStatus, Katello::PurposeRoleStatus, Katello::PurposeSlaStatus, Katello::SubscriptionStatus, Katello::PurposeStatus, Katello::TraceStatus, Katello::PurposeUsageStatus] " end def all_host_statuses @all_host_statuses ||= HostStatus.status_registry.to_a.sort_by(&:status_name) @@ -210,7 +210,7 @@ def all_host_statuses apipie :method, 'Returns hash representing all statuses for a given host' do required :host, 'Host::Managed', desc: 'a host object to get the statuses for' returns object_of: Hash, desc: 'Hash representing all statuses for a given host' - example 'all_host_statuses(@host) # => {"Addons"=>0, "Build"=>1, "Compliance"=>0, "Configuration"=>0, "Errata"=>0, "Execution"=>1, "Role"=>0, "Service Level"=>0, "Subscription"=>0, "System Purpose"=>0, "Traces"=>0, "Usage"=>0}' + example 'all_host_statuses(@host) # => {"Build"=>1, "Compliance"=>0, "Configuration"=>0, "Errata"=>0, "Execution"=>1, "Role"=>0, "Service Level"=>0, "Subscription"=>0, "System Purpose"=>0, "Traces"=>0, "Usage"=>0}' example "<%- load_hosts.each_record do |host| -%>\n<%= host.name -%>, <%= all_host_statuses(host)['Subscription'] %>\n<%- end -%>" end def all_host_statuses_hash(host) @@ -220,7 +220,7 @@ def all_host_statuses_hash(host) apipie :method, 'Returns hash representing all statuses for a given host in human-readable format' do required :host, 'Host::Managed', desc: 'a host object to get the statuses for' returns object_of: Hash, desc: 'Hash representing all statuses for a given host in human-readable format' - example 'all_host_statuses_labels(@host) # => {"Addons"=>"Unknown", "Build"=>"Installed", "Compliance"=>"Not applicable", "Configuration"=>"No reports", "Errata"=>"Security errata applicable", "Execution"=>"Last execution succeeded", "Role"=>"Unknown", "Service Level"=>"Unknown", "Subscription"=>"Simple Content Access", "System Purpose"=>"Unknown", "Traces"=>"No processes require restarting", "Usage"=>"Unknown"}' + example 'all_host_statuses_labels(@host) # => {"Build"=>"Installed", "Compliance"=>"Not applicable", "Configuration"=>"No reports", "Errata"=>"Security errata applicable", "Execution"=>"Last execution succeeded", "Role"=>"Unknown", "Service Level"=>"Unknown", "Subscription"=>"Simple Content Access", "System Purpose"=>"Unknown", "Traces"=>"No processes require restarting", "Usage"=>"Unknown"}' example "<%- load_hosts.each_record do |host| -%>\n<%= host.name -%>, <%= all_host_statuses_labels(host)['Subscription'] %>\n<%- end -%>" end def all_host_statuses_labels_hash(host) diff --git a/app/services/foreman/template_snapshot_service.rb b/app/services/foreman/template_snapshot_service.rb index d2fe2c35b77..44dd9491993 100644 --- a/app/services/foreman/template_snapshot_service.rb +++ b/app/services/foreman/template_snapshot_service.rb @@ -82,7 +82,6 @@ def define_host_params(host) "syspurpose_role" => "Red Hat Enterprise Linux Server", "syspurpose_usage" => "Development/Test", "syspurpose_sla" => "Self-Support", - "syspurpose_addons" => "first addon, second addon, third addon", "ansible_user" => "win_ansible_user", "create_ansible_user" => "true", "ansible_ssh_pass" => "win_ansible_user_ssh_pass", diff --git a/app/views/unattended/provisioning_templates/snippet/kickstart_rhsm.erb b/app/views/unattended/provisioning_templates/snippet/kickstart_rhsm.erb index 60b074fadba..3b5278f8ed8 100644 --- a/app/views/unattended/provisioning_templates/snippet/kickstart_rhsm.erb +++ b/app/views/unattended/provisioning_templates/snippet/kickstart_rhsm.erb @@ -19,12 +19,10 @@ test_on: sys_role = " --role '#{host_param('syspurpose_role')}'" if host_param('syspurpose_role') sys_usage = " --usage '#{host_param('syspurpose_usage')}'" if host_param('syspurpose_usage') sys_sla = " --sla '#{host_param('syspurpose_sla')}'" if host_param('syspurpose_sla') - sys_addons = " #{host_param('syspurpose_addons').split(',') - .map { |add_on| "--addon '#{add_on.strip}'" }.join(" ")}" if host_param('syspurpose_addons') -%> <% if subman_registration -%> rhsm --organization="<%= subman_org %>" --activation-key="<%= subman_keys %>"<%= subman_hostname -%><%= subman_rhsm_baseurl -%><%= subman_insights -%> <% end -%> <%- if host_param('syspurpose_role') %> -syspurpose<%= sys_role %><%= sys_usage %><%= sys_sla %><%= sys_addons %> +syspurpose<%= sys_role %><%= sys_usage %><%= sys_sla %> <% end -%> diff --git a/app/views/unattended/provisioning_templates/snippet/redhat_register.erb b/app/views/unattended/provisioning_templates/snippet/redhat_register.erb index 08caa63436c..ecba6eb9a59 100644 --- a/app/views/unattended/provisioning_templates/snippet/redhat_register.erb +++ b/app/views/unattended/provisioning_templates/snippet/redhat_register.erb @@ -53,9 +53,6 @@ description: | syspurpose_sla Sets the system purpose SLA - syspurpose_addons Sets the system purpose add-ons. Separate multiple - values with commas. - Set these parameters if you're using rhnreg_ks: spacewalk_host = Hostname of Spacewalk server @@ -98,7 +95,7 @@ description: | # Set up subscription-manager <%= snippet("subscription_manager_setup", variables: { subman_setup_scenario: 'provisioning' }).strip -%> - <%- if (host_param('syspurpose_role') || host_param('syspurpose_usage') || host_param('syspurpose_sla') || host_param('syspurpose_addons')) -%> + <%- if (host_param('syspurpose_role') || host_param('syspurpose_usage') || host_param('syspurpose_sla')) -%> # Avoid timeout accessing unreachable repo on air gapped infrastructure, # assuming subscription-manager-syspurpose is installed in custom packages section. if ! rpm --query --quiet subscription-manager-syspurpose ; then @@ -115,11 +112,6 @@ description: | <%- if host_param('syspurpose_sla') -%> syspurpose set-sla "<%= host_param('syspurpose_sla') %>" <%- end -%> - <%- if host_param('syspurpose_addons') -%> - <%- addons = host_param('syspurpose_addons').split(',') - .map { |add_on| "'#{add_on.strip}'" }.join(" ") %> - syspurpose add-addons <%= addons %> - <%- end -%> else echo "Syspurpose CLI not found." fi diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/cloud-init/CloudInit_default.host4dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/cloud-init/CloudInit_default.host4dhcp.snap.txt index 3b508594c71..c4192a0b27c 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/cloud-init/CloudInit_default.host4dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/cloud-init/CloudInit_default.host4dhcp.snap.txt @@ -133,8 +133,6 @@ runcmd: syspurpose set-role "Red Hat Enterprise Linux Server" syspurpose set-usage "Development/Test" syspurpose set-sla "Self-Support" - - syspurpose add-addons 'first addon' 'second addon' 'third addon' else echo "Syspurpose CLI not found." fi diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/finish/Kickstart_default_finish.host4dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/finish/Kickstart_default_finish.host4dhcp.snap.txt index b57d71e0ef4..64e75eb0005 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/finish/Kickstart_default_finish.host4dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/finish/Kickstart_default_finish.host4dhcp.snap.txt @@ -118,8 +118,6 @@ systemctl try-restart yggdrasil >/dev/null 2>&1 || true syspurpose set-role "Red Hat Enterprise Linux Server" syspurpose set-usage "Development/Test" syspurpose set-sla "Self-Support" - - syspurpose add-addons 'first addon' 'second addon' 'third addon' else echo "Syspurpose CLI not found." fi diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4and6dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4and6dhcp.snap.txt index be2452f5185..c8cb2562ffb 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4and6dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4and6dhcp.snap.txt @@ -181,8 +181,6 @@ systemctl try-restart yggdrasil >/dev/null 2>&1 || true syspurpose set-role "Red Hat Enterprise Linux Server" syspurpose set-usage "Development/Test" syspurpose set-sla "Self-Support" - - syspurpose add-addons 'first addon' 'second addon' 'third addon' else echo "Syspurpose CLI not found." fi diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4dhcp.snap.txt index c9e6c1e838e..6a933bec20c 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4dhcp.snap.txt @@ -181,8 +181,6 @@ systemctl try-restart yggdrasil >/dev/null 2>&1 || true syspurpose set-role "Red Hat Enterprise Linux Server" syspurpose set-usage "Development/Test" syspurpose set-sla "Self-Support" - - syspurpose add-addons 'first addon' 'second addon' 'third addon' else echo "Syspurpose CLI not found." fi diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4static.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4static.snap.txt index 7f61105a1a2..a2de22c600e 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4static.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host4static.snap.txt @@ -181,8 +181,6 @@ systemctl try-restart yggdrasil >/dev/null 2>&1 || true syspurpose set-role "Red Hat Enterprise Linux Server" syspurpose set-usage "Development/Test" syspurpose set-sla "Self-Support" - - syspurpose add-addons 'first addon' 'second addon' 'third addon' else echo "Syspurpose CLI not found." fi diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host6dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host6dhcp.snap.txt index be890618fcd..f7f51f267cb 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host6dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host6dhcp.snap.txt @@ -181,8 +181,6 @@ systemctl try-restart yggdrasil >/dev/null 2>&1 || true syspurpose set-role "Red Hat Enterprise Linux Server" syspurpose set-usage "Development/Test" syspurpose set-sla "Self-Support" - - syspurpose add-addons 'first addon' 'second addon' 'third addon' else echo "Syspurpose CLI not found." fi diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host6static.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host6static.snap.txt index 26441f46777..df5ff8656ab 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host6static.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.host6static.snap.txt @@ -181,8 +181,6 @@ systemctl try-restart yggdrasil >/dev/null 2>&1 || true syspurpose set-role "Red Hat Enterprise Linux Server" syspurpose set-usage "Development/Test" syspurpose set-sla "Self-Support" - - syspurpose add-addons 'first addon' 'second addon' 'third addon' else echo "Syspurpose CLI not found." fi diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rhel9_dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rhel9_dhcp.snap.txt index 1e085c2270e..2149eea4ddb 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rhel9_dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rhel9_dhcp.snap.txt @@ -30,7 +30,7 @@ part /boot --fstype ext3 --size=100 --asprimary part / --fstype ext3 --size=1024 --grow part swap --recommended rhsm --organization="Org" --activation-key="key" --connect-to-insights -syspurpose --role 'Red Hat Enterprise Linux Server' --usage 'Development/Test' --sla 'Self-Support' --addon 'first addon' --addon 'second addon' --addon 'third addon' +syspurpose --role 'Red Hat Enterprise Linux Server' --usage 'Development/Test' --sla 'Self-Support' skipx text diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rocky8_dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rocky8_dhcp.snap.txt index e012180d5b3..3fbc91f2a10 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rocky8_dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rocky8_dhcp.snap.txt @@ -179,8 +179,6 @@ systemctl try-restart yggdrasil >/dev/null 2>&1 || true syspurpose set-role "Red Hat Enterprise Linux Server" syspurpose set-usage "Development/Test" syspurpose set-sla "Self-Support" - - syspurpose add-addons 'first addon' 'second addon' 'third addon' else echo "Syspurpose CLI not found." fi diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rocky9_dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rocky9_dhcp.snap.txt index a5fe55fd3a5..1efac828a61 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rocky9_dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/Kickstart_default.rocky9_dhcp.snap.txt @@ -178,8 +178,6 @@ systemctl try-restart yggdrasil >/dev/null 2>&1 || true syspurpose set-role "Red Hat Enterprise Linux Server" syspurpose set-usage "Development/Test" syspurpose set-sla "Self-Support" - - syspurpose add-addons 'first addon' 'second addon' 'third addon' else echo "Syspurpose CLI not found." fi diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/snippet/kickstart_rhsm.rhel9_dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/snippet/kickstart_rhsm.rhel9_dhcp.snap.txt index aa967e1461e..43a6b826832 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/snippet/kickstart_rhsm.rhel9_dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/snippet/kickstart_rhsm.rhel9_dhcp.snap.txt @@ -1,2 +1,2 @@ rhsm --organization="Org" --activation-key="key" --connect-to-insights -syspurpose --role 'Red Hat Enterprise Linux Server' --usage 'Development/Test' --sla 'Self-Support' --addon 'first addon' --addon 'second addon' --addon 'third addon' +syspurpose --role 'Red Hat Enterprise Linux Server' --usage 'Development/Test' --sla 'Self-Support' diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/user_data/Kickstart_default_user_data.host4dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/user_data/Kickstart_default_user_data.host4dhcp.snap.txt index 97b0e87430e..1d81bfca6fc 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/user_data/Kickstart_default_user_data.host4dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/user_data/Kickstart_default_user_data.host4dhcp.snap.txt @@ -132,8 +132,6 @@ systemctl try-restart yggdrasil >/dev/null 2>&1 || true syspurpose set-role "Red Hat Enterprise Linux Server" syspurpose set-usage "Development/Test" syspurpose set-sla "Self-Support" - - syspurpose add-addons 'first addon' 'second addon' 'third addon' else echo "Syspurpose CLI not found." fi