foreman_maintain 0.6.11 → 0.7.1
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/definitions/checks/foreman/check_checkpoint_segments.rb +30 -22
- data/definitions/checks/package_manager/yum/validate_yum_config.rb +51 -0
- data/definitions/features/foreman_cockpit.rb +15 -0
- data/definitions/features/pulpcore.rb +23 -6
- data/definitions/procedures/backup/accessibility_confirmation.rb +1 -1
- data/definitions/procedures/backup/online/safety_confirmation.rb +10 -6
- data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +1 -1
- data/definitions/procedures/content/migration_stats.rb +12 -0
- data/definitions/procedures/content/prepare.rb +2 -6
- data/definitions/procedures/content/prepare_abort.rb +12 -0
- data/definitions/procedures/content/switchover.rb +1 -1
- data/definitions/procedures/installer/upgrade_rake_task.rb +11 -0
- data/definitions/procedures/packages/installer_confirmation.rb +1 -1
- data/definitions/procedures/packages/update_all_confirmation.rb +1 -1
- data/definitions/procedures/prep_6_10_upgrade.rb +31 -0
- data/definitions/procedures/restore/confirmation.rb +1 -1
- data/definitions/procedures/restore/installer_reset.rb +10 -1
- data/definitions/scenarios/content.rb +50 -3
- data/definitions/scenarios/prep_6_10_upgrade.rb +13 -0
- data/definitions/scenarios/upgrade_to_capsule_6_9.rb +88 -0
- data/definitions/scenarios/upgrade_to_capsule_6_9_z.rb +88 -0
- data/definitions/scenarios/upgrade_to_satellite_6_8.rb +1 -0
- data/definitions/scenarios/upgrade_to_satellite_6_8_z.rb +1 -0
- data/definitions/scenarios/upgrade_to_satellite_6_9.rb +90 -0
- data/definitions/scenarios/upgrade_to_satellite_6_9_z.rb +89 -0
- data/extras/foreman_protector/foreman-protector.whitelist +1 -0
- data/lib/foreman_maintain.rb +1 -1
- data/lib/foreman_maintain/cli.rb +9 -0
- data/lib/foreman_maintain/cli/content_command.rb +17 -2
- data/lib/foreman_maintain/concerns/downstream.rb +4 -0
- data/lib/foreman_maintain/package_manager/dnf.rb +1 -0
- data/lib/foreman_maintain/reporter.rb +18 -13
- data/lib/foreman_maintain/reporter/cli_reporter.rb +18 -9
- data/lib/foreman_maintain/runner.rb +6 -4
- data/lib/foreman_maintain/scenario.rb +4 -0
- data/lib/foreman_maintain/utils/backup.rb +1 -1
- data/lib/foreman_maintain/utils/service/systemd.rb +11 -1
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +13 -3
- data/definitions/checks/yum_exclude.rb +0 -21
@@ -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
|
-
|
50
|
-
|
51
|
-
|
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}, [
|
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,
|
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
|
-
|
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,
|
185
|
+
ask_to_select('Select step to continue', steps, run_strategy)
|
185
186
|
end
|
186
187
|
|
187
|
-
|
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}, [#{
|
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
|
-
|
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 =
|
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
|
-
|
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)
|
@@ -163,7 +163,7 @@ module ForemanMaintain
|
|
163
163
|
def validate_hostname?
|
164
164
|
# make sure that the system hostname is the same as the backup
|
165
165
|
config_tarball = file_map[:config_files][:path]
|
166
|
-
tar_cmd = "tar zxf #{config_tarball} etc/httpd/conf/httpd.conf --to-stdout"
|
166
|
+
tar_cmd = "tar zxf #{config_tarball} etc/httpd/conf/httpd.conf --to-stdout --occurrence=1"
|
167
167
|
status, httpd_config = execute_with_status(tar_cmd)
|
168
168
|
|
169
169
|
# Incremental backups sometimes don't include httpd.conf. Since a "base" backup
|
@@ -50,19 +50,29 @@ module ForemanMaintain::Utils
|
|
50
50
|
|
51
51
|
def exist?
|
52
52
|
if @sys.systemd_installed?
|
53
|
-
systemd =
|
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
|
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.
|
4
|
+
version: 0.7.1
|
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-
|
11
|
+
date: 2020-12-04 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
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- definitions/features/dynflow_sidekiq.rb
|
171
171
|
- definitions/features/foreman_1_11_x.rb
|
172
172
|
- definitions/features/foreman_1_7_x.rb
|
173
|
+
- definitions/features/foreman_cockpit.rb
|
173
174
|
- definitions/features/foreman_database.rb
|
174
175
|
- definitions/features/foreman_openscap.rb
|
175
176
|
- definitions/features/foreman_proxy.rb
|
@@ -220,7 +221,9 @@ files:
|
|
220
221
|
- definitions/procedures/backup/snapshot/mount_pulpcore_db.rb
|
221
222
|
- definitions/procedures/backup/snapshot/prepare_mount.rb
|
222
223
|
- definitions/procedures/candlepin/delete_orphaned_records_from_env_content.rb
|
224
|
+
- definitions/procedures/content/migration_stats.rb
|
223
225
|
- definitions/procedures/content/prepare.rb
|
226
|
+
- definitions/procedures/content/prepare_abort.rb
|
224
227
|
- definitions/procedures/content/switchover.rb
|
225
228
|
- definitions/procedures/crond/start.rb
|
226
229
|
- definitions/procedures/crond/stop.rb
|
@@ -239,6 +242,7 @@ files:
|
|
239
242
|
- definitions/procedures/hammer_setup.rb
|
240
243
|
- definitions/procedures/installer/run.rb
|
241
244
|
- definitions/procedures/installer/upgrade.rb
|
245
|
+
- definitions/procedures/installer/upgrade_rake_task.rb
|
242
246
|
- definitions/procedures/iptables/add_maintenance_mode_chain.rb
|
243
247
|
- definitions/procedures/iptables/remove_maintenance_mode_chain.rb
|
244
248
|
- definitions/procedures/knowledge_base_article.rb
|
@@ -252,6 +256,7 @@ files:
|
|
252
256
|
- definitions/procedures/packages/update.rb
|
253
257
|
- definitions/procedures/packages/update_all_confirmation.rb
|
254
258
|
- definitions/procedures/passenger_recycler.rb
|
259
|
+
- definitions/procedures/prep_6_10_upgrade.rb
|
255
260
|
- definitions/procedures/pulp/migrate.rb
|
256
261
|
- definitions/procedures/pulpcore/migrate.rb
|
257
262
|
- definitions/procedures/puppet/delete_empty_ca_cert_request_files.rb
|
@@ -287,10 +292,13 @@ files:
|
|
287
292
|
- definitions/scenarios/content.rb
|
288
293
|
- definitions/scenarios/maintenance_mode.rb
|
289
294
|
- definitions/scenarios/packages.rb
|
295
|
+
- definitions/scenarios/prep_6_10_upgrade.rb
|
290
296
|
- definitions/scenarios/restore.rb
|
291
297
|
- definitions/scenarios/services.rb
|
292
298
|
- definitions/scenarios/upgrade_to_capsule_6_8.rb
|
293
299
|
- definitions/scenarios/upgrade_to_capsule_6_8_z.rb
|
300
|
+
- definitions/scenarios/upgrade_to_capsule_6_9.rb
|
301
|
+
- definitions/scenarios/upgrade_to_capsule_6_9_z.rb
|
294
302
|
- definitions/scenarios/upgrade_to_satellite_6_2.rb
|
295
303
|
- definitions/scenarios/upgrade_to_satellite_6_2_z.rb
|
296
304
|
- definitions/scenarios/upgrade_to_satellite_6_3.rb
|
@@ -305,6 +313,8 @@ files:
|
|
305
313
|
- definitions/scenarios/upgrade_to_satellite_6_7_z.rb
|
306
314
|
- definitions/scenarios/upgrade_to_satellite_6_8.rb
|
307
315
|
- definitions/scenarios/upgrade_to_satellite_6_8_z.rb
|
316
|
+
- definitions/scenarios/upgrade_to_satellite_6_9.rb
|
317
|
+
- definitions/scenarios/upgrade_to_satellite_6_9_z.rb
|
308
318
|
- extras/foreman-maintain.sh
|
309
319
|
- extras/foreman_protector/foreman-protector.conf
|
310
320
|
- 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
|