foreman_maintain 1.6.11 → 1.6.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/definitions/checks/backup/incremental_parent_type.rb +36 -0
  3. data/definitions/checks/foreman/check_tuning_requirements.rb +2 -2
  4. data/definitions/checks/system_registration.rb +1 -1
  5. data/definitions/features/foreman_database.rb +6 -1
  6. data/definitions/procedures/foreman_tasks/ui_investigate.rb +1 -1
  7. data/definitions/procedures/knowledge_base_article.rb +1 -1
  8. data/definitions/procedures/packages/update_all_confirmation.rb +1 -1
  9. data/definitions/procedures/sync_plans/disable.rb +0 -1
  10. data/definitions/procedures/sync_plans/enable.rb +0 -2
  11. data/definitions/scenarios/backup.rb +4 -0
  12. data/definitions/scenarios/foreman_upgrade.rb +3 -1
  13. data/definitions/scenarios/restore.rb +1 -1
  14. data/definitions/scenarios/satellite_upgrade.rb +66 -21
  15. data/definitions/scenarios/services.rb +5 -5
  16. data/lib/foreman_maintain/cli/upgrade_command.rb +1 -1
  17. data/lib/foreman_maintain/concerns/base_database.rb +1 -1
  18. data/lib/foreman_maintain/concerns/finders.rb +0 -4
  19. data/lib/foreman_maintain/config.rb +5 -0
  20. data/lib/foreman_maintain/core_ext.rb +0 -12
  21. data/lib/foreman_maintain/detector.rb +1 -0
  22. data/lib/foreman_maintain/reporter/cli_reporter.rb +23 -23
  23. data/lib/foreman_maintain/reporter.rb +1 -1
  24. data/lib/foreman_maintain/update_runner.rb +4 -4
  25. data/lib/foreman_maintain/upgrade_runner.rb +7 -7
  26. data/lib/foreman_maintain/utils/backup.rb +7 -0
  27. data/lib/foreman_maintain/utils/service/systemd.rb +1 -5
  28. data/lib/foreman_maintain/version.rb +1 -1
  29. data/lib/foreman_maintain.rb +5 -4
  30. metadata +3 -3
  31. data/definitions/procedures/pulpcore/trim_rpm_changelogs.rb +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 251038c33fba4faa2abf9c839937e229a664703c9b3003376b4d88aa7eca7d02
4
- data.tar.gz: 72f4bb7fe9e7a9862df58accbfa190019a3356e99917d884242ad90259743291
3
+ metadata.gz: 7357cec0fa22b76e7ae0c7d2da85e2cb20f52aeb2ded53e9a2ddf21c56b7a037
4
+ data.tar.gz: 2116a2048dc315a55bb7fb8789e9961f2a4fc91a4afa5b614dd237eb7825da37
5
5
  SHA512:
6
- metadata.gz: 140782d6ee833f07a64b2310fd94901f42991dc9babb2368cdc48c904fe78122c6e8ae6584bdb7c2818883e6c425035288d9f2859b7983d5957a5366c7c1a13a
7
- data.tar.gz: 127c879d335e5dc46151d31e02d9fb72c4f45bcaff5ffcd83dee2ae1552877952a2b7128b28e45c69cab779df7055025e9bfdfa014bc484ae17ef2ffdd595ad3
6
+ metadata.gz: 5a14594384dd60070ffde442e87423522ebde81e3f9580ac88c74028bb33a232bbe4bf57e7847d70768c82b375c5067509dfefed5ecc7c79023f66a2c904af11
7
+ data.tar.gz: 07fc2c9e32f3d16171a99839562dd01210190c00de03414859dfb84492401168d2127d84974ac750c7b5aaa47a927bd6ea42cc47237249c908ac56f96749e7d0
@@ -0,0 +1,36 @@
1
+ module Checks::Backup
2
+ class IncrementalParentType < ForemanMaintain::Check
3
+ metadata do
4
+ description 'Check if the incremental backup has the right type'
5
+ tags :backup
6
+ param :incremental_dir, 'Path to existing backup directory'
7
+ param :online_backup, 'Select for online backup', :flag => true, :default => false
8
+ param :sql_tar, 'Will backup include PostgreSQL tarball', :flag => true, :default => false
9
+ manual_detection
10
+ end
11
+
12
+ def run
13
+ return unless @incremental_dir
14
+
15
+ backup = ForemanMaintain::Utils::Backup.new(@incremental_dir)
16
+
17
+ existing_type = backup.backup_type
18
+ new_type = if @online_backup
19
+ ForemanMaintain::Utils::Backup::ONLINE_BACKUP
20
+ else
21
+ ForemanMaintain::Utils::Backup::OFFLINE_BACKUP
22
+ end
23
+ msg = "The existing backup is an #{existing_type} backup, "\
24
+ "but an #{new_type} backup was requested."
25
+ assert(existing_type == new_type, msg)
26
+
27
+ unless @online_backup
28
+ existing_sql = backup.sql_tar_files_exist? ? 'tarball' : 'dump'
29
+ new_sql = @sql_tar ? 'tarball' : 'dump'
30
+ msg = "The existing backup has PostgreSQL as a #{existing_sql}, "\
31
+ "but the new one will have a #{new_sql}."
32
+ assert(existing_sql == new_sql, msg)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -70,8 +70,8 @@ module Checks
70
70
  end
