Skip to content

Commit

Permalink
grubport snippet fails for RHEL9
Browse files Browse the repository at this point in the history
Beaker users reported grub.cfg files being overwritten by Beaker
causing job failures.  I determined that this occurs only when
the system is configured with
    Install Options --> Kickstart Metadata --> grubport=0x03f8
This grubport config causes the grubport snippet to expand in the
kickstart file.  When looking at the two possible grub.cfg files,
it looks like RHEL team now using /boot/efi/EFI/redhat/grub.cfg as a
programmable link to /boot/grub2/grub.cfg file. To continue to
support configuration of serial port, this changeset will only try
to configure /boot/grub2/grub.cfg for RHEL9.  All other distros will
remain the unchanged.
  • Loading branch information
cbouchar committed Nov 22, 2024
1 parent b739685 commit 721efa4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions IntegrationTests/src/bkr/inttest/server/test_kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,32 @@ def test_grubport(self):
</job>
''', system)
self.assertIn('--port=0x02f8', recipe.installation.rendered_kickstart.kickstart)
self.assertIn('for file in /boot/grub2/grub.cfg /boot/efi/EFI/redhat/grub.cfg ; do', recipe.installation.rendered_kickstart.kickstart)

def test_grubport_rhel9(self):
system = data_setup.create_system(arch=u'x86_64', status=u'Automated',
lab_controller=self.lab_controller)
system.provisions[system.arch[0]] = Provision(arch=system.arch[0],
ks_meta=u'grubport=0x02f8')
recipe = self.provision_recipe('''
<job>
<whiteboard/>
<recipeSet>
<recipe>
<distroRequires>
<distro_name op="=" value="RHEL-9.0.0-20201122.0" />
<distro_variant op="=" value="BaseOS" />
<distro_arch op="=" value="x86_64" />
</distroRequires>
<hostRequires/>
<task name="/distribution/check-install" />
<task name="/distribution/reservesys" />
</recipe>
</recipeSet>
</job>
''', system)
self.assertIn('--port=0x02f8', recipe.installation.rendered_kickstart.kickstart)
self.assertIn('for file in /boot/grub2/grub.cfg ; do', recipe.installation.rendered_kickstart.kickstart)

def test_rhel5_devices(self):
system = data_setup.create_system(arch=u'x86_64', status=u'Automated',
Expand Down
4 changes: 4 additions & 0 deletions Server/bkr/server/snippets/grubport
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ done
# set --port for GRUB2
if [ -e "/etc/default/grub" ] ; then
sed --in-place=.orig -e '/^GRUB_SERIAL_COMMAND="serial/ {s/--unit=[0-9]\+//; s/"$/ --port={{ grubport }}"/}' /etc/default/grub
{% if distro.osversion.osmajor.name == 'RedHatEnterpriseLinux' and distro.osversion.osmajor.number | int >= 9 %}
for file in /boot/grub2/grub.cfg ; do
{% else %}
for file in /boot/grub2/grub.cfg /boot/efi/EFI/redhat/grub.cfg ; do
{% endif %}
if [ -f "$file" ] && [ ! -L "$file" ] ; then
grub2-mkconfig -o "$file"
fi
Expand Down

0 comments on commit 721efa4

Please sign in to comment.