Skip to content

Commit

Permalink
Fixes #36525 - kickstart's RHSM line only works on RHEL hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
jcpunk committed Apr 16, 2024
1 parent 7d5fb02 commit 8a29803
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,28 @@ runcmd:
<%= indent(2) { snippet 'yum_proxy' } -%>
- |
<%= indent(2) { snippet 'ntp' } -%>
<% if rhel_compatible -%>
<% if host_param_true?('enable-epel') -%>
- |
<% if rhel_compatible && host_param_true?('enable-epel') -%>
<%= indent(2) { snippet 'epel' } -%>
<% end -%>
- |
<%= indent(2) { snippet 'redhat_register' } -%>
- |
<% end -%>
<% if host_enc['parameters']['realm'] && @host.realm && (@host.realm.realm_type == 'FreeIPA' || @host.realm.realm_type == 'Red Hat Identity Management') -%>
- |
<%= indent(2) { snippet 'freeipa_register' } %>
<% end -%>
- |
<%= indent(2) { snippet 'remote_execution_ssh_keys' } %>
- |
<%= indent(2) { snippet 'blacklist_kernel_modules' } %>
<% if chef_enabled -%>
- |
<% if chef_enabled %>
<%= indent(2) { snippet 'chef_client' } %>
<% end -%>
<% if puppet_enabled -%>
- |
<% if puppet_enabled %>
<% if host_param_true?('enable-puppetlabs-repo') || host_param_true?('enable-official-puppet8-repo') || host_param_true?('enable-official-puppet7-repo') || host_param_true?('enable-puppetlabs-puppet6-repo') || host_param_true?('enable-puppetlabs-puppet5-repo') -%>
<%= indent(2) { snippet 'puppetlabs_repo' } %>
<% end -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ description: |
use_ntp = host_param_true?('use-ntp', (is_fedora && os_major < 16) || (rhel_compatible && os_major <= 6))
iface = @host.provision_interface
appstream_present = false
use_rhsm = (@host.operatingsystem.name == 'RedHat' || @host.operatingsystem.name == 'RHEL') && os_major >= 8
-%>
# This kickstart file was rendered from the Foreman provisioning template "<%= @template_name %>".
# for <%= @host %> running <%= @host.operatingsystem.name %> <%= os_major %> <%= @arch %>
Expand Down Expand Up @@ -235,7 +236,7 @@ key --skip
<% else -%>
<%= @host.diskLayout %>
<% end -%>
<%= snippet('kickstart_rhsm') if rhel_compatible && os_major >= 9 -%>
<%= snippet('kickstart_rhsm') if use_rhsm -%>
<% if host_param_true?('use_graphical_installer') -%>
graphical
Expand Down Expand Up @@ -309,7 +310,7 @@ logger "Starting anaconda <%= @host %> postinstall"
<%= snippet 'epel' -%>
<% end -%>
<%= snippet 'redhat_register' if rhel_compatible && os_major < 9 -%>
<%= snippet 'redhat_register' if rhel_compatible && !use_rhsm -%>
<% if host_enc['parameters']['realm'] && @host.realm && (@host.realm.realm_type == 'FreeIPA' || @host.realm.realm_type == 'Red Hat Identity Management') -%>
<%= snippet 'freeipa_register' %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ description: |
spacewalk_host = <hostname> Hostname of Spacewalk server
-%>
<%
# Katello or subscription-manager:
if host_param_true?('subscription_manager') || host_param('kt_activation_keys')
registration_type = 'subscription_manager'
# Spacewalk:
elsif host_param('spacewalk_host')
registration_type = 'spacewalk'
end if
%>
<% if registration_type == 'subscription_manager' %>
else
registration_type = nil
end
-%>
# registration_type = '<%= registration_type %>'
<% if registration_type == 'subscription_manager' -%>
<%
if host_param('kt_activation_keys')
subscription_manager_certpkg_url = subscription_manager_configuration_url(@host)
Expand All @@ -86,7 +87,7 @@ description: |
redhat_install_host_tools = host_param_true?('redhat_install_host_tools')
redhat_install_host_tracer_tools = host_param_true?('redhat_install_host_tracer_tools')
end
%>
-%>

echo "##############################################################"
echo "################# SUBSCRIPTION MANAGER #######################"
Expand All @@ -97,61 +98,61 @@ 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') || host_param('syspurpose_addons')) -%>
# 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
$PKG_MANAGER_INSTALL subscription-manager-syspurpose
fi