71
71
 
72
72
  def failure_message(tuning_profile)
73
- <<-MESSAGE.strip_heredoc
74
- \nERROR: The installer is configured to use the #{tuning_profile} tuning profile and does not meet the requirements.
73
+ <<~MESSAGE
74
+ \nERROR: The installer is configured to use the #{tuning_profile} tuning profile and does not meet the requirements.
75
75
  MESSAGE
76
76
  end
77
77
  end
@@ -5,7 +5,7 @@ class Checks::SystemRegistration < ForemanMaintain::Check
5
5
  tags :default
6
6
 
7
7
  confine do
8
- file_exists?('/etc/rhsm/rhsm.conf') && feature(:instance).downstream
8
+ feature(:instance).downstream
9
9
  end
10
10
  end
11
11
 
@@ -35,7 +35,12 @@ class Features::ForemanDatabase < ForemanMaintain::Feature
35
35
  private
36
36
 
37
37
  def load_configuration
38
- config = YAML.load(File.read(FOREMAN_DB_CONFIG))
38
+ config = if File.exist?('/etc/foreman/database.yml')
39
+ YAML.load(File.read(FOREMAN_DB_CONFIG))
40
+ else
41
+ { 'production' => {} }
42
+ end
43
+
39
44
  @configuration = config['production']
40
45
  @configuration['host'] ||= 'localhost'
41
46
  @configuration
@@ -10,7 +10,7 @@ module Procedures::ForemanTasks
10
10
  attr_reader :search_query
11
11
 
12
12
  def run
13
- ask(<<-MESSAGE.strip_heredoc)
13
+ ask(<<~MESSAGE)
14
14
  Go to https://#{hostname}/foreman_tasks/tasks?search=#{CGI.escape(@search_query.to_s)}
15
15
  press ENTER after the tasks are resolved.
16
16
  MESSAGE
@@ -12,7 +12,7 @@ class Procedures::KnowledgeBaseArticle < ForemanMaintain::Procedure
12
12
  end
13
13
 
14
14
  def run
15
- ask(<<-MESSAGE.strip_heredoc)
15
+ ask(<<~MESSAGE)
16
16
  Go to #{kcs_documents[@doc]}
17
17
  please follow steps from above article to resolve this issue
18
18
  press ENTER once done.
@@ -20,7 +20,7 @@ module Procedures::Packages
20
20
  the recommendations?
21
21
  MSG
22
22
 
23
- answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
23
+ answer = ask_decision(question.strip, actions_msg: 'y(yes), q(quit)')
24
24
  abort! unless answer == :yes
25
25
  end
26
26
  end
@@ -4,7 +4,6 @@ module Procedures::SyncPlans
4
4
  metadata do
5
5
  for_feature :sync_plans
6
6
  description 'disable active sync plans'
7
- tags :pre_migrations, :maintenance_mode_on
8
7
 
9
8
  confine do
10
9
  feature(:katello)
@@ -4,8 +4,6 @@ module Procedures::SyncPlans
4
4
  metadata do
