diff --git a/definitions/scenarios/packages.rb b/definitions/scenarios/packages.rb index 93e7911c9..6cfa5ab52 100644 --- a/definitions/scenarios/packages.rb +++ b/definitions/scenarios/packages.rb @@ -97,6 +97,7 @@ 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 @@ -105,14 +106,37 @@ def compose 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'], + ) + else + add_step_with_context( + Procedures::Packages::Update, + :force => true, + :warn_on_errors => true + ) + end + + + if context.get(:downloadonly) + add_step_with_context(Procedures::Packages::LockVersions) + else + add_step_with_context(Procedures::Installer::Run) + end + add_step(Procedures::Packages::LockingStatus) end end diff --git a/lib/foreman_maintain/cli/packages_command.rb b/lib/foreman_maintain/cli/packages_command.rb index 831b81bf4..c3527e16d 100644 --- a/lib/foreman_maintain/cli/packages_command.rb +++ b/lib/foreman_maintain/cli/packages_command.rb @@ -55,12 +55,14 @@ 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