Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update packages update #825

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions definitions/procedures/packages/update_all_confirmation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ def run
"It is recommended to update everything only as part of upgrade\n" \
"of the #{feature(:instance).product_name} to the next version. \n" \
"To Upgrade to next version use 'foreman-maintain upgrade'.\n\n" \
"NOTE: --assumeyes is not applicable for this check\n\n" \
"Do you want to proceed with update of everything regardless\n" \
'of the recommendations?'
answer = ask_decision(question, actions_msg: 'y(yes), q(quit)', ignore_assumeyes: true)
answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
abort! unless answer == :yes
end
end
Expand Down
36 changes: 29 additions & 7 deletions definitions/scenarios/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,47 @@ class Update < ForemanMaintain::Scenario
description 'update packages in unlocked session'
param :packages, 'List of packages to Update', :array => true
param :assumeyes, 'Do not ask for confirmation'
param :downloadonly, 'Download and cache packages'
manual_detection
end

# rubocop:disable Metrics/MethodLength
def compose
if Packages.skip_installer_run?(context.get(:packages))
add_step_with_context(Procedures::Packages::Update,
:force => true, :warn_on_errors => true)
else
add_steps_with_context(
Procedures::Packages::UpdateAllConfirmation,
Procedures::Packages::InstallerConfirmation
)
unless context.get(:downloadonly)
add_steps_with_context(
Procedures::Packages::UpdateAllConfirmation,
Procedures::Packages::InstallerConfirmation
)
end

add_step_with_context(Procedures::Packages::UnlockVersions)
add_step_with_context(Procedures::Packages::Update,
:force => true, :warn_on_errors => true)
add_step_with_context(Procedures::Installer::Run)

if context.get(:downloadonly)
add_step_with_context(
Procedures::Packages::Update,
:force => true,
:warn_on_errors => true,
:dnf_options => ['--downloadonly']
)
add_step_with_context(Procedures::Packages::LockVersions)
else
add_step_with_context(
Procedures::Packages::Update,
:force => true,
:warn_on_errors => true
)

add_step_with_context(Procedures::Installer::Run)
end

add_step(Procedures::Packages::LockingStatus)
end
end
# rubocop:enable Metrics/MethodLength

def set_context_mapping
context.map(:packages,
Expand Down
5 changes: 4 additions & 1 deletion lib/foreman_maintain/cli/packages_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ def execute
subcommand 'update', 'Update packages in an unlocked session' do
interactive_option(['assumeyes'])
parameter '[PACKAGES] ...', 'packages to update', :attribute_name => :packages
option '--downloadonly', :flag, 'Downloads and caches package updates only',
:default => false

def execute
run_scenarios_and_exit(
Scenarios::Packages::Update.new(
:packages => packages,
:assumeyes => assumeyes?
:assumeyes => assumeyes?,
:downloadonly => @downloadonly
)
)
end
Expand Down
Loading