5
5
  for_feature :sync_plans
6
6
  description 're-enable sync plans'
7
- tags :post_migrations, :maintenance_mode_off
8
- before :disk_io
9
7
 
10
8
  confine do
11
9
  feature(:katello)
@@ -18,6 +18,9 @@ module ForemanMaintain::Scenarios
18
18
 
19
19
  def compose
20
20
  check_valid_strategy
21
+ add_step_with_context(Checks::Backup::IncrementalParentType,
22
+ :online_backup => strategy == :online,
23
+ :sql_tar => feature(:instance).postgresql_local?)
21
24
  safety_confirmation
22
25
  add_step_with_context(Procedures::Backup::AccessibilityConfirmation) if strategy == :offline
23
26
  add_step_with_context(Procedures::Backup::PrepareDirectory,
@@ -51,6 +54,7 @@ module ForemanMaintain::Scenarios
51
54
  context.map(:preserve_dir,
52
55
  Procedures::Backup::PrepareDirectory => :preserve_dir)
53
56
  context.map(:incremental_dir,
57
+ Checks::Backup::IncrementalParentType => :incremental_dir,
54
58
  Procedures::Backup::PrepareDirectory => :incremental_dir,
55
59
  Procedures::Backup::Metadata => :incremental_dir)
56
60
  context.map(:proxy_features,
@@ -1,4 +1,4 @@
1
- module Scenarios::ForemanUpgrade
1
+ module Scenarios::Foreman
2
2
  class Abstract < ForemanMaintain::Scenario
3
3
  def self.upgrade_metadata(&block)
4
4
  metadata do
@@ -38,6 +38,7 @@ module Scenarios::ForemanUpgrade
38
38
  Checks::CheckUpstreamRepository,
39
39
  Checks::Disk::AvailableSpace,
40
40
  Checks::Disk::AvailableSpaceCandlepin, # if candlepin
41
+ Checks::Disk::AvailableSpacePostgresql13,
41
42
  Checks::Foreman::ValidateExternalDbVersion, # if external database
42
43
  Checks::Foreman::CheckCorruptedRoles,
43
44
  Checks::Foreman::CheckDuplicatePermissions,
@@ -50,6 +51,7 @@ module Scenarios::ForemanUpgrade
50
51
  Checks::NonRhPackages,
51
52
  Checks::PackageManager::Dnf::ValidateDnfConfig,
52
53
  Checks::Repositories::CheckNonRhRepository,
54
+ Checks::CheckOrganizationContentAccessMode,
53
55
  Checks::Repositories::Validate
54
56
  )
55
57
  end
@@ -14,7 +14,7 @@ module ForemanMaintain::Scenarios
14
14
  def compose
15
15
  backup = ForemanMaintain::Utils::Backup.new(context.get(:backup_dir))
16
16
 
17
- add_steps(find_checks(:root_user))
17
+ add_step(Checks::RootUser)
18
18
  add_steps_with_context(Checks::Restore::ValidateBackup,
19
19
  Checks::Restore::ValidateHostname,
20
20
  Checks::Restore::ValidateInterfaces,
@@ -23,14 +23,41 @@ module Scenarios::Satellite
23
23
  run_strategy :fail_slow
24
24
  end
25
25
 
26
+ # rubocop:disable Metrics/MethodLength
26
27
  def compose
27
- add_steps(find_checks(:default))
28
- add_steps(find_checks(:pre_upgrade))
29
- add_step(Checks::CheckIpv6Disable)
30
- add_step(Checks::Disk::AvailableSpacePostgresql13)
31
- add_step(Checks::Repositories::Validate.new(:version => target_version))
32
- add_step(Checks::CheckOrganizationContentAccessMode)
28
+ add_steps(
29
+ Checks::Foreman::FactsNames, # if Foreman database present
30
+ Checks::ForemanProxy::CheckTftpStorage, # if Satellite with foreman-proxy+tftp
31
+ Checks::ForemanProxy::VerifyDhcpConfigSyntax, # if foreman-proxy+dhcp-isc
32
+ Checks::ForemanTasks::NotPaused, # if foreman-tasks present
33
+ Checks::Puppet::VerifyNoEmptyCacertRequests, # if puppetserver
34
+ Checks::ServerPing,
35
+ Checks::ServicesUp,
36
+ Checks::SystemRegistration,
37
+ Checks::CheckHotfixInstalled,
38
+ Checks::CheckTmout,
39
+ Checks::CheckUpstreamRepository,
40
+ Checks::Disk::AvailableSpace,
41
+ Checks::Disk::AvailableSpaceCandlepin, # if candlepin
42
+ Checks::Foreman::ValidateExternalDbVersion, # if external database
43
+ Checks::Foreman::CheckCorruptedRoles,
44
+ Checks::Foreman::CheckDuplicatePermissions,
45
+ Checks::Foreman::TuningRequirements, # if katello present
46
+ Checks::ForemanOpenscap::InvalidReportAssociations, # if foreman-openscap
47
+ Checks::ForemanTasks::Invalid::CheckOld, # if foreman-tasks
48
+ Checks::ForemanTasks::Invalid::CheckPendingState, # if foreman-tasks
49
+ Checks::ForemanTasks::Invalid::CheckPlanningState, # if foreman-tasks
50
+ Checks::ForemanTasks::NotRunning, # if foreman-tasks
51
+ Checks::NonRhPackages,
52
+ Checks::PackageManager::Dnf::ValidateDnfConfig,
53
+ Checks::Repositories::CheckNonRhRepository,
54
+ Checks::CheckIpv6Disable,
55
+ Checks::Disk::AvailableSpacePostgresql13,
56
+ Checks::CheckOrganizationContentAccessMode,
57
+ Checks::Repositories::Validate.new(:version => target_version),
58
+ )
33
59
  end
60
+ # rubocop:enable Metrics/MethodLength
34
61
  end
35
62
 
36
63
  class PreMigrations < Abstract
@@ -40,7 +67,11 @@ module Scenarios::Satellite
40
67
  end
41
68
 
42
69
  def compose
43
- add_steps(find_procedures(:pre_migrations))
70
+ add_steps(
71
+ Procedures::MaintenanceMode::EnableMaintenanceMode,
72
+ Procedures::Crond::Stop,
73
+ Procedures::SyncPlans::Disable,
74
+ )
44
75
  end
45
76
  end
46
77
 
@@ -63,12 +94,14 @@ module Scenarios::Satellite
63
94
  modules_to_enable = ["#{feature(:instance).downstream.module_name}:#{el_short_name}"]
64
95
  add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
65
96
  end
66
- add_step(Procedures::Packages::Update.new(
67
- :assumeyes => true,
68
- :download_only => true
69
- ))
70
- add_step(Procedures::Service::Stop.new)
71
- add_step(Procedures::Packages::Update.new(:assumeyes => true, :clean_cache => false))
97
+ add_steps(
98
+ Procedures::Packages::Update.new(
99
+ :assumeyes => true,
100
+ :download_only => true
101
+ ),
102
+ Procedures::Service::Stop,
103
+ Procedures::Packages::Update.new(:assumeyes => true, :clean_cache => false),
104
+ )
72
105
  add_step_with_context(Procedures::Installer::Run)
73
106
  add_step(Procedures::Installer::UpgradeRakeTask)
74
107
  end
@@ -81,9 +114,13 @@ module Scenarios::Satellite
81
114
  end
82
115
 
83
116
  def compose
84
- add_step(Procedures::RefreshFeatures)
85
- add_step(Procedures::Service::Start.new)
86
- add_steps(find_procedures(:post_migrations))
117
+ add_steps(
118
+ Procedures::RefreshFeatures,
119
+ Procedures::Service::Start,
120
+ Procedures::Crond::Start,
121
+ Procedures::SyncPlans::Enable,
122
+ Procedures::MaintenanceMode::DisableMaintenanceMode,
123
+ )
87
124
  end
88
125
  end
89
126
 
@@ -95,11 +132,19 @@ module Scenarios::Satellite
95
132
  end
96
133
 
97
134
  def compose
98
- add_steps(find_checks(:default))
99
- add_steps(find_checks(:post_upgrade))
100
- add_step(Procedures::Packages::CheckForReboot)
101
- add_step(Procedures::Pulpcore::ContainerHandleImageMetadata)
102
- add_step(Procedures::Repositories::IndexKatelloRepositoriesContainerMetatdata)
135
+ add_steps(
136
+ Checks::Foreman::FactsNames, # if Foreman database present
137
+ Checks::ForemanProxy::CheckTftpStorage, # if Satellite with foreman-proxy+tftp
138
+ Checks::ForemanProxy::VerifyDhcpConfigSyntax, # if foreman-proxy+dhcp-isc
139
+ Checks::ForemanTasks::NotPaused, # if foreman-tasks present
140
+ Checks::Puppet::VerifyNoEmptyCacertRequests, # if puppetserver
141
+ Checks::ServerPing,
142
+ Checks::ServicesUp,
143
+ Checks::SystemRegistration,
144
+ Procedures::Packages::CheckForReboot,
145
+ Procedures::Pulpcore::ContainerHandleImageMetadata,
146
+ Procedures::Repositories::IndexKatelloRepositoriesContainerMetatdata,
147
+ )
103
148
  end
104
149
  end
105
150
  end
@@ -8,7 +8,7 @@ module ForemanMaintain::Scenarios
8
8
  end
9
9
 
10
10
  def compose
11
- add_steps(find_checks(:root_user))
11
+ add_step(Checks::RootUser)
12
12
  add_steps_with_context(Procedures::Service::Restart)
13
13
  end
14
14
 
@@ -33,7 +33,7 @@ module ForemanMaintain::Scenarios
33
33
  end
34
34
 
35
35
  def compose
36
- add_steps(find_checks(:root_user))
36
+ add_step(Checks::RootUser)
37
37
  add_steps_with_context(Procedures::Service::Stop)
38
38
  end
39
39
 
@@ -55,7 +55,7 @@ module ForemanMaintain::Scenarios
55
55
  end
56
56
 
57
57
  def compose
58
- add_steps(find_checks(:root_user))
58
+ add_step(Checks::RootUser)
59
59
  add_steps_with_context(Procedures::Service::Start)
60
60
  end
61
61
 
@@ -98,7 +98,7 @@ module ForemanMaintain::Scenarios
98
98
  end
99
99
 
100
100
  def compose
101
- add_steps(find_checks(:root_user))
101
+ add_step(Checks::RootUser)
102
102
  add_steps_with_context(Procedures::Service::Enable)
103
103
  end
104
104
 
@@ -120,7 +120,7 @@ module ForemanMaintain::Scenarios
120
120
  end
121
121
 
122
122
  def compose
123
- add_steps(find_checks(:root_user))
123
+ add_step(Checks::RootUser)
124
124
  add_steps_with_context(Procedures::Service::Disable)
125
125
  end
126
126
 
@@ -30,7 +30,7 @@ module ForemanMaintain
30
30
  else
31
31
  '--target-version not specified'
32
32
  end
33
- message = <<-MESSAGE.strip_heredoc
33
+ message = <<~MESSAGE
34
34
  #{message_start}
35
35
  Possible target versions are:
36
36
  MESSAGE
@@ -42,7 +42,7 @@ module ForemanMaintain
42
42
  end
43
43
 
44
44
  def local?(config = configuration)
45
- ['localhost', '127.0.0.1', `hostname`.strip].include? config['host']
45
+ ['localhost', '127.0.0.1', `hostname`.strip].include?(config['host'])
46
46
  end
47
47
 
48
48
  def query(sql, config = configuration)
@@ -13,10 +13,6 @@ module ForemanMaintain
13
13
  ensure_one_object(:check, label)
14
14
  end
15
15
 
16
- def find_checks(conditions)
17
- detector.available_checks(conditions)
18
- end
19
-
20
16
  def procedure(label)
21
17
  ensure_one_object(:procedure, label)
22
18
  end
@@ -25,6 +25,11 @@ module ForemanMaintain
25
25
  @foreman_port = @options.fetch(:foreman_port, 443)
26
26
  end
27
27
 
28
+ def use_color?
29
+ ENV['TERM'] && ENV.fetch('NO_COLOR', '') == '' && \
30
+ system('command -v tput', out: File.open('/dev/null')) && `tput colors`.to_i > 0
31
+ end
32
+
28
33
  private
29
34
 
30
35
  def load_log_configs
@@ -1,17 +1,5 @@
1
1
  module ForemanMaintain
2
2
  module CoreExt
3
- module StripHeredoc
4
- def strip_heredoc
5
- indent = 0
6
- indented_lines = scan(/^[ \t]+(?=\S)/)
7
- unless indented_lines.empty?
8
- indent = indented_lines.min.size
9
- end
10
- gsub(/^[ \t]{#{indent}}/, '')
11
- end
12
- end
13
- String.include StripHeredoc
14
-
15
3
  module ValidateOptions
16
4
  def validate_options!(*valid_keys)
17
5
  valid_keys.flatten!
@@ -24,6 +24,7 @@ module ForemanMaintain
24
24
  @all_features_scanned = false
25
25
  @available_checks = nil
26
26
  @available_scenarios = nil
27
+ @available_procedures = nil
27
28
  @scenarios ||= Scenario.all_sub_classes.select(&:autodetect?)
28
29
  end
29
30
 
@@ -301,17 +301,17 @@ module ForemanMaintain
301
301
  return if scenario.passed? && !scenario.warning?
302
302
 
303
303
  message = []
304
- message << <<-MESSAGE.strip_heredoc
304
+ message << <<~MESSAGE
305
305
  Scenario [#{scenario.description}] failed.
306
306
  MESSAGE
307
307
  recommend = []
308
308
 
309
309
  steps_with_abort = scenario.steps_with_abort(:whitelisted => false)
310
310
  unless steps_with_abort.empty?
311
- message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_abort, "\n", 2))
312
- The processing was aborted by user during the following steps:
311
+ message << format(<<~MESSAGE, format_steps(steps_with_abort, "\n", 2))
312
+ The processing was aborted by user during the following steps:
313
313
 
314
- %s
314
+ %s
315
315
  MESSAGE
316
316
  end
317
317
 
@@ -323,28 +323,28 @@ module ForemanMaintain
323
323
 
324
324
  steps_to_whitelist = steps_with_error + steps_with_skipped - not_skippable_steps
325
325
  unless steps_with_error.empty?
326
- message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_error, "\n", 2))
327
- The following steps ended up in failing state:
326
+ message << format(<<~MESSAGE, format_steps(steps_with_error, "\n", 2))
327
+ The following steps ended up in failing state:
328
328
 
329
- %s
329
+ %s
330
330
  MESSAGE
331
331
  whitelist_labels = steps_to_whitelist.map(&:label_dashed).join(',')
332
332
  unless whitelist_labels.empty?
333
333
  recommend << if scenario.detector.feature(:instance).downstream
334
- format(<<-MESSAGE.strip_heredoc)
335
- Resolve the failed steps and rerun the command.
334
+ format(<<~MESSAGE)
335
+ Resolve the failed steps and rerun the command.
336
336
 
337
- If the situation persists and, you are unclear what to do next,
338
- contact #{scenario.detector.feature(:instance).project_support_entity}.
337
+ If the situation persists and, you are unclear what to do next,
338
+ contact #{scenario.detector.feature(:instance).project_support_entity}.
339
339
 
340
- In case the failures are false positives, use
341
- --whitelist="#{whitelist_labels}"
340
+ In case the failures are false positives, use
341
+ --whitelist="#{whitelist_labels}"
342
342
  MESSAGE
343
343
  else
344
- format(<<-MESSAGE.strip_heredoc)
345
- Resolve the failed steps and rerun the command.
346
- In case the failures are false positives, use
347
- --whitelist="#{whitelist_labels}"
344
+ format(<<~MESSAGE)
345
+ Resolve the failed steps and rerun the command.
346
+ In case the failures are false positives, use
347
+ --whitelist="#{whitelist_labels}"
348
348
  MESSAGE
349
349
  end
350
350
  end
@@ -352,15 +352,15 @@ module ForemanMaintain
352
352
 
353
353
  steps_with_warning = scenario.steps_with_warning(:whitelisted => false)
354
354
  unless steps_with_warning.empty?
355
- message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_warning, "\n", 2))
356
- The following steps ended up in warning state:
355
+ message << format(<<~MESSAGE, format_steps(steps_with_warning, "\n", 2))
356
+ The following steps ended up in warning state:
357
357
 
