foreman_maintain 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/checks/candlepin/db_up.rb +10 -6
- data/definitions/checks/foreman/db_up.rb +10 -6
- data/definitions/checks/mongo/db_up.rb +10 -6
- data/definitions/features/foreman_tasks.rb +3 -3
- data/definitions/features/mongo.rb +10 -0
- data/definitions/features/service.rb +37 -18
- data/definitions/procedures/content/migration_reset.rb +12 -0
- data/definitions/procedures/pulp/remove.rb +87 -0
- data/definitions/procedures/service/base.rb +1 -2
- data/definitions/procedures/service/list.rb +1 -0
- data/definitions/scenarios/content.rb +30 -0
- data/definitions/scenarios/restore.rb +1 -1
- data/lib/foreman_maintain/cli/content_command.rb +12 -0
- data/lib/foreman_maintain/concerns/base_database.rb +11 -0
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 743d74ea6833807f28ea4f14096821c03d080ede64f8cc74ee4146b4dd8eea26
|
4
|
+
data.tar.gz: 4b54030179cb8019c0a5936f5accfb8a91f6a092c9221cd1b03e9d342c5bbaa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89f47a46c1061c416d9042c116dea5ad0acbf973418d4452e44500a8ebbb55cd598d3d3001332ec92970094dd2ebd36af8a92fde9d28835a5544e96d6bd333d0
|
7
|
+
data.tar.gz: 370b409946044d658e102e0aa64733842163b5834289b7cf059dd16733ee2e6f1263aa6221212caa3b5fcb1f77fd81519c414e542357cac8df579f0d4031c7fd
|
@@ -9,15 +9,19 @@ module Checks
|
|
9
9
|
|
10
10
|
def run
|
11
11
|
status = false
|
12
|
-
|
13
|
-
|
12
|
+
if feature(:candlepin_database).psql_cmd_available?
|
13
|
+
with_spinner('Checking connection to the Candlepin DB') do
|
14
|
+
status = feature(:candlepin_database).ping
|
15
|
+
end
|
16
|
+
assert(status, 'Candlepin DB is not responding. ' \
|
17
|
+
'It needs to be up and running to perform the following steps',
|
18
|
+
:next_steps => start_pgsql)
|
19
|
+
else
|
20
|
+
feature(:candlepin_database).raise_psql_missing_error
|
14
21
|
end
|
15
|
-
assert(status, 'Candlepin DB is not responding. ' \
|
16
|
-
'It needs to be up and running to perform the following steps',
|
17
|
-
:next_steps => next_steps)
|
18
22
|
end
|
19
23
|
|
20
|
-
def
|
24
|
+
def start_pgsql
|
21
25
|
if feature(:candlepin_database).local?
|
22
26
|
[Procedures::Service::Start.new(:only => 'postgresql')]
|
23
27
|
else
|
@@ -9,15 +9,19 @@ module Checks
|
|
9
9
|
|
10
10
|
def run
|
11
11
|
status = false
|
12
|
-
|
13
|
-
|
12
|
+
if feature(:foreman_database).psql_cmd_available?
|
13
|
+
with_spinner('Checking connection to the Foreman DB') do
|
14
|
+
status = feature(:foreman_database).ping
|
15
|
+
end
|
16
|
+
assert(status, 'Foreman DB is not responding. ' \
|
17
|
+
'It needs to be up and running to perform the following steps',
|
18
|
+
:next_steps => start_pgsql)
|
19
|
+
else
|
20
|
+
feature(:foreman_database).raise_psql_missing_error
|
14
21
|
end
|
15
|
-
assert(status, 'Foreman DB is not responding. ' \
|
16
|
-
'It needs to be up and running to perform the following steps',
|
17
|
-
:next_steps => next_steps)
|
18
22
|
end
|
19
23
|
|
20
|
-
def
|
24
|
+
def start_pgsql
|
21
25
|
if feature(:foreman_database).local?
|
22
26
|
[Procedures::Service::Start.new(:only => 'postgresql')]
|
23
27
|
else
|
@@ -9,15 +9,19 @@ module Checks
|
|
9
9
|
|
10
10
|
def run
|
11
11
|
status = false
|
12
|
-
|
13
|
-
|
12
|
+
if feature(:mongo).mongo_cmd_available?
|
13
|
+
with_spinner('Checking connection to the Mongo DB') do
|
14
|
+
status = feature(:mongo).ping
|
15
|
+
end
|
16
|
+
assert(status, 'Mongo DB is not responding. ' \
|
17
|
+
'It needs to be up and running to perform the following steps.',
|
18
|
+
:next_steps => start_mongodb)
|
19
|
+
else
|
20
|
+
feature(:mongo).raise_mongo_client_missing_error
|
14
21
|
end
|
15
|
-
assert(status, 'Mongo DB is not responding. ' \
|
16
|
-
'It needs to be up and running to perform the following steps.',
|
17
|
-
:next_steps => next_steps)
|
18
22
|
end
|
19
23
|
|
20
|
-
def
|
24
|
+
def start_mongodb
|
21
25
|
if feature(:mongo).local?
|
22
26
|
[Procedures::Service::Start.new(:only => feature(:mongo).services)]
|
23
27
|
else
|
@@ -97,10 +97,10 @@ class Features::ForemanTasks < ForemanMaintain::Feature
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def resume_task_using_hammer
|
100
|
-
if
|
101
|
-
feature(:hammer).run('task resume --search ""')
|
100
|
+
if feature(:satellite) && feature(:satellite).current_minor_version == '6.8'
|
101
|
+
feature(:hammer).run('task resume --search "" --fields="Total tasks resumed"')
|
102
102
|
else
|
103
|
-
feature(:hammer).run('task resume')
|
103
|
+
feature(:hammer).run('task resume --fields="Total tasks resumed"')
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
@@ -140,6 +140,16 @@ class Features::Mongo < ForemanMaintain::Feature
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
+
def mongo_cmd_available?
|
144
|
+
exit_status, _output = execute_with_status("which #{core.client_command}")
|
145
|
+
exit_status == 0
|
146
|
+
end
|
147
|
+
|
148
|
+
def raise_mongo_client_missing_error
|
149
|
+
raise ForemanMaintain::Error::Fail, "The #{core.client_command} command not found."\
|
150
|
+
" Make sure system has #{core.client_command} utility installed."
|
151
|
+
end
|
152
|
+
|
143
153
|
private
|
144
154
|
|
145
155
|
def load_mongo_core_default(version)
|
@@ -8,7 +8,6 @@ class Features::Service < ForemanMaintain::Feature
|
|
8
8
|
# { :only => ["httpd"] }
|
9
9
|
# { :exclude => ["pulp-workers", "tomcat"] }
|
10
10
|
# { :include => ["crond"] }
|
11
|
-
|
12
11
|
if feature(:instance).downstream && feature(:instance).downstream.less_than_version?('6.3')
|
13
12
|
use_katello_service(action, options)
|
14
13
|
else
|
@@ -27,11 +26,12 @@ class Features::Service < ForemanMaintain::Feature
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def filtered_services(options)
|
30
|
-
|
31
|
-
|
32
|
-
raise 'No services found matching your parameters' unless
|
29
|
+
services = include_unregistered_services(existing_services, options[:include])
|
30
|
+
services = filter_services(services, options)
|
31
|
+
raise 'No services found matching your parameters' unless services.any?
|
32
|
+
return services unless options[:reverse]
|
33
33
|
|
34
|
-
|
34
|
+
Hash[services.sort_by { |k, _| k.to_i }.reverse]
|
35
35
|
end
|
36
36
|
|
37
37
|
def action_noun(action)
|
@@ -61,40 +61,59 @@ class Features::Service < ForemanMaintain::Feature
|
|
61
61
|
def run_action_on_services(action, options, spinner)
|
62
62
|
status = 0
|
63
63
|
failed_services = []
|
64
|
+
filtered_services(options).each_value do |group|
|
65
|
+
systemctl_status, _output = execute_with_status('systemctl ' \
|
66
|
+
"#{action} #{group.map(&:name).join(' ')}")
|
67
|
+
display_status(group, options, action, spinner)
|
68
|
+
if systemctl_status > 0
|
69
|
+
status = systemctl_status
|
70
|
+
failed_services |= failed_services_by_status(action, group, spinner)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
[status, failed_services]
|
74
|
+
end
|
64
75
|
|
65
|
-
|
76
|
+
def display_status(services, options, action, spinner)
|
77
|
+
services.each do |service|
|
66
78
|
spinner.update("#{action_noun(action)} #{service}")
|
67
|
-
|
68
|
-
|
69
|
-
formatted = format_status(output, item_status, options)
|
79
|
+
formatted = format_status(service.status, options, action)
|
70
80
|
puts formatted unless formatted.empty?
|
71
|
-
|
72
|
-
if item_status > 0
|
73
|
-
status = item_status
|
74
|
-
failed_services << service
|
75
|
-
end
|
76
81
|
end
|
77
|
-
[status, failed_services]
|
78
82
|
end
|
79
83
|
|
80
|
-
def format_status(
|
84
|
+
def format_status(service_status, options, action)
|
85
|
+
exit_code, output = service_status
|
81
86
|
status = ''
|
82
87
|
if !options[:failing] || exit_code > 0
|
83
88
|
if options[:brief]
|
84
89
|
status += format_brief_status(exit_code)
|
85
|
-
elsif
|
90
|
+
elsif include_output?(action, exit_code)
|
86
91
|
status += "\n" + output
|
87
92
|
end
|
88
93
|
end
|
89
94
|
status
|
90
95
|
end
|
91
96
|
|
97
|
+
def include_output?(action, status)
|
98
|
+
(action == 'start' && status > 0) ||
|
99
|
+
action == 'status'
|
100
|
+
end
|
101
|
+
|
92
102
|
def format_brief_status(exit_code)
|
93
103
|
result = exit_code == 0 ? reporter.status_label(:success) : reporter.status_label(:fail)
|
94
104
|
padding = reporter.max_length - reporter.last_line.to_s.length - 30
|
95
105
|
"#{' ' * padding} #{result}"
|
96
106
|
end
|
97
107
|
|
108
|
+
def failed_services_by_status(action, services, spinner)
|
109
|
+
failed_services = []
|
110
|
+
services.each do |service|
|
111
|
+
spinner.update("#{action_noun(action)} #{service}")
|
112
|
+
failed_services << service unless service.running?
|
113
|
+
end
|
114
|
+
failed_services
|
115
|
+
end
|
116
|
+
|
98
117
|
def allowed_action?(action)
|
99
118
|
%w[start stop restart status enable disable].include?(action)
|
100
119
|
end
|
@@ -119,7 +138,7 @@ class Features::Service < ForemanMaintain::Feature
|
|
119
138
|
end
|
120
139
|
|
121
140
|
service_list = extend_service_list_with_sockets(service_list, options)
|
122
|
-
service_list.
|
141
|
+
service_list.group_by(&:priority).to_h
|
123
142
|
end
|
124
143
|
|
125
144
|
def include_unregistered_services(service_list, services_filter)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Procedures::Content
|
2
|
+
class MigrationReset < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Reset the Pulp 2 to Pulp 3 migration data (pre-switchover)'
|
5
|
+
for_feature :pulpcore
|
6
|
+
end
|
7
|
+
|
8
|
+
def run
|
9
|
+
puts execute!('foreman-rake katello:pulp3_migration_reset')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Procedures::Pulp
|
2
|
+
class Remove < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Remove pulp2'
|
5
|
+
|
6
|
+
confine do
|
7
|
+
check_min_version('katello-common', '4.0')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def sys
|
12
|
+
ForemanMaintain::Utils::SystemHelpers.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def pulp_data_dirs
|
16
|
+
[
|
17
|
+
'/var/lib/pulp/published',
|
18
|
+
'/var/lib/pulp/content',
|
19
|
+
'/var/lib/pulp/importers',
|
20
|
+
'/var/lib/pulp/uploads',
|
21
|
+
'/var/lib/mongodb/'
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
def pulp_packages
|
26
|
+
[
|
27
|
+
'pulp-server', 'python-pulp-streamer', 'pulp-puppet-plugins',
|
28
|
+
'python-pulp-rpm-common', 'python-pulp-common',
|
29
|
+
'pulp-selinux', 'python-pulp-oid_validation',
|
30
|
+
'python-pulp-puppet-common', 'python-pulp-repoauth',
|
31
|
+
'pulp-rpm-plugins', 'python-blinker', 'python-celery',
|
32
|
+
'python-django', 'python-isodate', 'python-ldap',
|
33
|
+
'python-mongoengine', 'python-nectar', 'python-oauth2',
|
34
|
+
'python-pymongo'
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
38
|
+
def data_dir_removal_cmds
|
39
|
+
pulp_data_dirs.collect { |dir| "rm -rf #{dir}" }
|
40
|
+
end
|
41
|
+
|
42
|
+
def ask_to_proceed(rm_cmds)
|
43
|
+
question = "\nWARNING: All pulp2 packages will be removed with the following commands:\n" \
|
44
|
+
"\n# yum remove #{pulp_packages.join(' ')}" \
|
45
|
+
"\n# yum remove rh-mongodb34-*" \
|
46
|
+
"\n\nAll pulp2 data will be removed.\n"
|
47
|
+
question += rm_cmds.collect { |cmd| "\n# #{cmd}" }.join
|
48
|
+
question += "\n\nDo you want to proceed?"
|
49
|
+
answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
|
50
|
+
abort! if answer != :yes
|
51
|
+
end
|
52
|
+
|
53
|
+
def run
|
54
|
+
rm_cmds = data_dir_removal_cmds
|
55
|
+
ask_to_proceed(rm_cmds)
|
56
|
+
|
57
|
+
remove_pulp
|
58
|
+
|
59
|
+
remove_mongo
|
60
|
+
|
61
|
+
delete_pulp_data(rm_cmds)
|
62
|
+
end
|
63
|
+
|
64
|
+
def remove_pulp
|
65
|
+
with_spinner('Removing pulp2 packages') do
|
66
|
+
packages_action(:remove, pulp_packages, :assumeyes => true)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def remove_mongo
|
71
|
+
with_spinner('Removing mongo packages') do
|
72
|
+
packages_action(:remove, ['rh-mongodb34-*'], :assumeyes => true)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def delete_pulp_data(rm_cmds)
|
77
|
+
with_spinner('Deleting pulp2 data directories') do |spinner|
|
78
|
+
rm_cmds.each do |cmd|
|
79
|
+
if File.directory?(cmd.split[2])
|
80
|
+
execute!(cmd)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
spinner.update('Done deleting pulp2 data directories')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -18,7 +18,6 @@ module Procedures
|
|
18
18
|
puts "\n#{action_noun} the following service(s):"
|
19
19
|
services = feature(:service).filtered_services(options)
|
20
20
|
print_services(services)
|
21
|
-
|
22
21
|
with_spinner('') do |spinner|
|
23
22
|
feature(:service).handle_services(spinner, action, options)
|
24
23
|
end
|
@@ -31,7 +30,7 @@ module Procedures
|
|
31
30
|
private
|
32
31
|
|
33
32
|
def print_services(services)
|
34
|
-
puts services.
|
33
|
+
puts services.values.flatten(1).join(', ')
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
@@ -78,5 +78,35 @@ module ForemanMaintain::Scenarios
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
|
+
|
82
|
+
class MigrationReset < ForemanMaintain::Scenario
|
83
|
+
metadata do
|
84
|
+
label :content_migration_reset
|
85
|
+
description 'Reset the Pulp 2 to Pulp 3 migration data (pre-switchover)'
|
86
|
+
manual_detection
|
87
|
+
end
|
88
|
+
|
89
|
+
def compose
|
90
|
+
if feature(:satellite) && feature(:satellite).at_least_version?('6.9')
|
91
|
+
enable_and_start_services
|
92
|
+
add_step(Procedures::Content::MigrationReset)
|
93
|
+
disable_and_stop_services
|
94
|
+
elsif !feature(:satellite)
|
95
|
+
add_step(Procedures::Content::MigrationReset)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class RemovePulp2 < ForemanMaintain::Scenario
|
101
|
+
metadata do
|
102
|
+
label :content_remove_pulp2
|
103
|
+
description 'Remove Pulp2 and mongodb packages and data'
|
104
|
+
manual_detection
|
105
|
+
end
|
106
|
+
|
107
|
+
def compose
|
108
|
+
add_step_with_context(Procedures::Pulp::Remove)
|
109
|
+
end
|
110
|
+
end
|
81
111
|
end
|
82
112
|
end
|
@@ -27,6 +27,18 @@ module ForemanMaintain
|
|
27
27
|
run_scenarios_and_exit(Scenarios::Content::MigrationStats.new)
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
subcommand 'migration-reset', 'Reset the Pulp 2 to Pulp 3 migration data (pre-switchover)' do
|
32
|
+
def execute
|
33
|
+
run_scenarios_and_exit(Scenarios::Content::MigrationReset.new)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
subcommand 'remove-pulp2', 'Remove pulp2 and mongodb packages and data' do
|
38
|
+
def execute
|
39
|
+
run_scenarios_and_exit(Scenarios::Content::RemovePulp2.new)
|
40
|
+
end
|
41
|
+
end
|
30
42
|
end
|
31
43
|
end
|
32
44
|
end
|
@@ -119,6 +119,7 @@ module ForemanMaintain
|
|
119
119
|
SQL
|
120
120
|
result = query(sql)
|
121
121
|
return false if result.nil? || (result && result.empty?)
|
122
|
+
|
122
123
|
result.first['exists'].eql?('t')
|
123
124
|
end
|
124
125
|
|
@@ -161,6 +162,16 @@ module ForemanMaintain
|
|
161
162
|
end
|
162
163
|
end
|
163
164
|
|
165
|
+
def psql_cmd_available?
|
166
|
+
exit_status, _output = execute_with_status('which psql')
|
167
|
+
exit_status == 0
|
168
|
+
end
|
169
|
+
|
170
|
+
def raise_psql_missing_error
|
171
|
+
raise Error::Fail, 'The psql command not found.'\
|
172
|
+
' Make sure system has psql utility installed.'
|
173
|
+
end
|
174
|
+
|
164
175
|
private
|
165
176
|
|
166
177
|
def base_command(config, command = 'psql')
|
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.7.
|
4
|
+
version: 0.7.6
|
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: 2021-02
|
11
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -222,6 +222,7 @@ files:
|
|
222
222
|
- definitions/procedures/backup/snapshot/mount_pulpcore_db.rb
|
223
223
|
- definitions/procedures/backup/snapshot/prepare_mount.rb
|
224
224
|
- definitions/procedures/candlepin/delete_orphaned_records_from_env_content.rb
|
225
|
+
- definitions/procedures/content/migration_reset.rb
|
225
226
|
- definitions/procedures/content/migration_stats.rb
|
226
227
|
- definitions/procedures/content/prepare.rb
|
227
228
|
- definitions/procedures/content/prepare_abort.rb
|
@@ -259,6 +260,7 @@ files:
|
|
259
260
|
- definitions/procedures/passenger_recycler.rb
|
260
261
|
- definitions/procedures/prep_6_10_upgrade.rb
|
261
262
|
- definitions/procedures/pulp/migrate.rb
|
263
|
+
- definitions/procedures/pulp/remove.rb
|
262
264
|
- definitions/procedures/pulpcore/migrate.rb
|
263
265
|
- definitions/procedures/puppet/delete_empty_ca_cert_request_files.rb
|
264
266
|
- definitions/procedures/remote_execution/remove_existing_settingsd.rb
|