foreman_maintain 0.6.15 → 0.7.5
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/disk/available_space_candlepin.rb +27 -0
- data/definitions/checks/foreman_tasks/not_paused.rb +10 -13
- data/definitions/checks/package_manager/yum/validate_yum_config.rb +51 -0
- data/definitions/features/candlepin.rb +4 -0
- data/definitions/features/foreman_cockpit.rb +15 -0
- data/definitions/features/foreman_tasks.rb +12 -2
- data/definitions/features/pulpcore.rb +20 -5
- data/definitions/procedures/backup/accessibility_confirmation.rb +1 -1
- data/definitions/procedures/backup/online/safety_confirmation.rb +11 -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/foreman_tasks/delete.rb +3 -4
- data/definitions/procedures/foreman_tasks/resume.rb +5 -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 +29 -0
- data/definitions/procedures/restore/confirmation.rb +1 -1
- data/definitions/procedures/restore/installer_reset.rb +10 -1
- data/definitions/scenarios/backup.rb +2 -0
- data/definitions/scenarios/content.rb +52 -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_9.rb +90 -0
- data/definitions/scenarios/upgrade_to_satellite_6_9_z.rb +89 -0
- data/lib/foreman_maintain.rb +1 -1
- data/lib/foreman_maintain/cli.rb +8 -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 +24 -11
- data/lib/foreman_maintain/runner.rb +13 -8
- data/lib/foreman_maintain/scenario.rb +4 -0
- data/lib/foreman_maintain/utils/backup.rb +1 -1
- data/lib/foreman_maintain/utils/disk/io_device.rb +4 -0
- data/lib/foreman_maintain/utils/service/systemd.rb +11 -1
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +14 -4
- data/definitions/checks/yum_exclude.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01f23ac8f61f67d6c71e3a31156f0267e724b62386f951e02ed4272276be5007
|
4
|
+
data.tar.gz: b4cc1198b259cbb1b074a2622caac177e7d93571cb3cb2f3d2d3630adaab205f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21bfdc38c8d3a3a710aedb2e114bb0616e854b1144af15ede8ce0b326938662620e32117947f13c6eacff88b3ed5bc2076d403bb147310722c0110b71828d297
|
7
|
+
data.tar.gz: a232dd4b4ac70ad534fe4310a55382c89cfaf65b61a8afd3f850961c0ce84012810f91e577394c14d2fcaa2df2bc127b2d494312b3c8f31b3458031ef438add7
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Foreman
|
1
|
+
# Foreman Maintain [](https://github.com/theforeman/foreman_maintain/workflows/Ruby%20Tests/badge.svg?event=pull_request) <a href="https://codeclimate.com/github/theforeman/foreman_maintain"><img src="https://codeclimate.com/github/theforeman/foreman_maintain/badges/gpa.svg" /></a>
|
2
2
|
|
3
3
|
The `foreman_maintain` aims to provide various features that helps keep the
|
4
4
|
Foreman/Satellite up and running. It supports multiple versions and subparts
|
@@ -52,7 +52,7 @@ Subcommands:
|
|
52
52
|
is-enabled Get maintenance-mode status code
|
53
53
|
|
54
54
|
content Content related commands
|
55
|
-
prepare Prepare content for Pulp 3
|
55
|
+
prepare Prepare content for Pulp 3
|
56
56
|
switchover Switch support for certain content from Pulp 2 to Pulp 3
|
57
57
|
```
|
58
58
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Checks
|
2
|
+
module Disk
|
3
|
+
class AvailableSpaceCandlepin < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
label :available_space_cp
|
6
|
+
description 'Check to make sure /var/lib/candlepin has enough space'
|
7
|
+
tags :pre_upgrade
|
8
|
+
confine do
|
9
|
+
feature(:candlepin) && check_min_version('candlepin', '3.1')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
MAX_USAGE_IN_PERCENT = 90
|
14
|
+
|
15
|
+
def run
|
16
|
+
assert(enough_space?, "System has more than #{MAX_USAGE_IN_PERCENT}% space used"\
|
17
|
+
" on #{feature(:candlepin).work_dir}.\n"\
|
18
|
+
'See https://bugzilla.redhat.com/show_bug.cgi?id=1898605')
|
19
|
+
end
|
20
|
+
|
21
|
+
def enough_space?
|
22
|
+
io_obj = ForemanMaintain::Utils::Disk::IODevice.new(feature(:candlepin).work_dir)
|
23
|
+
io_obj.space_used_in_percent < MAX_USAGE_IN_PERCENT
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -9,23 +9,20 @@ module Checks::ForemanTasks
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run
|
12
|
-
paused_tasks_count = feature(:foreman_tasks).paused_tasks_count(
|
12
|
+
paused_tasks_count = feature(:foreman_tasks).paused_tasks_count()
|
13
13
|
assert(paused_tasks_count == 0,
|
14
14
|
"There are currently #{paused_tasks_count} paused tasks in the system",
|
15
|
-
:next_steps =>
|
16
|
-
[Procedures::ForemanTasks::Resume.new,
|
17
|
-
Procedures::ForemanTasks::UiInvestigate.new('search_query' => scoped_search_query)])
|
15
|
+
:next_steps => next_procedures)
|
18
16
|
end
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
Actions::Katello::EventQueue::Monitor]
|
18
|
+
def next_procedures
|
19
|
+
if assumeyes?
|
20
|
+
return [Procedures::ForemanTasks::Resume.new,
|
21
|
+
Procedures::ForemanTasks::Delete.new(:state => :paused)]
|
22
|
+
end
|
23
|
+
[Procedures::ForemanTasks::Resume.new,
|
24
|
+
Procedures::ForemanTasks::Delete.new(:state => :paused),
|
25
|
+
Procedures::ForemanTasks::UiInvestigate.new('search_query' => 'state = paused')]
|
29
26
|
end
|
30
27
|
end
|
31
28
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Checks::PackageManager
|
2
|
+
module Yum
|
3
|
+
class ValidateYumConfig < ForemanMaintain::Check
|
4
|
+
metadata do
|
5
|
+
label :validate_yum_config
|
6
|
+
description 'Check to validate yum configuration before upgrade'
|
7
|
+
tags :pre_upgrade
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
final_result = verify_config_options
|
12
|
+
assert(
|
13
|
+
final_result[:matched_keys].empty?,
|
14
|
+
failure_message(final_result)
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def failure_message(final_result)
|
21
|
+
verb_string = final_result[:matched_keys].length > 1 ? 'are' : 'is'
|
22
|
+
|
23
|
+
"#{final_result[:matched_keys].join(',')} #{verb_string} set in /etc/yum.conf as below:"\
|
24
|
+
"\n#{final_result[:grep_output]}"\
|
25
|
+
"\nUnset this configuration as it is risky while yum update or upgrade!"
|
26
|
+
end
|
27
|
+
|
28
|
+
def verify_config_options
|
29
|
+
result = {}
|
30
|
+
combined_regex = yum_config_options.values.join('|')
|
31
|
+
result[:grep_output] = execute_grep_cmd(combined_regex)
|
32
|
+
result[:matched_keys] = yum_config_options.keys.select do |key|
|
33
|
+
result[:grep_output].include?(key)
|
34
|
+
end
|
35
|
+
result
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute_grep_cmd(regex_string)
|
39
|
+
execute_with_status("grep -iE '#{regex_string}' /etc/yum.conf")[1]
|
40
|
+
end
|
41
|
+
|
42
|
+
def yum_config_options
|
43
|
+
@yum_config_options ||= {
|
44
|
+
'exclude' => '^exclude\s*=\s*\S+.*$',
|
45
|
+
'clean_requirements_on_remove' =>
|
46
|
+
'^clean_requirements_on_remove\s*=\S*(1|yes|true)$'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Features::ForemanCockpit < ForemanMaintain::Feature
|
2
|
+
metadata do
|
3
|
+
label :foreman_cockpit
|
4
|
+
|
5
|
+
confine do
|
6
|
+
server? && find_package('tfm-rubygem-foreman_remote_execution-cockpit')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def services
|
11
|
+
[
|
12
|
+
system_service('foreman-cockpit')
|
13
|
+
]
|
14
|
+
end
|
15
|
+
end
|
@@ -89,13 +89,19 @@ class Features::ForemanTasks < ForemanMaintain::Feature
|
|
89
89
|
|
90
90
|
if state == :old
|
91
91
|
old_tasks_condition
|
92
|
+
elsif state == :paused
|
93
|
+
paused_tasks_condition
|
92
94
|
else
|
93
95
|
tasks_condition(state)
|
94
96
|
end
|
95
97
|
end
|
96
98
|
|
97
99
|
def resume_task_using_hammer
|
98
|
-
|
100
|
+
if check_min_version('satellite', '6.8')
|
101
|
+
feature(:hammer).run('task resume --search ""')
|
102
|
+
else
|
103
|
+
feature(:hammer).run('task resume')
|
104
|
+
end
|
99
105
|
end
|
100
106
|
|
101
107
|
def fetch_tasks_status(state, spinner)
|
@@ -176,6 +182,10 @@ class Features::ForemanTasks < ForemanMaintain::Feature
|
|
176
182
|
"foreman_tasks_tasks.started_at < CURRENT_DATE - INTERVAL '#{MIN_AGE} days'"
|
177
183
|
end
|
178
184
|
|
185
|
+
def paused_tasks_condition(state = "'paused'")
|
186
|
+
"foreman_tasks_tasks.state IN (#{state})"
|
187
|
+
end
|
188
|
+
|
179
189
|
def prepare_for_backup(state)
|
180
190
|
dir = backup_dir(state)
|
181
191
|
execute("mkdir -p #{dir}")
|
@@ -193,6 +203,6 @@ class Features::ForemanTasks < ForemanMaintain::Feature
|
|
193
203
|
end
|
194
204
|
|
195
205
|
def valid(state)
|
196
|
-
%w[old planning pending].include?(state.to_s)
|
206
|
+
%w[old planning pending paused].include?(state.to_s)
|
197
207
|
end
|
198
208
|
end
|
@@ -5,24 +5,39 @@ class Features::Pulpcore < ForemanMaintain::Feature
|
|
5
5
|
label :pulpcore
|
6
6
|
|
7
7
|
confine do
|
8
|
-
ForemanMaintain::Utils::Service::Systemd.new('pulpcore-api', 0).exist?
|
8
|
+
ForemanMaintain::Utils::Service::Systemd.new('pulpcore-api', 0).exist? &&
|
9
|
+
ForemanMaintain::Utils::Service::Systemd.new('pulpcore-api', 0).enabled?
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
13
|
def services
|
13
|
-
[
|
14
|
+
self.class.pulpcore_common_services + [
|
14
15
|
system_service('rh-redis5-redis', 5),
|
15
|
-
system_service('pulpcore-api', 10),
|
16
|
-
system_service('pulpcore-content', 10),
|
17
|
-
system_service('pulpcore-resource-manager', 10),
|
18
16
|
system_service('pulpcore-worker@*', 20, :all => true, :skip_enablement => true),
|
19
17
|
system_service('httpd', 30)
|
20
18
|
]
|
21
19
|
end
|
22
20
|
|
21
|
+
def self.pulpcore_migration_services
|
22
|
+
pulpcore_common_services + [
|
23
|
+
ForemanMaintain::Utils.system_service('pulpcore-worker@1', 20),
|
24
|
+
ForemanMaintain::Utils.system_service('pulpcore-worker@2', 20),
|
25
|
+
ForemanMaintain::Utils.system_service('pulpcore-worker@3', 20),
|
26
|
+
ForemanMaintain::Utils.system_service('pulpcore-worker@4', 20)
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
23
30
|
def config_files
|
24
31
|
[
|
25
32
|
'/etc/pulp/settings.py'
|
26
33
|
]
|
27
34
|
end
|
35
|
+
|
36
|
+
def self.pulpcore_common_services
|
37
|
+
[
|
38
|
+
ForemanMaintain::Utils.system_service('pulpcore-api', 10, :socket => 'pulpcore-api'),
|
39
|
+
ForemanMaintain::Utils.system_service('pulpcore-content', 10, :socket => 'pulpcore-content'),
|
40
|
+
ForemanMaintain::Utils.system_service('pulpcore-resource-manager', 10)
|
41
|
+
]
|
42
|
+
end
|
28
43
|
end
|
@@ -7,7 +7,7 @@ module Procedures::Backup
|
|
7
7
|
|
8
8
|
def run
|
9
9
|
answer = ask_decision("WARNING: This script will stop your services.\n\n" \
|
10
|
-
'Do you want to proceed?', 'y(yes), q(quit)')
|
10
|
+
'Do you want to proceed?', actions_msg: 'y(yes), q(quit)')
|
11
11
|
abort! unless answer == :yes
|
12
12
|
end
|
13
13
|
end
|
@@ -4,21 +4,26 @@ module Procedures::Backup
|
|
4
4
|
metadata do
|
5
5
|
description 'Data consistency warning'
|
6
6
|
tags :backup
|
7
|
+
param :include_db_dumps, 'Are database dumps included in backup', :flag => true,
|
8
|
+
:default => false
|
7
9
|
end
|
8
10
|
|
9
11
|
def run
|
10
|
-
answer = ask_decision(
|
11
|
-
|
12
|
+
answer = ask_decision(warning_message(@include_db_dumps), actions_msg: 'y(yes), q(quit)')
|
13
|
+
abort! unless answer == :yes
|
14
|
+
end
|
15
|
+
|
16
|
+
def warning_message(include_db_dumps)
|
17
|
+
substr = include_db_dumps ? 'database dump' : 'online backup'
|
18
|
+
"*** WARNING: The #{substr} is intended for making a copy of the data\n" \
|
12
19
|
'*** for debugging purposes only.' \
|
13
20
|
" The backup routine can not ensure 100% consistency while the\n" \
|
14
21
|
"*** backup is taking place as there is a chance there may be data mismatch between\n" \
|
15
22
|
'*** Mongo and Postgres databases while the services are live.' \
|
16
|
-
" If you wish to utilize the
|
23
|
+
" If you wish to utilize the #{substr}\n" \
|
17
24
|
'*** for production use you need to ensure that there are' \
|
18
25
|
" no modifications occurring during\n" \
|
19
|
-
"*** your backup run.\n\nDo you want to proceed?"
|
20
|
-
)
|
21
|
-
abort! unless answer == :yes
|
26
|
+
"*** your backup run.\n\nDo you want to proceed?"
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
@@ -40,7 +40,7 @@ module Procedures::Backup
|
|
40
40
|
'*** If you would like to continue, the snapshot size will be required to be at least' \
|
41
41
|
" the size of the actual #{shared_lv.join(', ')} database.\n" \
|
42
42
|
"*** You can skip this confirmation with the '-y' flag.\n\n" \
|
43
|
-
'Do you want to proceed?', 'y(yes), q(quit)')
|
43
|
+
'Do you want to proceed?', actions_msg: 'y(yes), q(quit)')
|
44
44
|
abort! unless answer == :yes
|
45
45
|
end
|
46
46
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Procedures::Content
|
2
|
+
class MigrationStats < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Retrieve Pulp 2 to Pulp 3 migration statistics'
|
5
|
+
for_feature :pulpcore
|
6
|
+
end
|
7
|
+
|
8
|
+
def run
|
9
|
+
puts execute!('foreman-rake katello:pulp3_migration_stats')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -3,15 +3,11 @@ module Procedures::Content
|
|
3
3
|
metadata do
|
4
4
|
description 'Prepare content for Pulp 3'
|
5
5
|
for_feature :pulpcore
|
6
|
-
|
7
|
-
confine do
|
8
|
-
# FIXME: remove this condition on next downstream upgrade scenario
|
9
|
-
!feature(:instance).downstream
|
10
|
-
end
|
11
6
|
end
|
12
7
|
|
13
8
|
def run
|
14
|
-
|
9
|
+
# use interactive to get realtime output
|
10
|
+
puts execute!('foreman-rake katello:pulp3_migration', :interactive => true)
|
15
11
|
end
|
16
12
|
end
|
17
13
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Procedures::Content
|
2
|
+
class PrepareAbort < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Abort all running Pulp 2 to Pulp 3 migration tasks'
|
5
|
+
for_feature :pulpcore
|
6
|
+
end
|
7
|
+
|
8
|
+
def run
|
9
|
+
puts execute!('foreman-rake katello:pulp3_migration_abort')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Procedures::ForemanTasks
|
2
2
|
class Delete < ForemanMaintain::Procedure
|
3
|
-
ALLOWED_STATES_VALUES = %w[old planning pending].freeze
|
3
|
+
ALLOWED_STATES_VALUES = %w[old planning pending paused].freeze
|
4
4
|
|
5
5
|
metadata do
|
6
6
|
param :state,
|
@@ -19,12 +19,11 @@ module Procedures::ForemanTasks
|
|
19
19
|
feature(:foreman_tasks).backup_tasks(@state) do |backup_progress|
|
20
20
|
spinner.update backup_progress
|
21
21
|
end
|
22
|
-
|
23
|
-
spinner.update "Deleting #{@state} tasks [running]"
|
22
|
+
spinner.update "Deleting #{count_tasks_before} #{@state} tasks [running]"
|
24
23
|
count_tasks_later = feature(:foreman_tasks).delete(@state)
|
25
24
|
spinner.update "Deleting #{@state} tasks [DONE]"
|
26
25
|
spinner.update(
|
27
|
-
"Deleted #{@state}
|
26
|
+
"Deleted #{@state} tasks: #{count_tasks_before - count_tasks_later}"
|
28
27
|
)
|
29
28
|
end
|
30
29
|
end
|
@@ -6,8 +6,13 @@ module Procedures::ForemanTasks
|
|
6
6
|
description 'Resume paused tasks'
|
7
7
|
end
|
8
8
|
|
9
|
+
WAIT_TIME = 30
|
10
|
+
|
9
11
|
def run
|
10
12
|
output << feature(:foreman_tasks).resume_task_using_hammer
|
13
|
+
with_spinner('Waiting 30 seconds for resumed tasks to start.') do
|
14
|
+
sleep WAIT_TIME
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
@@ -11,7 +11,7 @@ module Procedures::Packages
|
|
11
11
|
"is in a consistent state.\n" \
|
12
12
|
"As a result some of your services may be restarted. \n\n" \
|
13
13
|
'Do you want to proceed?'
|
14
|
-
answer = ask_decision(question, 'y(yes), q(quit)')
|
14
|
+
answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
|
15
15
|
abort! unless answer == :yes
|
16
16
|
end
|
17
17
|
end
|
@@ -16,7 +16,7 @@ module Procedures::Packages
|
|
16
16
|
"NOTE: --assumeyes is not applicable for this check\n\n" \
|
17
17
|
"Do you want to proceed with update of everything regardless\n" \
|
18
18
|
'of the recommendations?'
|
19
|
-
answer = ask_decision(question, 'y(yes), q(quit)', ignore_assumeyes: true)
|
19
|
+
answer = ask_decision(question, actions_msg: 'y(yes), q(quit)', ignore_assumeyes: true)
|
20
20
|
abort! unless answer == :yes
|
21
21
|
end
|
22
22
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Procedures::Prep610Upgrade < ForemanMaintain::Procedure
|
2
|
+
metadata do
|
3
|
+
description 'Preparations for the Satellite 6.10 upgrade'
|
4
|
+
|
5
|
+
confine do
|
6
|
+
feature(:satellite) &&
|
7
|
+
feature(:satellite).current_minor_version == '6.9'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
puts time_warning
|
13
|
+
with_spinner('Updating filesystem permissions for Pulp 3') do |spinner|
|
14
|
+
spinner.update('$ chmod -R g+rwX /var/lib/pulp/content')
|
15
|
+
FileUtils.chmod_R 'g=rwX', '/var/lib/pulp/content'
|
16
|
+
spinner.update("$ find /var/lib/pulp/content -type d -perm -g-s -exec chmod g+s {} \;")
|
17
|
+
execute!('find /var/lib/pulp/content -type d -perm -g-s -exec chmod g+s {} \;')
|
18
|
+
spinner.update('$ chown -R :pulp /var/lib/pulp/content')
|
19
|
+
FileUtils.chown_R nil, 'pulp', '/var/lib/pulp/content'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def time_warning
|
26
|
+
"\e[33mprep-6.10-upgrade may take a while depending on the "\
|
27
|
+
"size of /var/lib/pulp/content\e[0m"
|
28
|
+
end
|
29
|
+
end
|