358
- %s
358
+ %s
359
359
  MESSAGE
360
360
 
361
- recommend << <<-MESSAGE.strip_heredoc
362
- The steps in warning state itself might not mean there is an error,
363
- but it should be reviewed to ensure the behavior is expected
361
+ recommend << <<~MESSAGE
362
+ The steps in warning state itself might not mean there is an error,
363
+ but it should be reviewed to ensure the behavior is expected
364
364
  MESSAGE
365
365
  end
366
366
  puts((message + recommend).join("\n"))
@@ -67,7 +67,7 @@ module ForemanMaintain
67
67
  end
68
68
 
69
69
  until_valid_decision do
70
- filter_decision(ask("#{message}, [#{actions_msg}]"))
70
+ filter_decision(ask("#{message}\n[#{actions_msg}]"))
71
71
  end
72
72
  end
73
73
  # rubocop:enable Metrics/LineLength
@@ -133,10 +133,10 @@ module ForemanMaintain
133
133
  decision = super(scenario)
134
134
  # we have not asked the user already about next steps
135
135
  if decision.nil? && @ask_to_confirm_update
136
- response = reporter.ask_decision(<<-MESSAGE.strip_heredoc.strip)
137
- The pre-update checks indicate that the system is ready for update.
138
- It's recommended to perform a backup at this stage.
139
- Confirm to continue with the modification part of the update
136
+ response = reporter.ask_decision(<<~MESSAGE.strip)
137
+ The pre-update checks indicate that the system is ready for update.
138
+ It's recommended to perform a backup at this stage.
139
+ Confirm to continue with the modification part of the update
140
140
  MESSAGE
