foreman_maintain 0.6.16 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/definitions/checks/package_manager/yum/validate_yum_config.rb +51 -0
- data/definitions/features/candlepin.rb +0 -4
- data/definitions/features/dynflow_sidekiq.rb +4 -7
- data/definitions/features/pulpcore.rb +23 -6
- data/definitions/procedures/backup/accessibility_confirmation.rb +1 -1
- data/definitions/procedures/backup/online/safety_confirmation.rb +1 -1
- 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 +0 -5
- data/definitions/procedures/content/prepare_abort.rb +12 -0
- data/definitions/procedures/content/switchover.rb +1 -1
- 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/procedures/service/list.rb +2 -12
- 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_9.rb +90 -0
- data/definitions/scenarios/upgrade_to_satellite_6_9_z.rb +89 -0
- data/lib/foreman_maintain.rb +1 -3
- data/lib/foreman_maintain/cli.rb +9 -0
- data/lib/foreman_maintain/cli/content_command.rb +17 -2
- data/lib/foreman_maintain/cli/upgrade_command.rb +0 -3
- data/lib/foreman_maintain/concerns/downstream.rb +4 -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/disk/io_device.rb +0 -4
- data/lib/foreman_maintain/utils/service/systemd.rb +12 -3
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +11 -5
- data/definitions/checks/disk/available_space_candlepin.rb +0 -27
- data/definitions/checks/yum_exclude.rb +0 -21
- data/lib/foreman_maintain/concerns/primary_checks.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4151b9d6dbc810f7f85aa093bdcfc4f967530dbeddcf7e13e88ce998125211dc
|
4
|
+
data.tar.gz: e7db5a3881d9652bae19c61f95ff95076745f36212c6e36f4cf582d4b5f33c8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56165e03d708aa74d5b370cd7f2ca96a0121b2b97d14f326372181ef2c464eb9856dbafd1f60ad99aea89c9a610a1579a334a4a69c12abee38b70d2eb84a899a
|
7
|
+
data.tar.gz: e43c42dbbe5aab6752e16429dae6fd70367510be2df57f026aa5ad53bb1efb9ef9e4eb2efc4331aef3823b93729412b789bc8c3e8396e03b4563bc82cf42199b
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Foreman
|
1
|
+
# Foreman Maintain [![Build Status](https://github.com/theforeman/foreman_maintain/workflows/Ruby%20Tests/badge.svg?event=pull_request)](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,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
|
@@ -7,6 +7,10 @@ class Features::DynflowSidekiq < ForemanMaintain::Feature
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
def services
|
11
|
+
service_names.map { |service| system_service service, instance_priority(service) }
|
12
|
+
end
|
13
|
+
|
10
14
|
def config_files
|
11
15
|
# Workaround until foreman-installer can deploy scaled workers
|
12
16
|
service_symlinks = configured_instances.map do |service|
|
@@ -18,13 +22,6 @@ class Features::DynflowSidekiq < ForemanMaintain::Feature
|
|
18
22
|
].flatten
|
19
23
|
end
|
20
24
|
|
21
|
-
def services
|
22
|
-
service_names.map do |service|
|
23
|
-
system_service service, instance_priority(service),
|
24
|
-
:instance_parent_unit => 'dynflow-sidekiq@'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
25
|
private
|
29
26
|
|
30
27
|
def instance_priority(instance)
|
@@ -5,24 +5,41 @@ 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
|
-
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),
|
14
|
+
pulpcore_common_services + [
|
18
15
|
system_service('pulpcore-worker@*', 20, :all => true, :skip_enablement => true),
|
19
16
|
system_service('httpd', 30)
|
20
17
|
]
|
21
18
|
end
|
22
19
|
|
20
|
+
def pulpcore_migration_services
|
21
|
+
pulpcore_common_services + [
|
22
|
+
system_service('pulpcore-worker@1', 20),
|
23
|
+
system_service('pulpcore-worker@2', 20),
|
24
|
+
system_service('pulpcore-worker@3', 20),
|
25
|
+
system_service('pulpcore-worker@4', 20)
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
23
29
|
def config_files
|
24
30
|
[
|
25
31
|
'/etc/pulp/settings.py'
|
26
32
|
]
|
27
33
|
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def pulpcore_common_services
|
38
|
+
[
|
39
|
+
system_service('rh-redis5-redis', 5),
|
40
|
+
system_service('pulpcore-api', 10, :socket => 'pulpcore-api'),
|
41
|
+
system_service('pulpcore-content', 10, :socket => 'pulpcore-content'),
|
42
|
+
system_service('pulpcore-resource-manager', 10)
|
43
|
+
]
|
44
|
+
end
|
28
45
|
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
|
@@ -16,7 +16,7 @@ module Procedures::Backup
|
|
16
16
|
" If you wish to utilize the online backup\n" \
|
17
17
|
'*** for production use you need to ensure that there are' \
|
18
18
|
" no modifications occurring during\n" \
|
19
|
-
"*** your backup run.\n\nDo you want to proceed?", 'y(yes), q(quit)'
|
19
|
+
"*** your backup run.\n\nDo you want to proceed?", actions_msg: 'y(yes), q(quit)'
|
20
20
|
)
|
21
21
|
abort! unless answer == :yes
|
22
22
|
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
|
@@ -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
|
@@ -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,31 @@
|
|
1
|
+
class Procedures::Prep610Upgrade < ForemanMaintain::Procedure
|
2
|
+
metadata do
|
3
|
+
description 'Preparations for the Satellite 6.10 upgrade'
|
4
|
+
|
5
|
+
confine do
|
6
|
+
::Scenarios.const_defined?('Satellite_6_10') &&
|
7
|
+
feature(:satellite) &&
|
8
|
+
feature(:satellite).current_minor_version == '6.9'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
puts time_warning
|
14
|
+
with_spinner('Updating filesystem permissions for Pulp 3') do |spinner|
|
15
|
+
spinner.update('$ chmod -R g+rwX /var/lib/pulp/content')
|
16
|
+
FileUtils.chmod_R 'g=rwX', '/var/lib/pulp/content'
|
17
|
+
spinner.update("$ find /var/lib/pulp/content -type d -perm -g-s -exec chmod g+s {} \;")
|
18
|
+
execute!('find /var/lib/pulp/content -type d -perm -g-s -exec chmod g+s {} \;')
|
19
|
+
spinner.update('$ chown -R :pulp /var/lib/pulp/content')
|
20
|
+
FileUtils.chown_R nil, 'pulp', '/var/lib/pulp/content'
|
21
|
+
# TODO: Install Pulp 3 without starting services?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def time_warning
|
28
|
+
"\e[33mprep-6.10-upgrade may take a while depending on the "\
|
29
|
+
"size of /var/lib/pulp/content\e[0m"
|
30
|
+
end
|
31
|
+
end
|
@@ -10,7 +10,7 @@ module Procedures::Restore
|
|
10
10
|
"Your existing installation will be replaced with the backup database.\n" \
|
11
11
|
"Once this operation is complete there is no going back.\n" \
|
12
12
|
'Do you want to proceed?'
|
13
|
-
answer = ask_decision(warning, 'y(yes), q(quit)')
|
13
|
+
answer = ask_decision(warning, actions_msg: 'y(yes), q(quit)')
|
14
14
|
abort! unless answer == :yes
|
15
15
|
end
|
16
16
|
end
|
@@ -12,7 +12,7 @@ module Procedures::Restore
|
|
12
12
|
|
13
13
|
def installer_cmd
|
14
14
|
installer = "yes | #{feature(:installer).installer_command} "
|
15
|
-
installer <<
|
15
|
+
installer << reset_option
|
16
16
|
if feature(:instance).foreman_proxy_with_content?
|
17
17
|
installer << '--foreman-proxy-register-in-foreman false '
|
18
18
|
end
|
@@ -27,5 +27,14 @@ module Procedures::Restore
|
|
27
27
|
end
|
28
28
|
installer
|
29
29
|
end
|
30
|
+
|
31
|
+
def reset_option
|
32
|
+
if check_min_version('foreman', '2.2') || \
|
33
|
+
check_min_version('foreman-proxy', '2.2')
|
34
|
+
return '-v --reset-data '
|
35
|
+
end
|
36
|
+
|
37
|
+
'-v --reset '
|
38
|
+
end
|
30
39
|
end
|
31
40
|
end
|
@@ -16,22 +16,12 @@ module Procedures::Service
|
|
16
16
|
|
17
17
|
def unit_files_list(services)
|
18
18
|
if systemd_installed?
|
19
|
-
|
20
|
-
|
19
|
+
regex = services.map { |service| "^#{service.name}.service" }.join('\|')
|
20
|
+
execute("systemctl list-unit-files | grep '#{regex}'")
|
21
21
|
else
|
22
22
|
regex = services.map { |service| "^#{service.name} " }.join('\|')
|
23
23
|
execute("chkconfig --list 2>&1 | grep '#{regex}'")
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
def build_regex_for_services(services)
|
28
|
-
services.map do |service|
|
29
|
-
if service.respond_to?(:instance_parent_unit) && service.instance_parent_unit
|
30
|
-
"^#{service.instance_parent_unit}.service"
|
31
|
-
else
|
32
|
-
"^#{service.name}.service"
|
33
|
-
end
|
34
|
-
end.join('\|')
|
35
|
-
end
|
36
26
|
end
|
37
27
|
end
|
@@ -8,11 +8,29 @@ module ForemanMaintain::Scenarios
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def compose
|
11
|
-
|
12
|
-
|
11
|
+
if feature(:satellite) && feature(:satellite).at_least_version?('6.9')
|
12
|
+
enable_and_start_services
|
13
13
|
add_step(Procedures::Content::Prepare)
|
14
|
+
disable_and_stop_services
|
14
15
|
end
|
15
16
|
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def enable_and_start_services
|
21
|
+
add_step(Procedures::Service::Start)
|
22
|
+
add_step(Procedures::Service::Enable.
|
23
|
+
new(:only => feature(:pulpcore).pulpcore_migration_services))
|
24
|
+
add_step(Procedures::Service::Start.
|
25
|
+
new(:only => feature(:pulpcore).pulpcore_migration_services))
|
26
|
+
end
|
27
|
+
|
28
|
+
def disable_and_stop_services
|
29
|
+
add_step(Procedures::Service::Stop.
|
30
|
+
new(:only => feature(:pulpcore).pulpcore_migration_services))
|
31
|
+
add_step(Procedures::Service::Disable.
|
32
|
+
new(:only => feature(:pulpcore).pulpcore_migration_services))
|
33
|
+
end
|
16
34
|
end
|
17
35
|
|
18
36
|
class Switchover < ForemanMaintain::Scenario
|
@@ -23,9 +41,38 @@ module ForemanMaintain::Scenarios
|
|
23
41
|
end
|
24
42
|
|
25
43
|
def compose
|
26
|
-
# FIXME: remove this condition
|
44
|
+
# FIXME: remove this condition for the 6.10 upgrade scenario
|
27
45
|
if Procedures::Content::Switchover.present?
|
28
46
|
add_step(Procedures::Content::Switchover)
|
47
|
+
add_step(Procedures::Foreman::ApipieCache)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class PrepareAbort < ForemanMaintain::Scenario
|
53
|
+
metadata do
|
54
|
+
label :content_prepare_abort
|
55
|
+
description 'Abort all running Pulp 2 to Pulp 3 migration tasks'
|
56
|
+
manual_detection
|
57
|
+
end
|
58
|
+
|
59
|
+
def compose
|
60
|
+
if feature(:satellite) && feature(:satellite).at_least_version?('6.9')
|
61
|
+
add_step(Procedures::Content::PrepareAbort)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class MigrationStats < ForemanMaintain::Scenario
|
67
|
+
metadata do
|
68
|
+
label :content_migration_stats
|
69
|
+
description 'Retrieve Pulp 2 to Pulp 3 migration statistics'
|
70
|
+
manual_detection
|
71
|
+
end
|
72
|
+
|
73
|
+
def compose
|
74
|
+
if feature(:satellite) && feature(:satellite).at_least_version?('6.9')
|
75
|
+
add_step(Procedures::Content::MigrationStats)
|
29
76
|
end
|
30
77
|
end
|
31
78
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ForemanMaintain::Scenarios
|
2
|
+
class Prep610Upgrade < ForemanMaintain::Scenario
|
3
|
+
metadata do
|
4
|
+
label :prep_6_10_upgrade
|
5
|
+
description 'Preparations for the Satellite 6.10 upgrade'
|
6
|
+
manual_detection
|
7
|
+
end
|
8
|
+
|
9
|
+
def compose
|
10
|
+
add_step(Procedures::Prep610Upgrade)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|