Skip to content

Commit

Permalink
only run module stuff on el8
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni authored and ehelms committed Feb 22, 2024
1 parent 6078740 commit 3237d9b
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 12 deletions.
6 changes: 4 additions & 2 deletions definitions/scenarios/upgrade_to_capsule_6_16.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class PreMigrations < Abstract

def compose
add_step(Procedures::Repositories::Setup.new(:version => '6.16'))
modules_to_enable = ["satellite-capsule:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
if el8?
modules_to_enable = ["satellite-capsule:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
end
add_step(Procedures::Packages::Update.new(
:assumeyes => true,
:dnf_options => ['--downloadonly']
Expand Down
6 changes: 4 additions & 2 deletions definitions/scenarios/upgrade_to_capsule_6_16_z.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class PreMigrations < Abstract

def compose
add_step(Procedures::Repositories::Setup.new(:version => '6.16'))
modules_to_enable = ["satellite-capsule:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
if el8?
modules_to_enable = ["satellite-capsule:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
end
add_step(Procedures::Packages::Update.new(
:assumeyes => true,
:dnf_options => ['--downloadonly']
Expand Down
2 changes: 1 addition & 1 deletion definitions/scenarios/upgrade_to_foreman_nightly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def set_context_mapping

def compose
add_step(Procedures::Repositories::Setup.new(:version => 'nightly'))
if el?
if el8?
modules_to_enable = ["foreman:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
end
Expand Down
6 changes: 4 additions & 2 deletions definitions/scenarios/upgrade_to_katello_nightly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def set_context_mapping

def compose
add_step(Procedures::Repositories::Setup.new(:version => 'nightly'))
modules_to_enable = ["katello:#{el_short_name}", "pulpcore:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
if el8?
modules_to_enable = ["katello:#{el_short_name}", "pulpcore:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
end
add_step(Procedures::Packages::Update.new(
:assumeyes => true,
:dnf_options => ['--downloadonly']
Expand Down
6 changes: 4 additions & 2 deletions definitions/scenarios/upgrade_to_satellite_6_16.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class PreMigrations < Abstract

def compose
add_step(Procedures::Repositories::Setup.new(:version => '6.16'))
modules_to_enable = ["satellite:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
if el8?
modules_to_enable = ["satellite:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
end
add_step(Procedures::Packages::Update.new(
:assumeyes => true,
:dnf_options => ['--downloadonly']
Expand Down
6 changes: 4 additions & 2 deletions definitions/scenarios/upgrade_to_satellite_6_16_z.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ class PreMigrations < Abstract

def compose
add_step(Procedures::Repositories::Setup.new(:version => '6.16'))
modules_to_enable = ["satellite:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
if el8?
modules_to_enable = ["satellite:#{el_short_name}"]
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
end
add_step(Procedures::Packages::Update.new(
:assumeyes => true,
:dnf_options => ['--downloadonly']
Expand Down
2 changes: 1 addition & 1 deletion lib/foreman_maintain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def perform_self_upgrade
end

def enable_maintenance_module
return unless el?
return unless el8?

maintenance_module = 'satellite-maintenance:el8'
package_manager = ForemanMaintain.package_manager
Expand Down
4 changes: 4 additions & 0 deletions lib/foreman_maintain/concerns/os_facts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def el?
File.exist?('/etc/redhat-release')
end

def el8?
el_major_version == 8
end

def debian?
os_id == 'debian'
end
Expand Down
13 changes: 13 additions & 0 deletions test/lib/foreman_maintain_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

describe 'enable_maintenance_module' do
before do
subject.stubs(:el8?).returns(true)
subject.stubs(:el?).returns(true)
end

Expand Down Expand Up @@ -66,6 +67,18 @@
subject.enable_maintenance_module
end
end

it 'should not enable the maintenance module on el9' do
subject.stubs(:el8?).returns(false)
package_manager.any_instance.stubs(:module_exists?).returns(false)
package_manager.any_instance.stubs(:module_enabled?).returns(false)

package_manager.any_instance.expects(:enable_module).with('satellite-maintenance:el8').never

assert_output('') do
subject.enable_maintenance_module
end
end
end

describe '#main_package_name' do
Expand Down

0 comments on commit 3237d9b

Please sign in to comment.