foreman_maintain 1.4.0 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/definitions/checks/check_hotfix_installed.rb +2 -3
- data/definitions/checks/disk/performance.rb +1 -2
- data/definitions/checks/package_manager/{yum/validate_yum_config.rb → dnf/validate_dnf_config.rb} +13 -11
- data/definitions/checks/repositories/check_upstream_repository.rb +1 -2
- data/definitions/features/installer.rb +8 -66
- data/definitions/features/instance.rb +0 -6
- data/definitions/procedures/backup/metadata.rb +5 -3
- data/definitions/procedures/backup/snapshot/snapshot_deprecation_message.rb +14 -0
- data/definitions/procedures/packages/check_for_reboot.rb +16 -0
- data/definitions/procedures/packages/installer_confirmation.rb +1 -1
- data/definitions/procedures/packages/update.rb +3 -3
- data/definitions/scenarios/backup.rb +10 -8
- data/definitions/scenarios/puppet.rb +0 -3
- data/definitions/scenarios/self_upgrade.rb +4 -6
- data/definitions/scenarios/upgrade_to_capsule_6_15.rb +2 -2
- data/definitions/scenarios/upgrade_to_capsule_6_15_z.rb +2 -2
- data/definitions/scenarios/upgrade_to_katello_nightly.rb +1 -1
- data/definitions/scenarios/upgrade_to_satellite_6_15.rb +2 -2
- data/definitions/scenarios/upgrade_to_satellite_6_15_z.rb +2 -2
- data/extras/foreman_protector/foreman-protector.conf +1 -1
- data/extras/foreman_protector/foreman-protector.whitelist +16 -0
- data/lib/foreman_maintain/cli/backup_command.rb +1 -1
- data/lib/foreman_maintain/concerns/base_database.rb +0 -41
- data/lib/foreman_maintain/concerns/system_helpers.rb +2 -2
- data/lib/foreman_maintain/config.rb +5 -1
- data/lib/foreman_maintain/package_manager/dnf.rb +138 -11
- data/lib/foreman_maintain/package_manager.rb +0 -1
- data/lib/foreman_maintain/repository_manager/el.rb +2 -2
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +9 -17
- data/definitions/checks/backup/directory_ready.rb +0 -23
- data/definitions/checks/check_for_newer_packages.rb +0 -67
- data/definitions/checks/foreman/check_checkpoint_segments.rb +0 -59
- data/definitions/checks/foreman/check_duplicate_roles.rb +0 -42
- data/definitions/checks/foreman/puppet_class_duplicates.rb +0 -48
- data/definitions/checks/original_assets.rb +0 -23
- data/definitions/procedures/foreman/apipie_cache.rb +0 -12
- data/definitions/procedures/foreman_docker/remove_foreman_docker.rb +0 -16
- data/extras/foreman_protector/yum/foreman-protector.py +0 -86
- data/lib/foreman_maintain/package_manager/yum.rb +0 -142
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d37937d8bc4cbf619ea0e654e6826ae92a96ecd74f1b260e5b402df7bcbdc68
|
4
|
+
data.tar.gz: a0fcf7a0f6802f7547c26d640650ac29cafa3568f7fdbc648f31d3dbdbcf6a72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bab8216e974e96128a5f0fb88a201d1c8dd9da13d71b89efea76337c242f6459285e8af8a8dbcacbaa318f402c1b26cc7056e5e1d976946b8939f13bbaa4fda
|
7
|
+
data.tar.gz: 59772c9b2ec381408458383f4e06bafb8bb3998f5c4cea60be7a2dc2a254803896a05aa2858aad48f34e54185b7db6a455534cafa5f671b6a52a69bbe0b07e74
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Foreman Maintain [![
|
1
|
+
# Foreman Maintain [![Ruby Tests](https://github.com/theforeman/foreman_maintain/actions/workflows/ruby_tests.yml/badge.svg)](https://github.com/theforeman/foreman_maintain/actions/workflows/ruby_tests.yml) <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
|
@@ -4,8 +4,7 @@ class Checks::CheckHotfixInstalled < ForemanMaintain::Check
|
|
4
4
|
description 'Check to verify if any hotfix installed on system'
|
5
5
|
tags :pre_upgrade
|
6
6
|
preparation_steps do
|
7
|
-
[Checks::Repositories::CheckNonRhRepository.new
|
8
|
-
Procedures::Packages::Install.new(:packages => %w[yum-utils])]
|
7
|
+
[Checks::Repositories::CheckNonRhRepository.new]
|
9
8
|
end
|
10
9
|
|
11
10
|
confine do
|
@@ -45,7 +44,7 @@ class Checks::CheckHotfixInstalled < ForemanMaintain::Check
|
|
45
44
|
|
46
45
|
def installed_packages
|
47
46
|
packages = []
|
48
|
-
IO.popen(['repoquery', '-a', '--installed', '--qf', query_format]) do |io|
|
47
|
+
IO.popen(['dnf', 'repoquery', '-a', '--installed', '--qf', query_format]) do |io|
|
49
48
|
io.each do |line|
|
50
49
|
repo, pkg = line.chomp.split
|
51
50
|
next if repo.nil? || pkg.nil?
|
@@ -30,8 +30,7 @@ module Checks
|
|
30
30
|
puts "\n"
|
31
31
|
puts stats.stdout
|
32
32
|
|
33
|
-
|
34
|
-
if current_downstream_feature&.at_least_version?('6.3')
|
33
|
+
if feature(:instance).downstream
|
35
34
|
assert(success, io_obj.slow_disk_error_msg + warning_message, :warn => true)
|
36
35
|
else
|
37
36
|
assert(success, io_obj.slow_disk_error_msg)
|
data/definitions/checks/package_manager/{yum/validate_yum_config.rb → dnf/validate_dnf_config.rb}
RENAMED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Checks::PackageManager
|
2
|
-
module
|
3
|
-
class
|
2
|
+
module Dnf
|
3
|
+
class ValidateDnfConfig < ForemanMaintain::Check
|
4
4
|
metadata do
|
5
|
-
label :
|
6
|
-
description 'Check to validate
|
5
|
+
label :validate_dnf_config
|
6
|
+
description 'Check to validate dnf configuration before upgrade'
|
7
7
|
tags :pre_upgrade
|
8
8
|
end
|
9
9
|
|
@@ -17,30 +17,32 @@ module Checks::PackageManager
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
+
# rubocop:disable Metrics/LineLength
|
20
21
|
def failure_message(final_result)
|
21
22
|
verb_string = final_result[:matched_keys].length > 1 ? 'are' : 'is'
|
22
23
|
|
23
|
-
"#{final_result[:matched_keys].join(',')} #{verb_string} set in /etc/
|
24
|
+
"#{final_result[:matched_keys].join(',')} #{verb_string} set in /etc/dnf/dnf.conf as below:"\
|
24
25
|
"\n#{final_result[:grep_output]}"\
|
25
|
-
"\nUnset this configuration as it is risky while
|
26
|
+
"\nUnset this configuration as it is risky while dnf update or upgrade!"
|
26
27
|
end
|
28
|
+
# rubocop:enable Metrics/LineLength
|
27
29
|
|
28
30
|
def verify_config_options
|
29
31
|
result = {}
|
30
|
-
combined_regex =
|
32
|
+
combined_regex = dnf_config_options.values.join('|')
|
31
33
|
result[:grep_output] = execute_grep_cmd(combined_regex)
|
32
|
-
result[:matched_keys] =
|
34
|
+
result[:matched_keys] = dnf_config_options.keys.select do |key|
|
33
35
|
result[:grep_output].include?(key)
|
34
36
|
end
|
35
37
|
result
|
36
38
|
end
|
37
39
|
|
38
40
|
def execute_grep_cmd(regex_string)
|
39
|
-
execute_with_status("grep -iE '#{regex_string}' /etc/
|
41
|
+
execute_with_status("grep -iE '#{regex_string}' /etc/dnf/dnf.conf")[1]
|
40
42
|
end
|
41
43
|
|
42
|
-
def
|
43
|
-
@
|
44
|
+
def dnf_config_options
|
45
|
+
@dnf_config_options ||= {
|
44
46
|
'exclude' => '^exclude\s*=\s*\S+.*$',
|
45
47
|
}
|
46
48
|
end
|
@@ -6,8 +6,7 @@ class Checks::CheckUpstreamRepository < ForemanMaintain::Check
|
|
6
6
|
description 'Check if any upstream repositories are enabled on system'
|
7
7
|
tags :pre_upgrade
|
8
8
|
preparation_steps do
|
9
|
-
[Checks::Repositories::CheckNonRhRepository.new
|
10
|
-
Procedures::Packages::Install.new(:packages => %w[yum-utils])]
|
9
|
+
[Checks::Repositories::CheckNonRhRepository.new]
|
11
10
|
end
|
12
11
|
confine do
|
13
12
|
feature(:instance).downstream
|
@@ -3,22 +3,10 @@ class Features::Installer < ForemanMaintain::Feature
|
|
3
3
|
label :installer
|
4
4
|
|
5
5
|
confine do
|
6
|
-
find_package('foreman-installer')
|
7
|
-
find_package('katello-installer') ||
|
8
|
-
find_package('capsule-installer')
|
6
|
+
find_package('foreman-installer')
|
9
7
|
end
|
10
8
|
end
|
11
9
|
|
12
|
-
def initialize
|
13
|
-
@installer_type = if find_package('foreman-installer')
|
14
|
-
:scenarios
|
15
|
-
elsif find_package('katello-installer')
|
16
|
-
:legacy_katello
|
17
|
-
elsif find_package('capsule-installer')
|
18
|
-
:legacy_capsule
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
10
|
def answers
|
23
11
|
load_answers(configuration)
|
24
12
|
end
|
@@ -28,39 +16,17 @@ class Features::Installer < ForemanMaintain::Feature
|
|
28
16
|
end
|
29
17
|
|
30
18
|
def config_file
|
31
|
-
|
32
|
-
when :scenarios
|
33
|
-
last_scenario_config
|
34
|
-
when :legacy_katello
|
35
|
-
File.join(config_directory, 'katello-installer.yaml')
|
36
|
-
when :legacy_capsule
|
37
|
-
File.join(config_directory, 'capsule-installer.yaml')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def with_scenarios?
|
42
|
-
@installer_type == :scenarios
|
19
|
+
last_scenario_config
|
43
20
|
end
|
44
21
|
|
45
22
|
def config_directory
|
46
|
-
|
47
|
-
when :scenarios
|
48
|
-
'/etc/foreman-installer'
|
49
|
-
when :legacy_katello
|
50
|
-
'/etc/katello-installer'
|
51
|
-
when :legacy_capsule
|
52
|
-
'/etc/capsule-installer'
|
53
|
-
end
|
23
|
+
'/etc/foreman-installer'
|
54
24
|
end
|
55
25
|
|
56
26
|
def custom_hiera_file
|
57
27
|
@custom_hiera_file ||= File.join(config_directory, 'custom-hiera.yaml')
|
58
28
|
end
|
59
29
|
|
60
|
-
def can_upgrade?
|
61
|
-
@installer_type == :scenarios || @installer_type == :legacy_katello
|
62
|
-
end
|
63
|
-
|
64
30
|
def config_files
|
65
31
|
Dir.glob(File.join(config_directory, '**/*')) +
|
66
32
|
[
|
@@ -71,23 +37,14 @@ class Features::Installer < ForemanMaintain::Feature
|
|
71
37
|
end
|
72
38
|
|
73
39
|
def last_scenario
|
74
|
-
return nil unless with_scenarios?
|
75
|
-
|
76
40
|
File.basename(last_scenario_config).split('.')[0]
|
77
41
|
end
|
78
42
|
|
79
43
|
def installer_command
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
else
|
85
|
-
'foreman-installer'
|
86
|
-
end
|
87
|
-
when :legacy_katello
|
88
|
-
'katello-installer'
|
89
|
-
when :legacy_capsule
|
90
|
-
'capsule-installer'
|
44
|
+
if feature(:satellite)
|
45
|
+
'satellite-installer'
|
46
|
+
else
|
47
|
+
'foreman-installer'
|
91
48
|
end
|
92
49
|
end
|
93
50
|
|
@@ -105,22 +62,7 @@ class Features::Installer < ForemanMaintain::Feature
|
|
105
62
|
end
|
106
63
|
|
107
64
|
def upgrade(exec_options = {})
|
108
|
-
run(
|
109
|
-
end
|
110
|
-
|
111
|
-
def installer_arguments
|
112
|
-
installer_args = ''
|
113
|
-
|
114
|
-
if feature(:foreman_proxy)&.with_content? &&
|
115
|
-
check_max_version('foreman-installer', '3.4')
|
116
|
-
installer_args += ' --disable-system-checks'
|
117
|
-
end
|
118
|
-
|
119
|
-
if !check_min_version('foreman-installer', '2.1') && can_upgrade?
|
120
|
-
installer_args += ' --upgrade'
|
121
|
-
end
|
122
|
-
|
123
|
-
installer_args
|
65
|
+
run('', exec_options)
|
124
66
|
end
|
125
67
|
|
126
68
|
def initial_admin_username
|
@@ -139,12 +139,6 @@ class Features::Instance < ForemanMaintain::Feature
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def pick_failing_components(components)
|
142
|
-
if feature(:katello).current_version < Gem::Version.new('3.2.0')
|
143
|
-
# Note that katello_ping returns an empty result against foreman_auth.
|
144
|
-
# https://github.com/Katello/katello/commit/95d7b9067d38f269a5ec121fb73b5c19d4422baf
|
145
|
-
components.reject! { |n| n.eql?('foreman_auth') }
|
146
|
-
end
|
147
|
-
|
148
142
|
components.each_with_object([]) do |(name, data), failing|
|
149
143
|
failing << name unless data['status'] == 'ok'
|
150
144
|
end
|
@@ -64,9 +64,11 @@ module Procedures::Backup
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def proxy_config(spinner)
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
if feature(:installer)
|
68
|
+
spinner.update('Collecting proxy configuration')
|
69
|
+
feature(:installer).answers['foreman_proxy'].select do |key, _|
|
70
|
+
PROXY_CONFIG_ENTRIES.include?(key)
|
71
|
+
end
|
70
72
|
end
|
71
73
|
end
|
72
74
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Procedures::Backup
|
2
|
+
module Snapshot
|
3
|
+
class SnapshotDeprecationMessage < ForemanMaintain::Procedure
|
4
|
+
metadata do
|
5
|
+
description 'Snapshot backups are deprecated'
|
6
|
+
tags :backup
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
set_warn('Snapshot backups are deprecated and will be removed in a future version.')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Procedures::Packages
|
2
|
+
class CheckForReboot < ForemanMaintain::Procedure
|
3
|
+
metadata do
|
4
|
+
description 'Check if system needs reboot'
|
5
|
+
end
|
6
|
+
|
7
|
+
def run
|
8
|
+
status, output = execute_with_status('dnf needs-restarting --reboothint')
|
9
|
+
if status == 1
|
10
|
+
set_status(:warning, output)
|
11
|
+
else
|
12
|
+
set_status(:success, output)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -6,7 +6,7 @@ module Procedures::Packages
|
|
6
6
|
|
7
7
|
def run
|
8
8
|
question = "\nWARNING: This script runs #{feature(:installer).installer_command} " \
|
9
|
-
"after the
|
9
|
+
"after the dnf execution \n" \
|
10
10
|
"to ensure the #{feature(:instance).product_name} " \
|
11
11
|
"is in a consistent state.\n" \
|
12
12
|
"As a result some of your services may be restarted. \n\n" \
|
@@ -6,13 +6,13 @@ module Procedures::Packages
|
|
6
6
|
param :force, 'Do not skip if package is installed', :flag => true, :default => false
|
7
7
|
param :warn_on_errors, 'Do not interrupt scenario on failure',
|
8
8
|
:flag => true, :default => false
|
9
|
-
param :
|
9
|
+
param :dnf_options, 'Extra dnf options if any', :array => true, :default => []
|
10
10
|
end
|
11
11
|
|
12
12
|
def run
|
13
13
|
assumeyes_val = @assumeyes.nil? ? assumeyes? : @assumeyes
|
14
14
|
package_manager.clean_cache(:assumeyes => assumeyes_val)
|
15
|
-
opts = { :assumeyes => assumeyes_val, :
|
15
|
+
opts = { :assumeyes => assumeyes_val, :dnf_options => @dnf_options }
|
16
16
|
packages_action(:update, @packages, opts)
|
17
17
|
rescue ForemanMaintain::Error::ExecutionError => e
|
18
18
|
if @warn_on_errors
|
@@ -27,7 +27,7 @@ module Procedures::Packages
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def description
|
30
|
-
if @
|
30
|
+
if @dnf_options.include?('--downloadonly')
|
31
31
|
"Download package(s) #{@packages.join(', ')}"
|
32
32
|
else
|
33
33
|
"Update package(s) #{@packages.join(', ')}"
|
@@ -20,12 +20,13 @@ module ForemanMaintain::Scenarios
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def compose
|
23
|
-
|
23
|
+
check_valid_strategy
|
24
|
+
snapshot_deprecation_warning
|
24
25
|
safety_confirmation
|
25
26
|
accessibility_confirmation
|
26
27
|
prepare_directory
|
27
28
|
logical_volume_confirmation
|
28
|
-
add_step_with_context(Procedures::Backup::Metadata)
|
29
|
+
add_step_with_context(Procedures::Backup::Metadata, :online_backup => online_backup?)
|
29
30
|
|
30
31
|
case strategy
|
31
32
|
when :online
|
@@ -49,7 +50,6 @@ module ForemanMaintain::Scenarios
|
|
49
50
|
# rubocop:disable Metrics/MethodLength
|
50
51
|
def set_context_mapping
|
51
52
|
context.map(:backup_dir,
|
52
|
-
Checks::Backup::DirectoryReady => :backup_dir,
|
53
53
|
Procedures::Backup::PrepareDirectory => :backup_dir,
|
54
54
|
Procedures::Backup::Metadata => :backup_dir,
|
55
55
|
Procedures::Backup::ConfigFiles => :backup_dir,
|
@@ -66,7 +66,6 @@ module ForemanMaintain::Scenarios
|
|
66
66
|
Procedures::Backup::Snapshot::MountForemanDB => :backup_dir,
|
67
67
|
Procedures::Backup::Snapshot::MountPulpcoreDB => :backup_dir)
|
68
68
|
context.map(:preserve_dir,
|
69
|
-
Checks::Backup::DirectoryReady => :preserve_dir,
|
70
69
|
Procedures::Backup::PrepareDirectory => :preserve_dir)
|
71
70
|
context.map(:incremental_dir,
|
72
71
|
Procedures::Backup::PrepareDirectory => :incremental_dir,
|
@@ -104,8 +103,6 @@ module ForemanMaintain::Scenarios
|
|
104
103
|
|
105
104
|
def prepare_directory
|
106
105
|
add_step_with_context(Procedures::Backup::PrepareDirectory)
|
107
|
-
add_step_with_context(Checks::Backup::DirectoryReady,
|
108
|
-
:postgres_access => online_backup? || include_db_dumps?)
|
109
106
|
end
|
110
107
|
|
111
108
|
def logical_volume_confirmation
|
@@ -114,6 +111,12 @@ module ForemanMaintain::Scenarios
|
|
114
111
|
end
|
115
112
|
end
|
116
113
|
|
114
|
+
def snapshot_deprecation_warning
|
115
|
+
if strategy == :snapshot
|
116
|
+
add_step_with_context(Procedures::Backup::Snapshot::SnapshotDeprecationMessage)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
117
120
|
def accessibility_confirmation
|
118
121
|
if [:offline, :snapshot].include?(strategy)
|
119
122
|
add_step_with_context(Procedures::Backup::AccessibilityConfirmation)
|
@@ -126,7 +129,7 @@ module ForemanMaintain::Scenarios
|
|
126
129
|
end
|
127
130
|
end
|
128
131
|
|
129
|
-
def
|
132
|
+
def check_valid_strategy
|
130
133
|
unless [:online, :offline, :snapshot].include? strategy
|
131
134
|
raise ArgumentError, "Unsupported strategy '#{strategy}'"
|
132
135
|
end
|
@@ -199,7 +202,6 @@ module ForemanMaintain::Scenarios
|
|
199
202
|
Procedures::Backup::Online::ForemanDB,
|
200
203
|
Procedures::Backup::Online::PulpcoreDB
|
201
204
|
)
|
202
|
-
add_step_with_context(Procedures::Backup::Metadata, :online_backup => true)
|
203
205
|
end
|
204
206
|
|
205
207
|
def strategy
|
@@ -15,9 +15,6 @@ module ForemanMaintain::Scenarios
|
|
15
15
|
add_step(Procedures::Puppet::RemovePuppet)
|
16
16
|
add_step(Procedures::Puppet::RemovePuppetData) if context.get(:remove_data)
|
17
17
|
add_step(Procedures::Service::Restart)
|
18
|
-
if server?
|
19
|
-
add_step(Procedures::Foreman::ApipieCache)
|
20
|
-
end
|
21
18
|
end
|
22
19
|
end
|
23
20
|
end
|
@@ -67,13 +67,11 @@ module ForemanMaintain::Scenarios
|
|
67
67
|
def downstream_self_upgrade(pkgs_to_update)
|
68
68
|
ForemanMaintain.enable_maintenance_module
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
"--enablerepo=#{id}"
|
73
|
-
end
|
74
|
-
add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true,
|
75
|
-
yum_options: yum_options))
|
70
|
+
dnf_options = req_repos_to_update_pkgs.map do |id|
|
71
|
+
"--enablerepo=#{id}"
|
76
72
|
end
|
73
|
+
add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true,
|
74
|
+
dnf_options: dnf_options))
|
77
75
|
end
|
78
76
|
|
79
77
|
def upstream_self_upgrade(pkgs_to_update)
|
@@ -27,7 +27,6 @@ module Scenarios::Capsule_6_15
|
|
27
27
|
def compose
|
28
28
|
add_steps(find_checks(:default))
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
|
-
add_step(Checks::Foreman::CheckpointSegments)
|
31
30
|
add_step(Checks::Repositories::Validate.new(:version => '6.15'))
|
32
31
|
end
|
33
32
|
end
|
@@ -58,7 +57,7 @@ module Scenarios::Capsule_6_15
|
|
58
57
|
modules_to_enable = ["satellite-capsule:#{el_short_name}"]
|
59
58
|
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
60
59
|
add_step(Procedures::Packages::Update.new(:assumeyes => true,
|
61
|
-
:
|
60
|
+
:dnf_options => ['--downloadonly']))
|
62
61
|
add_step(Procedures::Service::Stop.new)
|
63
62
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
64
63
|
add_step_with_context(Procedures::Installer::Upgrade)
|
@@ -88,6 +87,7 @@ module Scenarios::Capsule_6_15
|
|
88
87
|
def compose
|
89
88
|
add_steps(find_checks(:default))
|
90
89
|
add_steps(find_checks(:post_upgrade))
|
90
|
+
add_step(Procedures::Packages::CheckForReboot)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -27,7 +27,6 @@ module Scenarios::Capsule_6_15_z
|
|
27
27
|
def compose
|
28
28
|
add_steps(find_checks(:default))
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
|
-
add_step(Checks::Foreman::CheckpointSegments)
|
31
30
|
add_step(Checks::Repositories::Validate.new(:version => '6.15'))
|
32
31
|
end
|
33
32
|
end
|
@@ -58,7 +57,7 @@ module Scenarios::Capsule_6_15_z
|
|
58
57
|
modules_to_enable = ["satellite-capsule:#{el_short_name}"]
|
59
58
|
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
60
59
|
add_step(Procedures::Packages::Update.new(:assumeyes => true,
|
61
|
-
:
|
60
|
+
:dnf_options => ['--downloadonly']))
|
62
61
|
add_step(Procedures::Service::Stop.new)
|
63
62
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
64
63
|
add_step_with_context(Procedures::Installer::Upgrade)
|
@@ -88,6 +87,7 @@ module Scenarios::Capsule_6_15_z
|
|
88
87
|
def compose
|
89
88
|
add_steps(find_checks(:default))
|
90
89
|
add_steps(find_checks(:post_upgrade))
|
90
|
+
add_step(Procedures::Packages::CheckForReboot)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -55,7 +55,7 @@ module Scenarios::Katello_Nightly
|
|
55
55
|
modules_to_enable = ["katello:#{el_short_name}", "pulpcore:#{el_short_name}"]
|
56
56
|
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
57
57
|
add_step(Procedures::Packages::Update.new(:assumeyes => true,
|
58
|
-
:
|
58
|
+
:dnf_options => ['--downloadonly']))
|
59
59
|
add_step(Procedures::Service::Stop.new)
|
60
60
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
61
61
|
add_step_with_context(Procedures::Installer::Upgrade)
|
@@ -27,7 +27,6 @@ module Scenarios::Satellite_6_15
|
|
27
27
|
def compose
|
28
28
|
add_steps(find_checks(:default))
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
|
-
add_step(Checks::Foreman::CheckpointSegments)
|
31
30
|
add_step(Checks::Repositories::Validate.new(:version => '6.15'))
|
32
31
|
end
|
33
32
|
end
|
@@ -59,7 +58,7 @@ module Scenarios::Satellite_6_15
|
|
59
58
|
modules_to_enable = ["satellite:#{el_short_name}"]
|
60
59
|
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
61
60
|
add_step(Procedures::Packages::Update.new(:assumeyes => true,
|
62
|
-
:
|
61
|
+
:dnf_options => ['--downloadonly']))
|
63
62
|
add_step(Procedures::Service::Stop.new)
|
64
63
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
65
64
|
add_step_with_context(Procedures::Installer::Upgrade)
|
@@ -90,6 +89,7 @@ module Scenarios::Satellite_6_15
|
|
90
89
|
def compose
|
91
90
|
add_steps(find_checks(:default))
|
92
91
|
add_steps(find_checks(:post_upgrade))
|
92
|
+
add_step(Procedures::Packages::CheckForReboot)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
@@ -27,7 +27,6 @@ module Scenarios::Satellite_6_15_z
|
|
27
27
|
def compose
|
28
28
|
add_steps(find_checks(:default))
|
29
29
|
add_steps(find_checks(:pre_upgrade))
|
30
|
-
add_step(Checks::Foreman::CheckpointSegments)
|
31
30
|
add_step(Checks::Repositories::Validate.new(:version => '6.15'))
|
32
31
|
end
|
33
32
|
end
|
@@ -58,7 +57,7 @@ module Scenarios::Satellite_6_15_z
|
|
58
57
|
modules_to_enable = ["satellite:#{el_short_name}"]
|
59
58
|
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
60
59
|
add_step(Procedures::Packages::Update.new(:assumeyes => true,
|
61
|
-
:
|
60
|
+
:dnf_options => ['--downloadonly']))
|
62
61
|
add_step(Procedures::Service::Stop.new)
|
63
62
|
add_step(Procedures::Packages::Update.new(:assumeyes => true))
|
64
63
|
add_step_with_context(Procedures::Installer::Upgrade)
|
@@ -89,6 +88,7 @@ module Scenarios::Satellite_6_15_z
|
|
89
88
|
def compose
|
90
89
|
add_steps(find_checks(:default))
|
91
90
|
add_steps(find_checks(:post_upgrade))
|
91
|
+
add_step(Procedures::Packages::CheckForReboot)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -39,5 +39,21 @@ python3-firewall
|
|
39
39
|
python3-nftables
|
40
40
|
python3-slip
|
41
41
|
python3-slip-dbus
|
42
|
+
# pcp
|
43
|
+
pcp
|
44
|
+
pcp-conf
|
45
|
+
pcp-libs
|
46
|
+
pcp-pmda-apache
|
47
|
+
pcp-pmda-openmetrics
|
48
|
+
pcp-pmda-postgresql
|
49
|
+
pcp-pmda-redis
|
50
|
+
pcp-system-tools
|
51
|
+
python3-pcp
|
52
|
+
grafana
|
53
|
+
grafana-pcp
|
42
54
|
# foreman-maintain
|
43
55
|
rubygem-foreman_maintain
|
56
|
+
# fapolicyd
|
57
|
+
fapolicyd
|
58
|
+
foreman-fapolicyd
|
59
|
+
foreman-proxy-fapolicyd
|
@@ -155,7 +155,7 @@ module ForemanMaintain
|
|
155
155
|
class BackupCommand < Base
|
156
156
|
subcommand 'online', 'Keep services online during backup', OnlineBackupCommand
|
157
157
|
subcommand 'offline', 'Shut down services to preserve consistent backup', OfflineBackupCommand
|
158
|
-
subcommand 'snapshot', 'Use snapshots of the databases to create backup', SnapshotBackupCommand
|
158
|
+
subcommand 'snapshot', 'Use snapshots of the databases to create backup (DEPRECATED)', SnapshotBackupCommand
|
159
159
|
end
|
160
160
|
# rubocop:enable Metrics/LineLength
|
161
161
|
end
|
@@ -75,11 +75,6 @@ module ForemanMaintain
|
|
75
75
|
:hidden_patterns => [config['password']])
|
76
76
|
end
|
77
77
|
|
78
|
-
def backup_file_path(config = configuration)
|
79
|
-
dump_file_name = "#{config['database']}_#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}.dump"
|
80
|
-
"#{backup_dir}/#{dump_file_name}.bz2"
|
81
|
-
end
|
82
|
-
|
83
78
|
def dump_db(file, config = configuration)
|
84
79
|
execute!(dump_command(config) + " > #{file}", :hidden_patterns => [config['password']])
|
85
80
|
end
|
@@ -115,47 +110,11 @@ module ForemanMaintain
|
|
115
110
|
end
|
116
111
|
end
|
117
112
|
|
118
|
-
# TODO: refactor to use dump_db
|
119
|
-
def backup_db_command(file_path, config = configuration)
|
120
|
-
pg_dump_cmd = "pg_dump -Fc #{config['database']}"
|
121
|
-
"runuser - postgres -c '#{pg_dump_cmd}' | bzip2 -9 > #{file_path}"
|
122
|
-
end
|
123
|
-
|
124
113
|
# TODO: remove the backup file path tools from here. Lib Utils::Backup?
|
125
114
|
def backup_dir
|
126
115
|
@backup_dir ||= File.expand_path(ForemanMaintain.config.db_backup_dir)
|
127
116
|
end
|
128
117
|
|
129
|
-
def perform_backup(config = configuration)
|
130
|
-
file_path = backup_file_path(config)
|
131
|
-
backup_cmd = backup_db_command(file_path, config)
|
132
|
-
execute!(backup_cmd, :hidden_patterns => [config['password']])
|
133
|
-
puts "\n Note: Database backup file path - #{file_path}"
|
134
|
-
puts "\n In case of any exception, use above dump file to restore DB."
|
135
|
-
end
|
136
|
-
|
137
|
-
def table_exist?(table_name)
|
138
|
-
sql = <<-SQL
|
139
|
-
SELECT EXISTS ( SELECT *
|
140
|
-
FROM information_schema.tables WHERE table_name = '#{table_name}' )
|
141
|
-
SQL
|
142
|
-
result = query(sql)
|
143
|
-
return false if result.nil? || (result && result.empty?)
|
144
|
-
|
145
|
-
result.first['exists'].eql?('t')
|
146
|
-
end
|
147
|
-
|
148
|
-
def delete_records_by_ids(tbl_name, rec_ids)
|
149
|
-
quotize_rec_ids = rec_ids.map { |el| "'#{el}'" }.join(',')
|
150
|
-
unless quotize_rec_ids.empty?
|
151
|
-
psql(<<-SQL)
|
152
|
-
BEGIN;
|
153
|
-
DELETE FROM #{tbl_name} WHERE id IN (#{quotize_rec_ids});
|
154
|
-
COMMIT;
|
155
|
-
SQL
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
118
|
def find_base_directory(directory)
|
160
119
|
find_dir_containing_file(directory, 'postgresql.conf')
|
161
120
|
end
|
@@ -100,13 +100,13 @@ module ForemanMaintain
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def packages_action(action, packages, options = {})
|
103
|
-
options.validate_options!(:assumeyes, :
|
103
|
+
options.validate_options!(:assumeyes, :dnf_options)
|
104
104
|
case action
|
105
105
|
when :install
|
106
106
|
package_manager.install(packages, :assumeyes => options[:assumeyes])
|
107
107
|
when :update
|
108
108
|
package_manager.update(packages, :assumeyes => options[:assumeyes],
|
109
|
-
:
|
109
|
+
:dnf_options => options[:dnf_options])
|
110
110
|
when :remove
|
111
111
|
package_manager.remove(packages, :assumeyes => options[:assumeyes])
|
112
112
|
else
|