141
141
  if [:no, :quit].include?(response)
142
142
  ask_to_quit
@@ -94,7 +94,7 @@ module ForemanMaintain
94
94
  def finish_upgrade
95
95
  @finished = true
96
96
  @reporter.hline
97
- @reporter.puts <<-MESSAGE.strip_heredoc
97
+ @reporter.puts <<~MESSAGE
98
98
  Upgrade finished.
99
99
  MESSAGE
100
100
  end
@@ -136,7 +136,7 @@ module ForemanMaintain
136
136
  def skip_phase(skipped_phase)
137
137
  with_non_empty_scenario(skipped_phase) do |scenario|
138
138
  @reporter.before_scenario_starts(scenario)
139
- @reporter.puts <<-MESSAGE.strip_heredoc
139
+ @reporter.puts <<~MESSAGE
140
140
  Skipping #{skipped_phase} phase as it was already run before.
141
141
  To enforce to run the phase, use `upgrade run --phase #{skipped_phase}`
142
142
  MESSAGE
@@ -164,7 +164,7 @@ module ForemanMaintain
164
164
  end
165
165
  end
166
166
  self.phase = :pre_upgrade_checks # rollback finished
167
- @reporter.puts <<-MESSAGE.strip_heredoc
167
+ @reporter.puts <<~MESSAGE
168
168
  The upgrade failed and system was restored to pre-upgrade state.
