foreman_maintain 0.6.10 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/definitions/checks/foreman/check_checkpoint_segments.rb +30 -22
  4. data/definitions/checks/package_manager/yum/validate_yum_config.rb +51 -0
  5. data/definitions/features/pulpcore.rb +23 -6
  6. data/definitions/procedures/backup/accessibility_confirmation.rb +1 -1
  7. data/definitions/procedures/backup/online/safety_confirmation.rb +1 -1
  8. data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +1 -1
  9. data/definitions/procedures/content/migration_stats.rb +12 -0
  10. data/definitions/procedures/content/prepare.rb +0 -5
  11. data/definitions/procedures/content/prepare_abort.rb +12 -0
  12. data/definitions/procedures/content/switchover.rb +1 -1
  13. data/definitions/procedures/installer/upgrade_rake_task.rb +11 -0
  14. data/definitions/procedures/packages/installer_confirmation.rb +1 -1
  15. data/definitions/procedures/packages/update_all_confirmation.rb +1 -1
  16. data/definitions/procedures/prep_6_10_upgrade.rb +31 -0
  17. data/definitions/procedures/restore/confirmation.rb +1 -1
  18. data/definitions/procedures/restore/installer_reset.rb +10 -1
  19. data/definitions/scenarios/content.rb +50 -3
  20. data/definitions/scenarios/prep_6_10_upgrade.rb +13 -0
  21. data/definitions/scenarios/upgrade_to_capsule_6_9.rb +88 -0
  22. data/definitions/scenarios/upgrade_to_capsule_6_9_z.rb +88 -0
  23. data/definitions/scenarios/upgrade_to_satellite_6_8.rb +1 -0
  24. data/definitions/scenarios/upgrade_to_satellite_6_8_z.rb +1 -0
  25. data/definitions/scenarios/upgrade_to_satellite_6_9.rb +90 -0
  26. data/definitions/scenarios/upgrade_to_satellite_6_9_z.rb +89 -0
  27. data/extras/foreman_protector/foreman-protector.whitelist +1 -0
  28. data/lib/foreman_maintain.rb +1 -1
  29. data/lib/foreman_maintain/cli.rb +11 -2
  30. data/lib/foreman_maintain/cli/content_command.rb +17 -2
  31. data/lib/foreman_maintain/concerns/downstream.rb +4 -0
  32. data/lib/foreman_maintain/reporter.rb +18 -13
  33. data/lib/foreman_maintain/reporter/cli_reporter.rb +18 -9
  34. data/lib/foreman_maintain/runner.rb +6 -4
  35. data/lib/foreman_maintain/scenario.rb +4 -0
  36. data/lib/foreman_maintain/utils/service/systemd.rb +11 -1
  37. data/lib/foreman_maintain/version.rb +1 -1
  38. metadata +12 -3
  39. data/definitions/checks/yum_exclude.rb +0 -21
@@ -54,6 +54,10 @@ module ForemanMaintain
54
54
  raise NotImplementedError
55
55
  end
56
56
 
57
+ def fm_pkg_and_cmd_name
58
+ %w[satellite-maintain satellite-maintain]
59
+ end
60
+
57
61
  private
58
62
 
59
63
  def rh_repos(server_version)
@@ -22,12 +22,13 @@ module ForemanMaintain
22
22
 
23
23
  def after_scenario_finishes(_scenario); end
24
24
 
25
- def on_next_steps(steps)
25
+ def on_next_steps(steps, run_strategy = :fail_fast)
26
26
  return if steps.empty?
27
+
27
28
  if steps.size > 1
28
- multiple_steps_decision(steps)
29
+ multiple_steps_decision(steps, run_strategy)
29
30
  else
30
- single_step_decision(steps.first)
31
+ single_step_decision(steps.first, run_strategy)
31
32
  end
32
33
  end
33
34
 
@@ -46,17 +47,19 @@ module ForemanMaintain
46
47
  end
47
48
 
48
49
  # simple yes/no question, returns :yes, :no or :quit
