From fa78f3234f8f8abaf9db6ecf3a46124cc12da095 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Thu, 2 May 2024 16:54:43 -0400 Subject: [PATCH] Combine Satellite and Capsule into a single scenario --- .../procedures/installer/upgrade_rake_task.rb | 7 +- ...satellite_6_16.rb => satellite_upgrade.rb} | 19 ++-- .../scenarios/upgrade_to_capsule_6_16.rb | 100 ------------------ 3 files changed, 13 insertions(+), 113 deletions(-) rename definitions/scenarios/{upgrade_to_satellite_6_16.rb => satellite_upgrade.rb} (80%) delete mode 100644 definitions/scenarios/upgrade_to_capsule_6_16.rb diff --git a/definitions/procedures/installer/upgrade_rake_task.rb b/definitions/procedures/installer/upgrade_rake_task.rb index 488fad8eb..dbca8efc3 100644 --- a/definitions/procedures/installer/upgrade_rake_task.rb +++ b/definitions/procedures/installer/upgrade_rake_task.rb @@ -2,12 +2,13 @@ module Procedures::Installer class UpgradeRakeTask < ForemanMaintain::Procedure metadata do description 'Execute upgrade:run rake task' + confine do + feature(:foreman) + end end def run - # only run this in the Satellite scenario, as in others - # the installer runs this rake task for us already - execute!('foreman-rake upgrade:run') if feature(:satellite) + execute!('foreman-rake upgrade:run') end end end diff --git a/definitions/scenarios/upgrade_to_satellite_6_16.rb b/definitions/scenarios/satellite_upgrade.rb similarity index 80% rename from definitions/scenarios/upgrade_to_satellite_6_16.rb rename to definitions/scenarios/satellite_upgrade.rb index 8b1a85ce3..eb4339a06 100644 --- a/definitions/scenarios/upgrade_to_satellite_6_16.rb +++ b/definitions/scenarios/satellite_upgrade.rb @@ -1,11 +1,10 @@ -module Scenarios::Satellite_6_16 +module Scenarios::Satellite class Abstract < ForemanMaintain::Scenario def self.upgrade_metadata(&block) metadata do tags :upgrade_scenario confine do - feature(:satellite) && - (feature(:satellite).current_minor_version == '6.15' || \ + (feature(:downstream).current_minor_version == '6.15' || \ ForemanMaintain.upgrade_in_progress == '6.16') end instance_eval(&block) @@ -19,7 +18,7 @@ def target_version class PreUpgradeCheck < Abstract upgrade_metadata do - description 'Checks before upgrading to Satellite 6.16' + description 'Checks before upgrading' tags :pre_upgrade_checks run_strategy :fail_slow end @@ -28,14 +27,14 @@ def compose add_steps(find_checks(:default)) add_steps(find_checks(:pre_upgrade)) add_step(Checks::Disk::AvailableSpacePostgresql13) - add_step(Checks::Repositories::Validate.new(:version => '6.16')) + add_step(Checks::Repositories::Validate.new(:version => target_version)) add_step(Checks::CheckOrganizationContentAccessMode) end end class PreMigrations < Abstract upgrade_metadata do - description 'Procedures before migrating to Satellite 6.16' + description 'Procedures before migrating' tags :pre_migrations end @@ -46,7 +45,7 @@ def compose class Migrations < Abstract upgrade_metadata do - description 'Migration scripts to Satellite 6.16' + description 'Migration scripts' tags :migrations run_strategy :fail_fast end @@ -56,7 +55,7 @@ def set_context_mapping end def compose - add_step(Procedures::Repositories::Setup.new(:version => '6.16')) + add_step(Procedures::Repositories::Setup.new(:version => target_version)) if el8? modules_to_switch = ['postgresql:13'] add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch)) @@ -76,7 +75,7 @@ def compose class PostMigrations < Abstract upgrade_metadata do - description 'Procedures after migrating to Satellite 6.16' + description 'Procedures after migrating' tags :post_migrations end @@ -89,7 +88,7 @@ def compose class PostUpgradeChecks < Abstract upgrade_metadata do - description 'Checks after upgrading to Satellite 6.16' + description 'Checks after upgrading' tags :post_upgrade_checks run_strategy :fail_slow end diff --git a/definitions/scenarios/upgrade_to_capsule_6_16.rb b/definitions/scenarios/upgrade_to_capsule_6_16.rb deleted file mode 100644 index aa5db4cf6..000000000 --- a/definitions/scenarios/upgrade_to_capsule_6_16.rb +++ /dev/null @@ -1,100 +0,0 @@ -module Scenarios::Capsule_6_16 - class Abstract < ForemanMaintain::Scenario - def self.upgrade_metadata(&block) - metadata do - tags :upgrade_scenario - confine do - feature(:capsule) && - (feature(:capsule).current_minor_version == '6.15' || \ - ForemanMaintain.upgrade_in_progress == '6.16') - end - instance_eval(&block) - end - end - - def target_version - '6.16' - end - end - - class PreUpgradeCheck < Abstract - upgrade_metadata do - description 'Checks before upgrading to Capsule 6.16' - tags :pre_upgrade_checks - run_strategy :fail_slow - end - - def compose - add_steps(find_checks(:default)) - add_steps(find_checks(:pre_upgrade)) - add_step(Checks::Disk::AvailableSpacePostgresql13) - add_step(Checks::Repositories::Validate.new(:version => '6.16')) - end - end - - class PreMigrations < Abstract - upgrade_metadata do - description 'Procedures before migrating to Capsule 6.16' - tags :pre_migrations - end - - def compose - add_steps(find_procedures(:pre_migrations)) - end - end - - class Migrations < Abstract - upgrade_metadata do - description 'Migration scripts to Capsule 6.16' - tags :migrations - end - - def set_context_mapping - context.map(:assumeyes, Procedures::Installer::Run => :assumeyes) - end - - def compose - add_step(Procedures::Repositories::Setup.new(:version => '6.16')) - if el8? - modules_to_switch = ['postgresql:13'] - add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch)) - 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, - :download_only => true - )) - add_step(Procedures::Service::Stop.new) - add_step(Procedures::Packages::Update.new(:assumeyes => true, :clean_cache => false)) - add_step_with_context(Procedures::Installer::Run) - end - end - - class PostMigrations < Abstract - upgrade_metadata do - description 'Procedures after migrating to Capsule 6.16' - tags :post_migrations - end - - def compose - add_step(Procedures::RefreshFeatures) - add_step(Procedures::Service::Start.new) - add_steps(find_procedures(:post_migrations)) - end - end - - class PostUpgradeChecks < Abstract - upgrade_metadata do - description 'Checks after upgrading to Capsule 6.16' - tags :post_upgrade_checks - run_strategy :fail_slow - end - - def compose - add_steps(find_checks(:default)) - add_steps(find_checks(:post_upgrade)) - add_step(Procedures::Packages::CheckForReboot) - end - end -end