diff --git a/definitions/features/foreman_install.rb b/definitions/features/foreman_install.rb index 0f3d7b63c..fc50612f7 100644 --- a/definitions/features/foreman_install.rb +++ b/definitions/features/foreman_install.rb @@ -6,7 +6,7 @@ class Features::ForemanInstall < ForemanMaintain::Feature label :foreman_install confine do - !feature(:instance).downstream && !feature(:katello) && feature(:foreman_server) + !feature(:instance).downstream && feature(:foreman_server) end end end diff --git a/definitions/procedures/repositories/setup.rb b/definitions/procedures/repositories/setup.rb index 890a120d7..aab584d51 100644 --- a/definitions/procedures/repositories/setup.rb +++ b/definitions/procedures/repositories/setup.rb @@ -3,7 +3,7 @@ class Setup < ForemanMaintain::Procedure metadata do description 'Setup repositories' confine do - feature(:instance).downstream || feature(:upstream) + feature(:instance).downstream || feature(:instance).upstream_install end param :version, 'Version for which repositories needs to be setup', diff --git a/definitions/scenarios/foreman_upgrade.rb b/definitions/scenarios/foreman_upgrade.rb new file mode 100644 index 000000000..695638720 --- /dev/null +++ b/definitions/scenarios/foreman_upgrade.rb @@ -0,0 +1,145 @@ +module Scenarios::ForemanUpgrade + class Abstract < ForemanMaintain::Scenario + def self.upgrade_metadata(&block) + metadata do + tags :upgrade_scenario + confine do + feature(:foreman_install) + end + instance_eval(&block) + end + end + + def target_version + 'nightly' + end + end + + class PreUpgradeCheck < Abstract + upgrade_metadata do + description 'Checks before upgrading' + tags :pre_upgrade_checks + run_strategy :fail_slow + end + + # rubocop:disable Metrics/MethodLength + def compose + add_steps( + Checks::Foreman::FactsNames, # if Foreman database present + Checks::ForemanProxy::CheckTftpStorage, # if Satellite with foreman-proxy+tftp + Checks::ForemanProxy::VerifyDhcpConfigSyntax, # if foreman-proxy+dhcp-isc + Checks::ForemanTasks::NotPaused, # if foreman-tasks present + Checks::Puppet::VerifyNoEmptyCacertRequests, # if puppetserver + Checks::ServerPing, + Checks::ServicesUp, + Checks::SystemRegistration, + Checks::CheckHotfixInstalled, + Checks::CheckTmout, + Checks::CheckUpstreamRepository, + Checks::Disk::AvailableSpace, + Checks::Disk::AvailableSpaceCandlepin, # if candlepin + Checks::Foreman::ValidateExternalDbVersion, # if external database + Checks::Foreman::CheckCorruptedRoles, + Checks::Foreman::CheckDuplicatePermissions, + Checks::Foreman::TuningRequirements, # if katello present + Checks::ForemanOpenscap::InvalidReportAssociations, # if foreman-openscap + Checks::ForemanTasks::Invalid::CheckOld, # if foreman-tasks + Checks::ForemanTasks::Invalid::CheckPendingState, # if foreman-tasks + Checks::ForemanTasks::Invalid::CheckPlanningState, # if foreman-tasks + Checks::ForemanTasks::NotRunning, # if foreman-tasks + Checks::NonRhPackages, + Checks::PackageManager::Dnf::ValidateDnfConfig, + Checks::Repositories::CheckNonRhRepository, + Checks::Repositories::Validate + ) + end + # rubocop:enable Metrics/MethodLength + end + + class PreMigrations < Abstract + upgrade_metadata do + description 'Procedures before upgrading' + tags :pre_migrations + end + + def compose + add_steps( + Procedures::Packages::Update.new( + :assumeyes => true, + :dnf_options => ['--downloadonly'] + ), + Procedures::MaintenanceMode::EnableMaintenanceMode, + Procedures::Crond::Stop, + Procedures::SyncPlans::Disable + ) + end + end + + class Migrations < Abstract + upgrade_metadata do + description 'Upgrade steps' + tags :migrations + run_strategy :fail_fast + end + + def set_context_mapping + context.map(:assumeyes, Procedures::Installer::Run => :assumeyes) + end + + def compose + add_step(Procedures::Repositories::Setup.new(:version => 'nightly')) + if el8? + modules_to_switch = ['postgresql:13'] + add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch)) + 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 'Post upgrade procedures' + tags :post_migrations + end + + def compose + add_steps( + Procedures::RefreshFeatures, + Procedures::Service::Start, + Procedures::Crond::Start, + Procedures::SyncPlans::Enable, + Procedures::MaintenanceMode::DisableMaintenanceMode + ) + end + end + + class PostUpgradeChecks < Abstract + upgrade_metadata do + description 'Checks after upgrading' + tags :post_upgrade_checks + run_strategy :fail_slow + end + + def compose + add_steps( + Checks::Foreman::FactsNames, # if Foreman database present + Checks::ForemanProxy::CheckTftpStorage, # if Satellite with foreman-proxy+tftp + Checks::ForemanProxy::VerifyDhcpConfigSyntax, # if foreman-proxy+dhcp-isc + Checks::ForemanTasks::NotPaused, # if foreman-tasks present + Checks::Puppet::VerifyNoEmptyCacertRequests, # if puppetserver + Checks::ServerPing, + Checks::ServicesUp, + Checks::SystemRegistration, + Procedures::Packages::CheckForReboot + ) + end + end +end diff --git a/definitions/scenarios/upgrade_to_foreman_nightly.rb b/definitions/scenarios/upgrade_to_foreman_nightly.rb deleted file mode 100644 index 9b900a882..000000000 --- a/definitions/scenarios/upgrade_to_foreman_nightly.rb +++ /dev/null @@ -1,91 +0,0 @@ -module Scenarios::Foreman_Nightly - class Abstract < ForemanMaintain::Scenario - def self.upgrade_metadata(&block) - metadata do - tags :upgrade_scenario - confine do - feature(:foreman_install) || ForemanMaintain.upgrade_in_progress == 'nightly' - end - instance_eval(&block) - end - end - - def target_version - 'nightly' - end - end - - class PreUpgradeCheck < Abstract - upgrade_metadata do - description 'Checks before upgrading to Foreman nightly' - tags :pre_upgrade_checks - run_strategy :fail_slow - end - - def compose - add_steps(find_checks(:default)) - add_steps(find_checks(:pre_upgrade)) - end - end - - class PreMigrations < Abstract - upgrade_metadata do - description 'Procedures before upgrading to Foreman nightly' - tags :pre_migrations - end - - def compose - add_steps(find_procedures(:pre_migrations)) - end - end - - class Migrations < Abstract - upgrade_metadata do - description 'Upgrade steps for Foreman nightly' - tags :migrations - run_strategy :fail_fast - end - - def set_context_mapping - context.map(:assumeyes, Procedures::Installer::Run => :assumeyes) - end - - def compose - add_step(Procedures::Repositories::Setup.new(:version => 'nightly')) - if el8? - modules_to_switch = ['postgresql:13'] - add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch)) - modules_to_enable = ["foreman:#{el_short_name}"] - add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable)) - end - add_step(Procedures::Packages::Update.new(:assumeyes => true)) - add_step_with_context(Procedures::Installer::Run) - end - end - - class PostMigrations < Abstract - upgrade_metadata do - description 'Post upgrade procedures for Foreman nightly' - 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 Foreman nightly' - tags :post_upgrade_checks - run_strategy :fail_slow - end - - def compose - add_steps(find_checks(:default)) - add_steps(find_checks(:post_upgrade)) - end - end -end diff --git a/definitions/scenarios/upgrade_to_katello_nightly.rb b/definitions/scenarios/upgrade_to_katello_nightly.rb deleted file mode 100644 index fca96fad6..000000000 --- a/definitions/scenarios/upgrade_to_katello_nightly.rb +++ /dev/null @@ -1,96 +0,0 @@ -module Scenarios::Katello_Nightly - class Abstract < ForemanMaintain::Scenario - def self.upgrade_metadata(&block) - metadata do - tags :upgrade_scenario - confine do - feature(:katello_install) || ForemanMaintain.upgrade_in_progress == 'nightly' - end - instance_eval(&block) - end - end - - def target_version - 'nightly' - end - end - - class PreUpgradeCheck < Abstract - upgrade_metadata do - description 'Checks before upgrading to Katello nightly' - tags :pre_upgrade_checks - run_strategy :fail_slow - end - - def compose - add_steps(find_checks(:default)) - add_steps(find_checks(:pre_upgrade)) - end - end - - class PreMigrations < Abstract - upgrade_metadata do - description 'Procedures before upgrading to Katello nightly' - tags :pre_migrations - end - - def compose - add_steps(find_procedures(:pre_migrations)) - end - end - - class Migrations < Abstract - upgrade_metadata do - description 'Upgrade steps for Katello nightly' - tags :migrations - run_strategy :fail_fast - end - - def set_context_mapping - context.map(:assumeyes, Procedures::Installer::Run => :assumeyes) - end - - def compose - add_step(Procedures::Repositories::Setup.new(:version => 'nightly')) - if el8? - modules_to_switch = ['postgresql:13'] - add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch)) - 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, - :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 'Post upgrade procedures for Katello nightly' - 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 Katello nightly' - tags :post_upgrade_checks - run_strategy :fail_slow - end - - def compose - add_steps(find_checks(:default)) - add_steps(find_checks(:post_upgrade)) - end - end -end