49
- def ask_decision(message, options = {})
50
- options.validate_options!(:assumeyes)
51
- assumeyes = options.fetch(:assumeyes, assumeyes?)
50
+ # rubocop:disable Metrics/LineLength
51
+ def ask_decision(message, actions_msg: 'y(yes), n(no), q(quit)', assumeyes: assumeyes?, run_strategy: :fail_fast)
52
+ actions_msg = 'y(yes), n(no)' if run_strategy == :fail_slow
52
53
  if assumeyes
53
54
  print("#{message} (assuming yes)")
54
55
  return :yes
55
56
  end
57
+
56
58
  until_valid_decision do
57
- filter_decision(ask("#{message}, [y(yes), n(no), q(quit)]"))
59
+ filter_decision(ask("#{message}, [#{actions_msg}]"))
58
60
  end
59
61
  end
62
+ # rubocop:enable Metrics/LineLength
60
63
 
61
64
  def assumeyes=(assume)
62
65
  @assumeyes = !!assume
@@ -64,8 +67,8 @@ module ForemanMaintain
64
67
 
65
68
  private
66
69
 
67
- def single_step_decision(step)
68
- answer = ask_decision("Continue with step [#{step.description}]?")
70
+ def single_step_decision(step, run_strategy)
71
+ answer = ask_decision("Continue with step [#{step.description}]?", run_strategy: run_strategy)
69
72
  if answer == :yes
70
73
  step
71
74
  else
@@ -73,12 +76,12 @@ module ForemanMaintain
73
76
  end
74
77
  end
75
78
 
76
- def multiple_steps_decision(steps)
79
+ def multiple_steps_decision(steps, run_strategy)
77
80
  puts 'There are multiple steps to proceed:'
78
81
  steps.each_with_index do |step, index|
79
82
  puts "#{index + 1}) #{step.description}"
80
83
  end
81
- ask_to_select('Select step to continue', steps, &:description)
84
+ ask_to_select('Select step to continue', steps, run_strategy)
82
85
  end
83
86
 
84
87
  def filter_decision(answer)
@@ -90,13 +93,15 @@ module ForemanMaintain
90
93
  end
91
94
 
92
95
  # rubocop:disable Metrics/MethodLength
93
- def ask_to_select(message, steps)
96
+ def ask_to_select(message, steps, run_strategy)
94
97
  if assumeyes?
95
98
  puts('(assuming first option)')
96
99
  return steps.first
97
100
  end
98
101
  until_valid_decision do
99
- answer = ask("#{message}, [n(next), q(quit)]")
102
+ actions = run_strategy == :fail_slow ? 'n(next)' : 'n(next), q(quit)'
103
+
104
+ answer = ask("#{message}, [#{actions}]")
100
105
  if answer =~ /^\d+$/ && (answer.to_i - 1) < steps.size
101
106
  steps[answer.to_i - 1]
102
107
  else
@@ -167,8 +167,9 @@ module ForemanMaintain
167
167
  @assumeyes
168
168
  end
169
169
 
170
- def single_step_decision(step)
171
- answer = ask_decision("Continue with step [#{step.runtime_message}]?")
170
+ def single_step_decision(step, run_strategy)
171
+ answer = ask_decision("Continue with step [#{step.runtime_message}]?",
172
+ run_strategy: run_strategy)
172
173
  if answer == :yes
173
174
  step
174
175
  else
@@ -176,25 +177,28 @@ module ForemanMaintain
176
177
  end
177
178
  end
178
179
 
179
- def multiple_steps_decision(steps)
180
+ def multiple_steps_decision(steps, run_strategy)
180
181
  puts 'There are multiple steps to proceed:'
181
182
  steps.each_with_index do |step, index|
182
183
  puts "#{index + 1}) #{step.runtime_message}"
183
184
  end
184
- ask_to_select('Select step to continue', steps, &:runtime_message)
185
+ ask_to_select('Select step to continue', steps, run_strategy)
185
186
  end
186
187
 
