foreman_maintain 0.6.2 → 0.6.3
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 +4 -0
- data/definitions/checks/disk/performance.rb +16 -8
- data/definitions/checks/foreman/validate_external_db_version.rb +28 -0
- data/definitions/checks/original_assets.rb +1 -0
- data/definitions/features/installer.rb +9 -2
- data/definitions/procedures/content/prepare.rb +1 -1
- data/definitions/procedures/content/switchover.rb +7 -3
- data/definitions/procedures/restore/regenerate_missing_queues.rb +52 -0
- data/definitions/scenarios/content.rb +27 -0
- data/definitions/scenarios/packages.rb +2 -4
- data/definitions/scenarios/upgrade_to_capsule_6_7.rb +84 -0
- data/definitions/scenarios/upgrade_to_capsule_6_7_z.rb +84 -0
- data/definitions/scenarios/upgrade_to_capsule_6_8.rb +84 -0
- data/definitions/scenarios/upgrade_to_capsule_6_8_z.rb +84 -0
- data/definitions/scenarios/upgrade_to_satellite_6_2.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_2_z.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_3.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_3_z.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_4.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_4_z.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_5.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_5_z.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_6.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_6_z.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_7.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_7_z.rb +8 -4
- data/definitions/scenarios/upgrade_to_satellite_6_8.rb +84 -0
- data/definitions/scenarios/upgrade_to_satellite_6_8_z.rb +84 -0
- data/lib/foreman_maintain.rb +4 -0
- data/lib/foreman_maintain/cli.rb +2 -0
- data/lib/foreman_maintain/cli/content_command.rb +17 -0
- data/lib/foreman_maintain/concerns/base_database.rb +11 -0
- data/lib/foreman_maintain/concerns/downstream.rb +13 -8
- data/lib/foreman_maintain/upgrade_runner.rb +20 -26
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +13 -3
@@ -0,0 +1,84 @@
|
|
1
|
+
module Scenarios::Satellite_6_8_z
|
2
|
+
class Abstract < ForemanMaintain::Scenario
|
3
|
+
def self.upgrade_metadata(&block)
|
4
|
+
metadata do
|
5
|
+
tags :upgrade_scenario
|
6
|
+
confine do
|
7
|
+
feature(:satellite) &&
|
8
|
+
(feature(:satellite).current_minor_version == '6.8' || \
|
9
|
+
ForemanMaintain.upgrade_in_progress == '6.8.z')
|
10
|
+
end
|
11
|
+
instance_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def target_version
|
16
|
+
'6.8.z'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class PreUpgradeCheck < Abstract
|
21
|
+
upgrade_metadata do
|
22
|
+
description 'Checks before upgrading to Satellite 6.8.z'
|
23
|
+
tags :pre_upgrade_checks
|
24
|
+
run_strategy :fail_slow
|
25
|
+
end
|
26
|
+
|
27
|
+
def compose
|
28
|
+
add_steps(find_checks(:default))
|
29
|
+
add_steps(find_checks(:pre_upgrade))
|
30
|
+
add_step(Checks::Repositories::Validate.new(:version => '6.8'))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class PreMigrations < Abstract
|
35
|
+
upgrade_metadata do
|
36
|
+
description 'Procedures before migrating to Satellite 6.8.z'
|
37
|
+
tags :pre_migrations
|
38
|
+
end
|
39
|
+
|
40
|
+
def compose
|
41
|
+
add_steps(find_procedures(:pre_migrations))
|
42
|
+
add_step(Procedures::Service::Stop.new)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Migrations < Abstract
|
47
|
+
upgrade_metadata do
|
48
|
+
description 'Migration scripts to Satellite 6.8.z'
|
49
|
+
tags :migrations
|
50
|
+
end
|
51
|
+
|
52
|
+
def compose
|
53
|
+
add_step(Procedures::Repositories::Setup.new(:version => '6.8'))
|
54
|
+
add_step(Procedures::Packages::UnlockVersions.new)
|
55
|
+
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
56
|
+
add_step(Procedures::Installer::Upgrade.new)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class PostMigrations < Abstract
|
61
|
+
upgrade_metadata do
|
62
|
+
description 'Procedures after migrating to Satellite 6.8.z'
|
63
|
+
tags :post_migrations
|
64
|
+
end
|
65
|
+
|
66
|
+
def compose
|
67
|
+
add_step(Procedures::Service::Start.new)
|
68
|
+
add_steps(find_procedures(:post_migrations))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
class PostUpgradeChecks < Abstract
|
73
|
+
upgrade_metadata do
|
74
|
+
description 'Checks after upgrading to Satellite 6.8.z'
|
75
|
+
tags :post_upgrade_checks
|
76
|
+
run_strategy :fail_slow
|
77
|
+
end
|
78
|
+
|
79
|
+
def compose
|
80
|
+
add_steps(find_checks(:default))
|
81
|
+
add_steps(find_checks(:post_upgrade))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/lib/foreman_maintain.rb
CHANGED
data/lib/foreman_maintain/cli.rb
CHANGED
@@ -10,6 +10,7 @@ require 'foreman_maintain/cli/service_command'
|
|
10
10
|
require 'foreman_maintain/cli/restore_command'
|
11
11
|
require 'foreman_maintain/cli/maintenance_mode_command'
|
12
12
|
require 'foreman_maintain/cli/packages_command'
|
13
|
+
require 'foreman_maintain/cli/content_command'
|
13
14
|
|
14
15
|
module ForemanMaintain
|
15
16
|
module Cli
|
@@ -23,6 +24,7 @@ module ForemanMaintain
|
|
23
24
|
subcommand 'restore', 'Restore a backup', RestoreCommand
|
24
25
|
subcommand 'packages', 'Lock/Unlock package protection, install, update', PackagesCommand
|
25
26
|
subcommand 'advanced', 'Advanced tools for server maintenance', AdvancedCommand
|
27
|
+
subcommand 'content', 'Content related commands', ContentCommand
|
26
28
|
subcommand 'maintenance-mode', 'Control maintenance-mode for application',
|
27
29
|
MaintenanceModeCommand
|
28
30
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
module Cli
|
3
|
+
class ContentCommand < Base
|
4
|
+
subcommand 'prepare', 'Prepare content for Pulp 3' do
|
5
|
+
def execute
|
6
|
+
run_scenarios_and_exit(Scenarios::Content::Prepare.new)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
subcommand 'switchover', 'Switch support for certain content from Pulp 2 to Pulp 3' do
|
11
|
+
def execute
|
12
|
+
run_scenarios_and_exit(Scenarios::Content::Switchover.new)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -150,6 +150,17 @@ module ForemanMaintain
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
+
def db_version(config = configuration)
|
154
|
+
if ping(config)
|
155
|
+
# Note - t removes headers, -A removes alignment whitespace
|
156
|
+
server_version_cmd = psql_command(config) + ' -c "SHOW server_version" -t -A'
|
157
|
+
version_string = execute!(server_version_cmd, :hidden_patterns => [config['password']])
|
158
|
+
version(version_string)
|
159
|
+
else
|
160
|
+
raise_service_error
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
153
164
|
private
|
154
165
|
|
155
166
|
def base_command(config, command = 'psql')
|
@@ -98,16 +98,21 @@ module ForemanMaintain
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def common_repos(rh_version_major, full_version)
|
101
|
-
|
102
|
-
|
101
|
+
repos_arrary = common_repos_array(rh_version_major, full_version)
|
102
|
+
return repos_arrary.first(1) if feature(:capsule)
|
103
103
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
repos_arrary
|
105
|
+
end
|
106
|
+
|
107
|
+
def common_repos_array(rh_version_major, full_version)
|
108
|
+
["rhel-#{rh_version_major}-server-satellite-maintenance-6#{use_beta}-rpms",
|
109
|
+
"rhel-#{rh_version_major}-server-satellite-tools-#{full_version}#{use_beta}-rpms"]
|
110
|
+
end
|
111
|
+
|
112
|
+
def use_beta
|
113
|
+
return '-beta' if ENV['FOREMAN_MAINTAIN_USE_BETA'] == '1'
|
109
114
|
|
110
|
-
|
115
|
+
nil
|
111
116
|
end
|
112
117
|
|
113
118
|
def main_rh_repos(rh_version_major)
|
@@ -15,29 +15,8 @@ module ForemanMaintain
|
|
15
15
|
def available_targets
|
16
16
|
# when some upgrade is in progress, we don't allow upgrade to different version
|
17
17
|
return [current_target_version] if current_target_version
|
18
|
-
versions_to_tags.inject([]) do |available_targets, (version, tag)|
|
19
|
-
if !find_scenarios(:tags => [tag]).empty?
|
20
|
-
available_targets << version
|
21
|
-
else
|
22
|
-
available_targets
|
23
|
-
end
|
24
|
-
end.sort
|
25
|
-
end
|
26
|
-
|
27
|
-
def versions_to_tags
|
28
|
-
@versions_to_tags ||= {}
|
29
|
-
end
|
30
|
-
|
31
|
-
# registers target version to specific tag
|
32
|
-
def register_version(version, tag)
|
33
|
-
if versions_to_tags.key?(version) && versions_to_tags[version] != tag
|
34
|
-
raise "Version #{version} already registered to tag #{versions_to_tags[version]}"
|
35
|
-
end
|
36
|
-
@versions_to_tags[version] = tag
|
37
|
-
end
|
38
18
|
|
39
|
-
|
40
|
-
versions_to_tags.clear
|
19
|
+
find_scenarios(:tags => :upgrade_scenario).map(&:target_version).uniq.sort
|
41
20
|
end
|
42
21
|
|
43
22
|
def current_target_version
|
@@ -57,25 +36,35 @@ module ForemanMaintain
|
|
57
36
|
|
58
37
|
def initialize(version, reporter, options = {})
|
59
38
|
super(reporter, [], options)
|
60
|
-
@tag = self.class.versions_to_tags[version]
|
61
|
-
raise "Unknown version #{version}" unless tag
|
62
39
|
@version = version
|
40
|
+
scenarios_present = find_scenarios(:tags => :upgrade_scenario).any?(&matching_version_test)
|
41
|
+
raise "Unknown version #{version}" unless scenarios_present
|
42
|
+
|
63
43
|
@scenario_cache = {}
|
64
44
|
self.phase = :pre_upgrade_checks
|
65
45
|
end
|
66
46
|
|
67
47
|
def scenario(phase)
|
68
48
|
return @scenario_cache[phase] if @scenario_cache.key?(phase)
|
69
|
-
|
70
|
-
|
49
|
+
|
50
|
+
condition = { :tags => [:upgrade_scenario, phase] }
|
51
|
+
matching_scenarios = find_scenarios(condition).select(&matching_version_test)
|
71
52
|
raise "Too many scenarios match #{condition.inspect}" if matching_scenarios.size > 1
|
53
|
+
|
72
54
|
@scenario_cache[phase] = matching_scenarios.first
|
73
55
|
end
|
74
56
|
|
57
|
+
def matching_version_test
|
58
|
+
proc do |scenario|
|
59
|
+
scenario.respond_to?(:target_version) && scenario.target_version == @version
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
75
63
|
def run
|
76
64
|
self.class.current_target_version = @version
|
77
65
|
PHASES.each do |phase|
|
78
66
|
return run_rollback if quit?
|
67
|
+
|
79
68
|
if skip?(phase)
|
80
69
|
skip_phase(phase)
|
81
70
|
else
|
@@ -127,6 +116,7 @@ module ForemanMaintain
|
|
127
116
|
# deserializes the state of the run from the storage
|
128
117
|
def load
|
129
118
|
return unless storage[:serialized]
|
119
|
+
|
130
120
|
load_from_hash(storage[:serialized])
|
131
121
|
end
|
132
122
|
|
@@ -134,6 +124,7 @@ module ForemanMaintain
|
|
134
124
|
with_non_empty_scenario(phase) do |scenario|
|
135
125
|
confirm_scenario(scenario)
|
136
126
|
return if quit?
|
127
|
+
|
137
128
|
self.phase = phase
|
138
129
|
run_scenario(scenario)
|
139
130
|
# if we started from the :pre_upgrade_checks, ensure to ask before
|
@@ -158,6 +149,7 @@ module ForemanMaintain
|
|
158
149
|
# rubocop:disable Metrics/MethodLength
|
159
150
|
def rollback_pre_migrations
|
160
151
|
raise "Unexpected phase #{phase}, expecting pre_migrations" unless phase == :pre_migrations
|
152
|
+
|
161
153
|
rollback_needed = scenario(:pre_migrations).steps.any? { |s| s.executed? && s.success? }
|
162
154
|
if rollback_needed
|
163
155
|
@quit = false
|
@@ -198,6 +190,7 @@ module ForemanMaintain
|
|
198
190
|
unless @scenario_cache.empty?
|
199
191
|
raise "Some scenarios are already initialized: #{@scenario_cache.keys}"
|
200
192
|
end
|
193
|
+
|
201
194
|
self.phase = hash[:phase]
|
202
195
|
hash[:scenarios].each do |key, scenario_hash|
|
203
196
|
@scenario_cache[key] = Scenario.new_from_hash(scenario_hash)
|
@@ -229,6 +222,7 @@ module ForemanMaintain
|
|
229
222
|
|
230
223
|
def phase=(phase)
|
231
224
|
raise "Unknown phase #{phase}" unless PHASES.include?(phase)
|
225
|
+
|
232
226
|
@phase = phase
|
233
227
|
end
|
234
228
|
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.
|
4
|
+
version: 0.6.3
|
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-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- definitions/checks/foreman/db_up.rb
|
133
133
|
- definitions/checks/foreman/facts_names.rb
|
134
134
|
- definitions/checks/foreman/puppet_class_duplicates.rb
|
135
|
+
- definitions/checks/foreman/validate_external_db_version.rb
|
135
136
|
- definitions/checks/foreman_openscap/invalid_report_associations.rb
|
136
137
|
- definitions/checks/foreman_proxy/verify_dhcp_config_syntax.rb
|
137
138
|
- definitions/checks/foreman_tasks/invalid/check_old.rb
|
@@ -263,6 +264,7 @@ files:
|
|
263
264
|
- definitions/procedures/restore/pg_global_objects.rb
|
264
265
|
- definitions/procedures/restore/postgres_owner.rb
|
265
266
|
- definitions/procedures/restore/pulpcore_dump.rb
|
267
|
+
- definitions/procedures/restore/regenerate_missing_queues.rb
|
266
268
|
- definitions/procedures/selinux/set_file_security.rb
|
267
269
|
- definitions/procedures/service/base.rb
|
268
270
|
- definitions/procedures/service/daemon_reload.rb
|
@@ -276,10 +278,15 @@ files:
|
|
276
278
|
- definitions/procedures/sync_plans/disable.rb
|
277
279
|
- definitions/procedures/sync_plans/enable.rb
|
278
280
|
- definitions/scenarios/backup.rb
|
281
|
+
- definitions/scenarios/content.rb
|
279
282
|
- definitions/scenarios/maintenance_mode.rb
|
280
283
|
- definitions/scenarios/packages.rb
|
281
284
|
- definitions/scenarios/restore.rb
|
282
285
|
- definitions/scenarios/services.rb
|
286
|
+
- definitions/scenarios/upgrade_to_capsule_6_7.rb
|
287
|
+
- definitions/scenarios/upgrade_to_capsule_6_7_z.rb
|
288
|
+
- definitions/scenarios/upgrade_to_capsule_6_8.rb
|
289
|
+
- definitions/scenarios/upgrade_to_capsule_6_8_z.rb
|
283
290
|
- definitions/scenarios/upgrade_to_satellite_6_2.rb
|
284
291
|
- definitions/scenarios/upgrade_to_satellite_6_2_z.rb
|
285
292
|
- definitions/scenarios/upgrade_to_satellite_6_3.rb
|
@@ -292,6 +299,8 @@ files:
|
|
292
299
|
- definitions/scenarios/upgrade_to_satellite_6_6_z.rb
|
293
300
|
- definitions/scenarios/upgrade_to_satellite_6_7.rb
|
294
301
|
- definitions/scenarios/upgrade_to_satellite_6_7_z.rb
|
302
|
+
- definitions/scenarios/upgrade_to_satellite_6_8.rb
|
303
|
+
- definitions/scenarios/upgrade_to_satellite_6_8_z.rb
|
295
304
|
- extras/foreman-maintain.sh
|
296
305
|
- extras/foreman_protector/foreman-protector.conf
|
297
306
|
- extras/foreman_protector/foreman-protector.py
|
@@ -309,6 +318,7 @@ files:
|
|
309
318
|
- lib/foreman_maintain/cli/advanced_command.rb
|
310
319
|
- lib/foreman_maintain/cli/backup_command.rb
|
311
320
|
- lib/foreman_maintain/cli/base.rb
|
321
|
+
- lib/foreman_maintain/cli/content_command.rb
|
312
322
|
- lib/foreman_maintain/cli/health_command.rb
|
313
323
|
- lib/foreman_maintain/cli/maintenance_mode_command.rb
|
314
324
|
- lib/foreman_maintain/cli/packages_command.rb
|
@@ -390,7 +400,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
390
400
|
- !ruby/object:Gem::Version
|
391
401
|
version: '0'
|
392
402
|
requirements: []
|
393
|
-
rubygems_version: 3.0.
|
403
|
+
rubygems_version: 3.0.8
|
394
404
|
signing_key:
|
395
405
|
specification_version: 4
|
396
406
|
summary: Foreman maintenance tool belt
|