169
169
  MESSAGE
170
170
  end
@@ -199,10 +199,10 @@ module ForemanMaintain
199
199
  decision = super(scenario)
200
200
  # we have not asked the user already about next steps
201
201
  if decision.nil? && @ask_to_confirm_upgrade
202
- response = reporter.ask_decision(<<-MESSAGE.strip_heredoc.strip)
203
- The pre-upgrade checks indicate that the system is ready for upgrade.
204
- It's recommended to perform a backup at this stage.
205
- Confirm to continue with the modification part of the upgrade
202
+ response = reporter.ask_decision(<<~MESSAGE.strip)
203
+ The pre-upgrade checks indicate that the system is ready for upgrade.
204
+ It's recommended to perform a backup at this stage.
205
+ Confirm to continue with the modification part of the upgrade
206
206
  MESSAGE
207
207
  if [:no, :quit].include?(response)
208
208
  ask_to_quit
@@ -11,6 +11,9 @@ module ForemanMaintain
11
11
  :foreman_online_files, :foreman_offline_files, :fpc_offline_files,
12
12
  :fpc_online_files
13
13
 
14
+ ONLINE_BACKUP = 'online'.freeze
15
+ OFFLINE_BACKUP = 'offline'.freeze
16
+
14
17
  def initialize(backup_dir)
