From 287de7375df7cce9385e0fe59168a58dd53258de Mon Sep 17 00:00:00 2001 From: Alexander Olofsson Date: Sat, 25 Nov 2023 15:41:18 +0100 Subject: [PATCH] Fixes #36947 - Support openSUSE Leap 15 --- .../iPXE/autoyast_default_ipxe.erb | 18 ++-- .../provision/autoyast_default.erb | 101 +++++++++++++++--- .../snippet/puppet.conf.erb | 2 +- .../AutoYaST_default_iPXE.host4dhcp.snap.txt | 4 +- .../AutoYaST_default.host4dhcp.snap.txt | 8 +- 5 files changed, 105 insertions(+), 28 deletions(-) diff --git a/app/views/unattended/provisioning_templates/iPXE/autoyast_default_ipxe.erb b/app/views/unattended/provisioning_templates/iPXE/autoyast_default_ipxe.erb index 9f8246127c36..f07670973b6c 100644 --- a/app/views/unattended/provisioning_templates/iPXE/autoyast_default_ipxe.erb +++ b/app/views/unattended/provisioning_templates/iPXE/autoyast_default_ipxe.erb @@ -18,6 +18,15 @@ if host_param('http-proxy') && host_param('http-proxy-port') elsif host_param('http-proxy') extra_args << "proxy=http://" + host_param('http-proxy') end + +subnet = @host.subnet +if subnet.respond_to?(:dhcp_boot_mode?) && subnet.dhcp_boot_mode? + extra_args << "useDHCP=1" +else + extra_args << "netsetup=-dhcp" + extra_args << "ifcfg=*=\"${netX/ip}/#{@host.primary_interface.subnet.cidr},${netX/gateway},${dns},#{@host.domain}\"" +end +extra_args << "BOOTIF=01-${netX/mac:hexhyp}" -%> echo Trying to ping Gateway: ${netX/gateway} ping --count 1 ${netX/gateway} || echo Ping to Gateway failed or ping command not available. @@ -28,11 +37,6 @@ ping --count 1 ${netX/dns} || echo Ping to DNS failed or ping command not availa <% kernel = boot_files_uris[0] -%> <% initrd = boot_files_uris[1] -%> -<% subnet = @host.subnet -%> -<% if subnet.respond_to?(:dhcp_boot_mode?) && subnet.dhcp_boot_mode? -%> -kernel <%= kernel %> initrd=initrd.img splash=silent install=<%= medium_uri %> autoyast=<%= foreman_url('provision') %> text-mode=1 useDHCP=1 <%= extra_args.join(' ')%> -<% else -%> -kernel <%= kernel %> initrd=initrd.img splash=silent install=<%= medium_uri %> autoyast=<%= foreman_url('provision') %> text-mode=1 useDHCP=0 netsetup=-dhcp ifcfg=*="${netX/ip}/<%= @host.primary_interface.subnet.cidr -%>,${netX/gateway},${dns},<%= @host.domain %>" <%= extra_args.join(' ')%> -<% end -%> -initrd <%= initrd %> +kernel <%= kernel %> initrd=initrd.img splash=silent install=<%= medium_uri %> autoyast=<%= foreman_url('provision') %> text-mode=1 <%= extra_args.join(' ')%> +initrd --name initrd.img <%= initrd %> boot diff --git a/app/views/unattended/provisioning_templates/provision/autoyast_default.erb b/app/views/unattended/provisioning_templates/provision/autoyast_default.erb index 11824ed5e45d..2542d21f2886 100644 --- a/app/views/unattended/provisioning_templates/provision/autoyast_default.erb +++ b/app/views/unattended/provisioning_templates/provision/autoyast_default.erb @@ -9,9 +9,11 @@ description: | -%> <% # safemode renderer does not support unary negation + aio_enabled = host_param_true?('enable-puppetlabs-repo') || %w[official-puppet8 official-puppet7].any? { |repo| host_param_true?("enable-#{repo}-repo") } puppet_enabled = !host_param_true?('skip-puppet-setup') && (host_puppet_server.present? || host_param_true?('force-puppet')) salt_enabled = host_param('salt_master') ? true : false os_major = @host.operatingsystem.major.to_i + os_minor = @host.operatingsystem.minor.to_i primary_interface_identifier = @host.primary_interface.identifier.blank? ? 'eth0' : @host.primary_interface.identifier primary_interface_subnet = @host.primary_interface.subnet -%> @@ -29,7 +31,9 @@ description: | <%= @host.name %> <% unless primary_interface_subnet.dhcp_boot_mode? -%> false +<% if os_major < 12 -%> false +<% end -%> <% if @host.domain -%> <%= @host.domain -%> <% end -%> @@ -96,9 +100,18 @@ description: | <% end -%> - <%# NTP client configuration has incompatible changes in Leap 15 -%> - <% if os_major <= 12 || os_major == 42 -%> +<% if os_major >= 15 -%> + auto + + +
<%= host_param('ntp-server') || '0.opensuse.pool.ntp.org' %>
+ false + true +
+
+ 15 +<% else -%> false @@ -110,23 +123,21 @@ description: | true true -
-<% else -%> - - auto - - - false -
<%= host_param('ntp-server') || '0.opensuse.pool.ntp.org' %>
- true -
-
- systemd -
<% end -%> + <% if ! @dynamic -%> - <%= @host.diskLayout %> +<%= @host.diskLayout %> <% end -%> +<% if os_major >= 15 -%> + + multi-user + + + sshd + + + +<% else -%> 3 @@ -136,8 +147,11 @@ description: | +<% end -%> +<% if os_major < 15 -%> default +<% end -%> base enhanced_base @@ -147,8 +161,12 @@ description: | lsb-release <% if puppet_enabled -%> +<% if aio_enabled -%> + puppet-agent +<% else -%> rubygem-puppet <% end -%> +<% end -%> <% if host_param('additional-packages').present? -%> <%= host_param('additional-packages').split(" ").collect{|x| "#{x}" }.join("\n") %> <% end -%> @@ -181,6 +199,7 @@ description: | <% end -%> +<% if os_major < 15 -%> +<% end -%> +<% if os_major >= 15 -%> + + true + off + public + + + public + + ssh + dhcpv6-client + + + + +<% end -%> english-us @@ -231,4 +267,37 @@ rm /etc/resolv.conf UTC <%= host_param('time-zone') || 'Etc/UTC' %> + + +<% if puppet_enabled && aio_enabled -%> +<% + puppet_repo_url_base = 'https://yum.puppet.com' + if host_param_true?('enable-official-puppet8-repo') + puppet_repo_url = "#{puppet_repo_url_base}/puppet8/sles/#{os_major}/#{@host.architecture}/" + puppet_repo_alias = 'puppet8-release' + elsif host_param_true?('enable-official-puppet7-repo') + puppet_repo_url = "#{puppet_repo_url_base}/puppet7/sles/#{os_major}/#{@host.architecture}/" + puppet_repo_alias = 'puppet7-release' + else + puppet_repo_url = "#{puppet_repo_url_base}/puppet/sles/#{os_major}/#{@host.architecture}/" + puppet_repo_alias = 'puppet-release' + end +-%> + + ]]> + <%= puppet_repo_alias %> + Puppet AutoYaST repository + + + false + + 7F438280EF8D349F + 4528B6CD9E61EF26 + + + + +<% end -%> + + diff --git a/app/views/unattended/provisioning_templates/snippet/puppet.conf.erb b/app/views/unattended/provisioning_templates/snippet/puppet.conf.erb index 5a7bd5bade35..5fe8a26ee221 100644 --- a/app/views/unattended/provisioning_templates/snippet/puppet.conf.erb +++ b/app/views/unattended/provisioning_templates/snippet/puppet.conf.erb @@ -13,7 +13,7 @@ description: | os_name = @host.operatingsystem.name aio_enabled = host_param_true?('enable-puppetlabs-repo') || host_param_true?('enable-official-puppet8-repo') || host_param_true?('enable-official-puppet7-repo') || host_param_true?('enable-puppet7') || host_param_true?('enable-puppetlabs-puppet6-repo') || host_param_true?('enable-puppet6') || host_param_true?('enable-puppetlabs-puppet5-repo') || host_param_true?('enable-puppet5') - aio_available = os_family == 'Debian' || os_family == 'Redhat' || os_name == 'SLES' + aio_available = os_family == 'Debian' || os_family == 'Redhat' || os_family == 'Suse' if os_family == 'Windows' var_dir = 'C:\ProgramData\PuppetLabs\puppet\cache' diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/iPXE/AutoYaST_default_iPXE.host4dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/iPXE/AutoYaST_default_iPXE.host4dhcp.snap.txt index 0666d2677450..b2f5a23b392d 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/iPXE/AutoYaST_default_iPXE.host4dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/iPXE/AutoYaST_default_iPXE.host4dhcp.snap.txt @@ -5,6 +5,6 @@ echo Trying to ping DNS: ${netX/dns} ping --count 1 ${netX/dns} || echo Ping to DNS failed or ping command not available. -kernel http://mirror.centos.org/centos/7/os/x86_64/images/pxeboot/vmlinuz initrd=initrd.img splash=silent install=http://mirror.centos.org/centos/7/os/x86_64 autoyast=http://foreman.example.com/unattended/provision text-mode=1 useDHCP=1 -initrd http://mirror.centos.org/centos/7/os/x86_64/images/pxeboot/initrd.img +kernel http://mirror.centos.org/centos/7/os/x86_64/images/pxeboot/vmlinuz initrd=initrd.img splash=silent install=http://mirror.centos.org/centos/7/os/x86_64 autoyast=http://foreman.example.com/unattended/provision text-mode=1 useDHCP=1 BOOTIF=01-${netX/mac:hexhyp} +initrd --name initrd.img http://mirror.centos.org/centos/7/os/x86_64/images/pxeboot/initrd.img boot diff --git a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/AutoYaST_default.host4dhcp.snap.txt b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/AutoYaST_default.host4dhcp.snap.txt index 348e096ff335..e931149ae8e1 100644 --- a/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/AutoYaST_default.host4dhcp.snap.txt +++ b/test/unit/foreman/renderer/snapshots/ProvisioningTemplate/provision/AutoYaST_default.host4dhcp.snap.txt @@ -18,7 +18,7 @@ - + false @@ -31,7 +31,7 @@ true true - zerombr +zerombr clearpart --all --initlabel part /boot --fstype ext3 --size=100 --asprimary part / --fstype ext3 --size=1024 --grow @@ -154,4 +154,8 @@ rm /etc/resolv.conf UTC Etc/UTC + + + +