-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #37175: Add dedicated update command
- Loading branch information
Showing
13 changed files
with
508 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
module Scenarios::Update | ||
class Abstract < ForemanMaintain::Scenario | ||
def self.update_metadata(&block) | ||
metadata do | ||
tags :update_scenario | ||
instance_eval(&block) | ||
end | ||
end | ||
end | ||
|
||
class PreUpdateCheck < Abstract | ||
update_metadata do | ||
description 'Checks before updating' | ||
tags :pre_update_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 | ||
update_metadata do | ||
description 'Procedures before migrating' | ||
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 | ||
update_metadata do | ||
description 'Migration scripts' | ||
tags :migrations | ||
run_strategy :fail_fast | ||
end | ||
|
||
def compose | ||
add_steps( | ||
Procedures::Service::Stop, | ||
Procedures::Packages::Update.new(:assumeyes => true, :clean_cache => false), | ||
Procedures::Installer::Run.new(:assumeyes => true), | ||
Procedures::Installer::UpgradeRakeTask | ||
) | ||
end | ||
end | ||
|
||
class PostMigrations < Abstract | ||
update_metadata do | ||
description 'Procedures after migrating' | ||
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 PostUpdateChecks < Abstract | ||
update_metadata do | ||
description 'Checks after update' | ||
tags :post_update_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'foreman_maintain/update_runner' | ||
|
||
module ForemanMaintain | ||
module Cli | ||
class UpdateCommand < Base | ||
def self.disable_self_update_option | ||
option '--disable-self-update', :flag, 'Disable automatic self update', | ||
:default => false | ||
end | ||
|
||
def update_runner | ||
update_runner = ForemanMaintain::UpdateRunner.new( | ||
reporter, | ||
:assumeyes => assumeyes?, | ||
:whitelist => whitelist || [], | ||
:force => force? | ||
) | ||
update_runner.load | ||
update_runner | ||
end | ||
|
||
subcommand 'check', 'Run pre-update checks before updating' do | ||
interactive_option | ||
disable_self_update_option | ||
|
||
def execute | ||
ForemanMaintain.validate_downstream_packages | ||
ForemanMaintain.perform_self_upgrade unless disable_self_update? | ||
update_runner.run_phase(:pre_update_checks) | ||
exit update_runner.exit_code | ||
end | ||
end | ||
|
||
subcommand 'run', 'Run an update' do | ||
interactive_option | ||
disable_self_update_option | ||
|
||
def execute | ||
ForemanMaintain.validate_downstream_packages | ||
ForemanMaintain.perform_self_upgrade unless disable_self_update? | ||
update_runner.run | ||
update_runner.save | ||
exit update_runner.exit_code | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.