15
18
  # fpc stands for foreman proxy w/ content
16
19
  @backup_dir = backup_dir
@@ -260,6 +263,10 @@ module ForemanMaintain
260
263
  def different_source_os?
261
264
  source_os_version != "#{os_name} #{os_version}"
262
265
  end
266
+
267
+ def backup_type
268
+ online_backup? ? ONLINE_BACKUP : OFFLINE_BACKUP
269
+ end
263
270
  end
264
271
  end
265
272
  end
@@ -50,11 +50,7 @@ module ForemanMaintain::Utils
50
50
  end
51
51
 
52
52
  def exist?
53
- if @sys.systemd_installed?
54
- ['enabled', 'disabled'].include?(service_enabled_status)
55
- else
56
- File.exist?("/etc/init.d/#{@name}")
57
- end
53
+ ['enabled', 'disabled'].include?(service_enabled_status)
58
54
  end
59
55
 
60
56
  def enabled?
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.6.11'.freeze
2
+ VERSION = '1.6.12'.freeze
3
3
  end
@@ -1,7 +1,3 @@
1
- if RUBY_VERSION <= '1.8.7'
2
- require 'rubygems'
3
- end
4
-
5
1
  require 'forwardable'
6
2
  require 'json'
7
3
  require 'logger'
@@ -68,6 +64,7 @@ module ForemanMaintain
68
64
 
