Skip to content

Commit

Permalink
Add ipv6 disable check
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed May 14, 2024
1 parent 258aac2 commit c2fa234
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 0 deletions.
23 changes: 23 additions & 0 deletions definitions/checks/check_ipv6_disable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Checks::CheckIpv6Disable < ForemanMaintain::Check
metadata do
label :check_ipv6_disable
description 'Check if ipv6.disable=1 is set at kernel level'
end

def run
grub_file = File.read('/etc/default/grub')

assert(!grub_file.include?("ipv6.disable=1"), error_message)
end

def error_message
base = "\nThe kernel contains ipv6.disable=1 which is known to break installation and upgrade"\
", remove and reboot before continuining."

if feature(:instance).downstream
base += " See https://access.redhat.com/solutions/5045841 for more details."
end

base
end
end
1 change: 1 addition & 0 deletions definitions/scenarios/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def compose
Checks::SystemRegistration,
Checks::CheckHotfixInstalled,
Checks::CheckTmout,
Checks::CheckIpv6Disable,
Checks::CheckUpstreamRepository,
Checks::Disk::AvailableSpace,
Checks::Disk::AvailableSpaceCandlepin, # if candlepin
Expand Down
1 change: 1 addition & 0 deletions definitions/scenarios/upgrade_to_capsule_6_16.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PreUpgradeCheck < Abstract
def compose
add_steps(find_checks(:default))
add_steps(find_checks(:pre_upgrade))
add_step(Checks::CheckIpv6Disable)
add_step(Checks::Disk::AvailableSpacePostgresql13)
add_step(Checks::Repositories::Validate.new(:version => '6.16'))
end
Expand Down
1 change: 1 addition & 0 deletions definitions/scenarios/upgrade_to_capsule_6_16_z.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PreUpgradeCheck < Abstract
def compose
add_steps(find_checks(:default))
add_steps(find_checks(:pre_upgrade))
add_step(Checks::CheckIpv6Disable)
add_step(Checks::Repositories::Validate.new(:version => '6.16'))
end
end
Expand Down
1 change: 1 addition & 0 deletions definitions/scenarios/upgrade_to_satellite_6_16.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PreUpgradeCheck < Abstract
def compose
add_steps(find_checks(:default))
add_steps(find_checks(:pre_upgrade))
add_step(Checks::CheckIpv6Disable)
add_step(Checks::Disk::AvailableSpacePostgresql13)
add_step(Checks::Repositories::Validate.new(:version => '6.16'))
add_step(Checks::CheckOrganizationContentAccessMode)
Expand Down
1 change: 1 addition & 0 deletions definitions/scenarios/upgrade_to_satellite_6_16_z.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PreUpgradeCheck < Abstract
def compose
add_steps(find_checks(:default))
add_steps(find_checks(:pre_upgrade))
add_step(Checks::CheckIpv6Disable)
add_step(Checks::Repositories::Validate.new(:version => '6.16'))
end
end
Expand Down
32 changes: 32 additions & 0 deletions test/definitions/checks/check_ipv6_disable_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'test_helper'

describe Checks::CheckIpv6Disable do
include DefinitionsTestHelper

subject { Checks::CheckIpv6Disable.new }

context 'throw an error message when ipv6.disable=1 is set' do
before do
File.expects(:read).with('/etc/default/grub').returns('ipv6.disable=1')
end

it 'system is self registered' do
result = run_step(subject)
msg = 'test'

assert result.fail?, msg
end
end

context 'success when ipv6.disable=1 is not set' do
before do
File.expects(:read).with('/etc/default/grub').returns('test.net=0')
end

it 'system is self registered' do
result = run_step(subject)

assert result.success?
end
end
end

0 comments on commit c2fa234

Please sign in to comment.