if [ -f /usr/sbin/syspurpose ]; then
<%- if host_param('syspurpose_role') %>
<%- if host_param('syspurpose_role') -%>
syspurpose set-role "<%= host_param('syspurpose_role') %>"
<%- end %>
<%- if host_param('syspurpose_usage') %>
<%- end -%>
<%- if host_param('syspurpose_usage') -%>
syspurpose set-usage "<%= host_param('syspurpose_usage') %>"
<%- end %>
<%- if host_param('syspurpose_sla') %>
<%- end -%>
<%- if host_param('syspurpose_sla') -%>
syspurpose set-sla "<%= host_param('syspurpose_sla') %>"
<%- end %>
<%- if host_param('syspurpose_addons') %>
<%- end -%>
<%- if host_param('syspurpose_addons') -%>
<%- addons = host_param('syspurpose_addons').split(',')
.map { |add_on| "'#{add_on.strip}'" }.join(" ") %>
syspurpose add-addons <%= addons %>
<%- end %>
<%- end -%>
else
echo "Syspurpose CLI not found."
fi
<% end %>
<% end -%>
<% if host_param('http-proxy') %>
<% if host_param('http-proxy') -%>
subscription-manager config --server.proxy_hostname='<%= host_param("http-proxy") %>'
<% if host_param('http-proxy-user') %>
<% if host_param('http-proxy-user') -%>
subscription-manager config --server.proxy_user='<%= host_param("http-proxy-user") %>'
<% end %>
<% if host_param('http-proxy-password') %>
<% end -%>
<% if host_param('http-proxy-password') -%>
subscription-manager config --server.proxy_password='<%= host_param("http-proxy-password") %>'
<% end %>
<% if host_param('http-proxy-port') %>
<% end -%>
<% if host_param('http-proxy-port') -%>
subscription-manager config --server.proxy_port='<%= host_param("http-proxy-port") %>'
<% end %>
<% end %>
<% end -%>
<% end -%>
<% if host_param('subscription_manager_username') && host_param('subscription_manager_password') %>
<% if host_param('subscription_manager_pool') %>
<% if host_param('subscription_manager_username') && host_param('subscription_manager_password') -%>
<% if host_param('subscription_manager_pool') -%>
subscription-manager register --name="<%= @host.name %>" --username='<%= host_param("subscription_manager_username") %>' --password='<%= host_param("subscription_manager_password") %>'
subscription-manager attach --pool='<%= host_param('subscription_manager_pool') %>'
<% else %>
<% else -%>
subscription-manager register --name="<%= @host.name %>" --username='<%= host_param("subscription_manager_username") %>' --password='<%= host_param("subscription_manager_password") %>' --auto-attach
<% end %>
<% end -%>
<% elsif activation_key %>
<% elsif activation_key -%>
subscription-manager register --name="<%= @host.name %>" --org='<%= subscription_manager_org %>' --activationkey='<%= activation_key %>'
<% else %>
<% else -%>
echo "No activation key found: Not registering to subscription manager"
<% end %>
<% end -%>
<% if host_param_true?('only_subscription_manager_repos') %>
<% if host_param_true?('only_subscription_manager_repos') -%>
for subman_config_file in /etc/yum/pluginconf.d/subscription-manager.conf /etc/dnf/plugins/subscription-manager.conf; do
if [ -f $subman_config_file ]; then
egrep -q "^disable_system_repos=" $subman_config_file
Expand All @@ -163,39 +164,39 @@ description: |
fi
fi
done
<% end %>
<% end -%>
<% if host_param_true?('subscription_manager_auto_attach', false) -%>
subscription-manager attach --auto

<% end -%>
<% if host_param('subscription_manager_repos') %>
<% if host_param('subscription_manager_repos') -%>
# workaround for RHEL 6.4 bug https://bugzilla.redhat.com/show_bug.cgi?id=1008016
subscription-manager repos --list > /dev/null
<%= "subscription-manager repos --enable #{host_param('subscription_manager_repos').gsub(/,\s*/, ' --enable ')}" %>
<% end %>
<% end -%>
<% if host_param('subscription_manager_override_repos_cost') %>
<% if host_param('subscription_manager_override_repos_cost') -%>
for repo in $(subscription-manager repos --list-enabled | grep "Repo ID:" | awk -F' ' '{ print $3 }'); do
<%= "subscription-manager repo-override --list --repo $repo | grep 'cost:' &>/dev/null || subscription-manager repo-override --repo $repo --add=cost:#{host_param('subscription_manager_override_repos_cost')}" %>
done
<% end %>
<% end -%>
<% if redhat_install_host_tools %>
<% if redhat_install_host_tools -%>
$PKG_MANAGER_INSTALL katello-host-tools
<% end %>
<% end -%>
<% if redhat_install_host_tracer_tools %>
<% if redhat_install_host_tracer_tools -%>
$PKG_MANAGER_INSTALL katello-host-tools-tracer
<% end %>
<% end %>
<% end -%>
<% end -%>
<% if registration_type == 'spacewalk' %>
<% if registration_type == 'spacewalk' -%>
echo "##############################################################"
echo "################ SPACEWALK REGISTRATION ######################"
echo "##############################################################"

<% if host_param('activation_key') %>
<% if host_param('activation_key') -%>
rhn_activation_key="<%= host_param('activation_key') -%>"
satellite_hostname="<%= host_param('spacewalk_host') -%>"
rhn_cert_file="RHN-ORG-TRUSTED-SSL-CERT"
Expand Down Expand Up @@ -246,7 +247,7 @@ description: |
echo "registration successful."
fi

<% else %>
<% else -%>
echo "No activation key found: Not registering"
<% end %>
<% end %>
<% end -%>
<% end -%>
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ runcmd:
- |
- |






- |
- |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ runcmd:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- |






- |
- |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ runcmd:
- |
- |






- |
- |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm








# update all the base packages from the updates repository
if [ -f /usr/bin/dnf ]; then
dnf -y update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm








# update all the base packages from the updates repository
if [ -f /usr/bin/dnf ]; then
dnf -y update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm








# update all the base packages from the updates repository
if [ -f /usr/bin/dnf ]; then
dnf -y update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm








# update all the base packages from the updates repository
if [ -f /usr/bin/dnf ]; then
dnf -y update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm








# update all the base packages from the updates repository
if [ -f /usr/bin/dnf ]; then
dnf -y update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm








# update all the base packages from the updates repository
if [ -f /usr/bin/dnf ]; then
dnf -y update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm








# update all the base packages from the updates repository
if [ -f /usr/bin/dnf ]; then
dnf -y update
Expand Down

0 comments on commit 8a29803

Please sign in to comment.