69
65
  # using a queue, we can log the messages which are generated before initializing logger
70
66
  self.config = Config.new(options)
67
+ configure_highline
71
68
  load_definitions
72
69
  init_logger
73
70
  update_path
@@ -102,6 +99,10 @@ module ForemanMaintain
102
99
  end
103
100
  end
104
101
 
102
+ def configure_highline
103
+ HighLine.use_color = config.use_color?
104
+ end
105
+
105
106
  def cache
106
107
  ObjectCache.instance
107
108
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_maintain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.11
4
+ version: 1.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-26 00:00:00.000000000 Z
11
+ date: 2024-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -158,6 +158,7 @@ files:
158
158
  - config/foreman_maintain.yml.packaging
159
159
  - config/hammer.yml.example
160
160
  - definitions/checks/backup/certs_tar_exist.rb
161
+ - definitions/checks/backup/incremental_parent_type.rb
161
162
  - definitions/checks/candlepin/db_up.rb
162
163
  - definitions/checks/check_hotfix_installed.rb
163
164
  - definitions/checks/check_ipv6_disable.rb
@@ -275,7 +276,6 @@ files:
275
276
  - definitions/procedures/packages/update.rb
276
277
  - definitions/procedures/packages/update_all_confirmation.rb
277
278
  - definitions/procedures/pulpcore/container_handle_image_metadata.rb
278
- - definitions/procedures/pulpcore/trim_rpm_changelogs.rb
279
279
  - definitions/procedures/puppet/delete_empty_ca_cert_request_files.rb
280
280
  - definitions/procedures/puppet/remove_puppet.rb
281
281
  - definitions/procedures/puppet/remove_puppet_data.rb
@@ -1,22 +0,0 @@
1
- module Procedures::Pulpcore
2
- class TrimRpmChangelogs < ForemanMaintain::Procedure
3
- include ForemanMaintain::Concerns::SystemService
4
- include ForemanMaintain::Concerns::PulpCommon
5
-
6
- metadata do
7
- description 'Trim RPM changelogs in the pulpcore db'
8
- for_feature :pulpcore
9
- end
10
-
11
- def run
12
- with_spinner('Trimming RPM changelogs in the pulpcore db') do |spinner|
13
- necessary_services = feature(:pulpcore_database).services
14
-
15
- feature(:service).handle_services(spinner, 'start', :only => necessary_services)
16
-
17
- spinner.update('Trimming RPM changelogs')
18
- execute!(pulpcore_manager('rpm-trim-changelogs'))
19
- end
20
- end
21
- end
22
- end