187
- def ask_decision(message, options = 'y(yes), n(no), q(quit)', ignore_assumeyes: false)
188
+ # rubocop:disable Metrics/LineLength
189
+ def ask_decision(message, actions_msg: 'y(yes), n(no), q(quit)', ignore_assumeyes: false, run_strategy: :fail_fast)
190
+ actions_msg = 'y(yes), n(no)' if run_strategy == :fail_slow
188
191
  if !ignore_assumeyes && assumeyes?
189
192
  print("#{message} (assuming yes)\n")
190
193
  return :yes
191
194
  end
192
195
  until_valid_decision do
193
- filter_decision(ask("#{message}, [#{options}]"))
196
+ filter_decision(ask("#{message}, [#{actions_msg}]"))
194
197
  end
195
198
  ensure
196
199
  clear_line
197
200
  end
201
+ # rubocop:enable Metrics/LineLength
198
202
 
199
203
  def filter_decision(answer)
200
204
  decision = nil
@@ -206,13 +210,15 @@ module ForemanMaintain
206
210
  end
207
211
 
208
212
  # rubocop:disable Metrics/MethodLength
209
- def ask_to_select(message, steps)
213
+ def ask_to_select(message, steps, run_strategy)
210
214
  if assumeyes?
211
215
  puts('(assuming first option)')
212
216
  return steps.first
213
217
  end
218
+
214
219
  until_valid_decision do
215
- answer = ask("#{message}, [n(next), q(quit)]")
220
+ actions = run_strategy == :fail_slow ? 'n(next)' : 'n(next), q(quit)'
221
+ answer = ask("#{message}, [#{actions}]")
216
222
  if answer =~ /^\d+$/ && (answer.to_i - 1) < steps.size
217
223
  steps[answer.to_i - 1]
218
224
  else
@@ -277,6 +283,7 @@ module ForemanMaintain
277
283
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
278
284
  def scenario_failure_message(scenario)
279
285
  return if scenario.passed? && !scenario.warning?
286
+
280
287
  message = []
281
288
  message << <<-MESSAGE.strip_heredoc
282
289
  Scenario [#{scenario.description}] failed.
@@ -293,13 +300,15 @@ module ForemanMaintain
293
300
  end
294
301
 
295
302
  steps_with_error = scenario.steps_with_error(:whitelisted => false)
303
+ steps_with_skipped = scenario.steps_with_skipped(:whitelisted => true)
304
+ steps_to_whitelist = steps_with_error + steps_with_skipped
296
305
  unless steps_with_error.empty?
297
306
  message << format(<<-MESSAGE.strip_heredoc, format_steps(steps_with_error, "\n", 2))
298
307
  The following steps ended up in failing state:
299
308
 
300
309
  %s
301
310
  MESSAGE
302
- whitelist_labels = steps_with_error.map(&:label_dashed).join(',')
311
+ whitelist_labels = steps_to_whitelist.map(&:label_dashed).join(',')
303
312
  recommend << format(<<-MESSAGE.strip_heredoc, whitelist_labels)
304
313
  Resolve the failed steps and rerun
305
314
  the command. In case the failures are false positives,
@@ -70,7 +70,8 @@ module ForemanMaintain
70
70
  :quit
71
71
  elsif @last_scenario.steps_with_warning(:whitelisted => false).any?
72
72
  @last_scenario_continuation_confirmed = true
73
- reporter.ask_decision("Continue with [#{scenario.description}]")
73
+ reporter.ask_decision("Continue with [#{scenario.description}]",
74
+ run_strategy: scenario.run_strategy)
74
75
  end
75
76
 
76
77
  ask_to_quit if [:quit, :no].include?(decision)
@@ -131,7 +132,7 @@ module ForemanMaintain
131
132
  if execution.aborted?
132
133
  ask_to_quit
133
134
  else
134
- next_steps_decision = ask_about_offered_steps(step)
135
+ next_steps_decision = ask_about_offered_steps(step, scenario)
135
136
  if next_steps_decision != :yes &&
136
137
  execution.fail? && !execution.whitelisted? &&
137
138
  scenario.run_strategy == :fail_fast
@@ -141,7 +142,7 @@ module ForemanMaintain
141
142
  end
142
143
 
143
144
  # rubocop:disable Metrics/MethodLength
144
- def ask_about_offered_steps(step)
145
+ def ask_about_offered_steps(step, scenario)
145
146
  if assumeyes? && rerun_check?(step)
146
147
  @reporter.puts 'Check still failing after attempt to fix. Skipping'
147
148
  return :no
@@ -149,7 +150,8 @@ module ForemanMaintain
149
150
  if step.next_steps && !step.next_steps.empty?
150
151
  @last_decision_step = step
151
152
  steps = step.next_steps.map(&:ensure_instance)
152
- decision = @reporter.on_next_steps(steps)
153
+
154
+ decision = @reporter.on_next_steps(steps, scenario.run_strategy)
153
155
  case decision
154
156
  when :quit
155
157
  ask_to_quit
@@ -116,6 +116,10 @@ module ForemanMaintain
116
116
  filter_whitelisted(executed_steps.find_all(&:warning?), options)
117
117
  end
118
118
 
119
+ def steps_with_skipped(options = {})
120
+ filter_whitelisted(executed_steps.find_all(&:skipped?), options)
121
+ end
122
+
119
123
  def filter_whitelisted(steps, options)
120
124
  options.validate_options!(:whitelisted)
121
125
  if options.key?(:whitelisted)
@@ -50,19 +50,29 @@ module ForemanMaintain::Utils
50
50
 
51
51
  def exist?
52
52
  if @sys.systemd_installed?
53
- systemd = @sys.execute("systemctl is-enabled #{@name} 2>&1 | tail -1").strip
53
+ systemd = service_enabled_status
54
54
  systemd == 'enabled' || systemd == 'disabled'
55
55
  else
56
56
  File.exist?("/etc/init.d/#{@name}")
57
57
  end
58
58
  end
59
59
 
60
+ def enabled?
61
+ if @sys.systemd_installed?
62
+ service_enabled_status == 'enabled'
63
+ end
64
+ end
65
+
60
66
  private
61
67
 
62
68
  def execute(action, options = {})
63
69
  @sys.execute_with_status(command(action, options))
64
70
  end
65
71
 
72
+ def service_enabled_status
73
+ @sys.execute("systemctl is-enabled #{@name} 2>&1 | tail -1").strip
74
+ end
75
+
66
76
  def skip_enablement_message(action, name)
67
77
  # Enable and disable does not work well with globs since they treat them literally.
68
78
  # We are skipping the pulpcore-workers@* for these actions until they are configured in
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '0.6.10'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  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: 0.6.10
4
+ version: 0.7.0
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: 2020-09-04 00:00:00.000000000 Z
11
+ date: 2020-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clamp
@@ -147,6 +147,7 @@ files:
147
147
  - definitions/checks/mongo/db_up.rb
148
148
  - definitions/checks/mongo/tools_installed.rb
149
149
  - definitions/checks/original_assets.rb
150
+ - definitions/checks/package_manager/yum/validate_yum_config.rb
150
151
  - definitions/checks/pulpcore/db_up.rb
151
152
  - definitions/checks/puppet/provide_upgrade_guide.rb
152
153
  - definitions/checks/puppet/verify_no_empty_cacert_requests.rb
@@ -161,7 +162,6 @@ files:
161
162
  - definitions/checks/services_up.rb
162
163
  - definitions/checks/system_registration.rb
163
164
  - definitions/checks/version_locking_enabled.rb
164
- - definitions/checks/yum_exclude.rb
165
165
  - definitions/features/apache.rb
166
166
  - definitions/features/candlepin.rb
167
167
  - definitions/features/candlepin_database.rb
@@ -220,7 +220,9 @@ files:
220
220
  - definitions/procedures/backup/snapshot/mount_pulpcore_db.rb
221
221
  - definitions/procedures/backup/snapshot/prepare_mount.rb
222
222
  - definitions/procedures/candlepin/delete_orphaned_records_from_env_content.rb
223
+ - definitions/procedures/content/migration_stats.rb
223
224
  - definitions/procedures/content/prepare.rb
225
+ - definitions/procedures/content/prepare_abort.rb
224
226
  - definitions/procedures/content/switchover.rb
225
227
  - definitions/procedures/crond/start.rb
226
228
  - definitions/procedures/crond/stop.rb
@@ -239,6 +241,7 @@ files:
239
241
  - definitions/procedures/hammer_setup.rb
240
242
  - definitions/procedures/installer/run.rb
241
243
  - definitions/procedures/installer/upgrade.rb
244
+ - definitions/procedures/installer/upgrade_rake_task.rb
242
245
  - definitions/procedures/iptables/add_maintenance_mode_chain.rb
243
246
  - definitions/procedures/iptables/remove_maintenance_mode_chain.rb
244
247
  - definitions/procedures/knowledge_base_article.rb
@@ -252,6 +255,7 @@ files:
252
255
  - definitions/procedures/packages/update.rb
253
256
  - definitions/procedures/packages/update_all_confirmation.rb
254
257
  - definitions/procedures/passenger_recycler.rb
258
+ - definitions/procedures/prep_6_10_upgrade.rb
255
259
  - definitions/procedures/pulp/migrate.rb
256
260
  - definitions/procedures/pulpcore/migrate.rb
257
261
  - definitions/procedures/puppet/delete_empty_ca_cert_request_files.rb
@@ -287,10 +291,13 @@ files:
287
291
  - definitions/scenarios/content.rb
288
292
  - definitions/scenarios/maintenance_mode.rb
289
293
  - definitions/scenarios/packages.rb
294
+ - definitions/scenarios/prep_6_10_upgrade.rb
290
295
  - definitions/scenarios/restore.rb
291
296
  - definitions/scenarios/services.rb
292
297
  - definitions/scenarios/upgrade_to_capsule_6_8.rb
293
298
  - definitions/scenarios/upgrade_to_capsule_6_8_z.rb
299
+ - definitions/scenarios/upgrade_to_capsule_6_9.rb
300
+ - definitions/scenarios/upgrade_to_capsule_6_9_z.rb
294
301
  - definitions/scenarios/upgrade_to_satellite_6_2.rb
295
302
  - definitions/scenarios/upgrade_to_satellite_6_2_z.rb
296
303
  - definitions/scenarios/upgrade_to_satellite_6_3.rb
@@ -305,6 +312,8 @@ files:
305
312
  - definitions/scenarios/upgrade_to_satellite_6_7_z.rb
306
313
  - definitions/scenarios/upgrade_to_satellite_6_8.rb
307
314
  - definitions/scenarios/upgrade_to_satellite_6_8_z.rb
315
+ - definitions/scenarios/upgrade_to_satellite_6_9.rb
316
+ - definitions/scenarios/upgrade_to_satellite_6_9_z.rb
308
317
  - extras/foreman-maintain.sh
309
318
  - extras/foreman_protector/foreman-protector.conf
310
319
  - extras/foreman_protector/foreman-protector.py
@@ -1,21 +0,0 @@
1
- class Checks::YumExclude < ForemanMaintain::Check
2
- metadata do
3
- label :check_yum_exclude_list
4
- description 'Check if yum exclude list is configured'
5
- tags :pre_upgrade
6
- end
7
-
8
- EXCLUDE_SET_RE = /^exclude\s*=\s*\S+.*$/
9
-
10
- def run
11
- grep_result = grep_yum_exclude
12
- assert(!grep_result.match(EXCLUDE_SET_RE),
13
- 'The /etc/yum.conf has exclude list configured as below,'\
14
- "\n #{grep_result}"\
15
- "\nUnset this as it can cause yum update or upgrade failures !")
16
- end
17
-
18
- def grep_yum_exclude
19
- execute_with_status('grep -w exclude /etc/yum.conf')[1]
20
- end
21
- end