foreman_maintain 1.4.0 → 1.4.2
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 +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
@@ -64,7 +64,11 @@ module ForemanMaintain
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def config_file_path
|
67
|
-
|
67
|
+
if defined?(CONFIG_FILE) && File.exist?(CONFIG_FILE)
|
68
|
+
CONFIG_FILE
|
69
|
+
else
|
70
|
+
File.join(source_path, 'config/foreman_maintain.yml')
|
71
|
+
end
|
68
72
|
end
|
69
73
|
|
70
74
|
def source_path
|
@@ -1,14 +1,100 @@
|
|
1
1
|
module ForemanMaintain::PackageManager
|
2
|
-
class Dnf <
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
class Dnf < Base
|
3
|
+
PROTECTOR_CONFIG_FILE = '/etc/dnf/plugins/foreman-protector.conf'.freeze
|
4
|
+
PROTECTOR_WHITELIST_FILE = '/etc/dnf/plugins/foreman-protector.whitelist'.freeze
|
5
|
+
|
6
|
+
def self.parse_envra(envra)
|
7
|
+
# envra format: 0:foreman-1.20.1.10-1.el7sat.noarch
|
8
|
+
parsed = envra.match(/\d*:?(?<name>.*)-[^-]+-[^-]+\.[^.]+/)
|
9
|
+
parsed ? Hash[parsed.names.map(&:to_sym).zip(parsed.captures)].merge(:envra => envra) : nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def lock_versions
|
13
|
+
enable_protector
|
14
|
+
end
|
15
|
+
|
16
|
+
def unlock_versions
|
17
|
+
disable_protector
|
18
|
+
end
|
19
|
+
|
20
|
+
def versions_locked?
|
21
|
+
!!(protector_config =~ /^\s*enabled\s*=\s*1/) &&
|
22
|
+
protector_whitelist_file_nonzero?
|
23
|
+
end
|
24
|
+
|
25
|
+
def protector_whitelist_file_nonzero?
|
26
|
+
File.exist?(PROTECTOR_WHITELIST_FILE) &&
|
27
|
+
!File.zero?(PROTECTOR_WHITELIST_FILE)
|
6
28
|
end
|
7
29
|
|
8
30
|
def version_locking_supported?
|
9
31
|
true
|
10
32
|
end
|
11
33
|
|
34
|
+
def installed?(packages)
|
35
|
+
packages_list = [packages].flatten(1).map { |pkg| "'#{pkg}'" }.join(' ')
|
36
|
+
sys.execute?(%(rpm -q #{packages_list}))
|
37
|
+
end
|
38
|
+
|
39
|
+
def find_installed_package(name, queryformat = '')
|
40
|
+
rpm_cmd = "rpm -q '#{name}'"
|
41
|
+
unless queryformat.empty?
|
42
|
+
rpm_cmd += " --qf '#{queryformat}'"
|
43
|
+
end
|
44
|
+
status, result = sys.execute_with_status(rpm_cmd, interactive: false)
|
45
|
+
if status == 0
|
46
|
+
result
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def install(packages, assumeyes: false)
|
51
|
+
dnf_action('install', packages, assumeyes: assumeyes)
|
52
|
+
end
|
53
|
+
|
54
|
+
def reinstall(packages, assumeyes: false)
|
55
|
+
dnf_action('reinstall', packages, assumeyes: assumeyes)
|
56
|
+
end
|
57
|
+
|
58
|
+
def remove(packages, assumeyes: false)
|
59
|
+
dnf_action('remove', packages, assumeyes: assumeyes)
|
60
|
+
end
|
61
|
+
|
62
|
+
def update(packages = [], assumeyes: false, dnf_options: [])
|
63
|
+
dnf_action('update', packages, assumeyes: assumeyes, dnf_options: dnf_options)
|
64
|
+
end
|
65
|
+
|
66
|
+
def check_update(packages: nil, with_status: false)
|
67
|
+
dnf_action(
|
68
|
+
'check-update',
|
69
|
+
packages,
|
70
|
+
assumeyes: true,
|
71
|
+
valid_exit_statuses: [0, 100],
|
72
|
+
with_status: with_status
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def update_available?(package)
|
77
|
+
cmd_output = dnf_action('check-update -q', package, with_status: true, assumeyes: false)
|
78
|
+
cmd_output[0] == 100
|
79
|
+
end
|
80
|
+
|
81
|
+
def files_not_owned_by_package(directory)
|
82
|
+
find_cmd = "find #{directory} -exec /bin/sh -c 'rpm -qf {} &> /dev/null || echo {}' \\;"
|
83
|
+
sys.execute(find_cmd).split("\n")
|
84
|
+
end
|
85
|
+
|
86
|
+
def list_installed_packages(queryformat = '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n')
|
87
|
+
# The queryformat should only include valid tag(s) as per `rpm --querytags` list.
|
88
|
+
# If any special formatting is required with querytag then it should be provided with tag i.e,
|
89
|
+
# "--%{VENDOR}"
|
90
|
+
# The queryformat string must end with '\n'
|
91
|
+
sys.execute!("rpm -qa --qf '#{queryformat}'").split("\n")
|
92
|
+
end
|
93
|
+
|
94
|
+
def clean_cache(assumeyes: false)
|
95
|
+
dnf_action('clean', 'all', :assumeyes => assumeyes)
|
96
|
+
end
|
97
|
+
|
12
98
|
def module_enabled?(name)
|
13
99
|
_status, result = info(name)
|
14
100
|
result.match?(/Stream.+\[e\].+/)
|
@@ -29,18 +115,59 @@ module ForemanMaintain::PackageManager
|
|
29
115
|
|
30
116
|
private
|
31
117
|
|
32
|
-
|
118
|
+
# rubocop:disable Metrics/LineLength, Metrics/ParameterLists
|
119
|
+
def dnf_action(action, packages, with_status: false, assumeyes: false, dnf_options: [], valid_exit_statuses: [0])
|
33
120
|
packages = [packages].flatten(1)
|
34
|
-
|
35
|
-
|
121
|
+
|
122
|
+
dnf_options << '-y' if assumeyes
|
123
|
+
dnf_options << '--disableplugin=foreman-protector'
|
124
|
+
|
125
|
+
command = ['dnf', dnf_options.join(' '), action]
|
126
|
+
|
127
|
+
command.push(packages.join(' ')) unless packages.empty?
|
128
|
+
command = command.join(' ')
|
129
|
+
|
36
130
|
if with_status
|
37
|
-
sys.execute_with_status(
|
38
|
-
|
131
|
+
sys.execute_with_status(
|
132
|
+
command,
|
133
|
+
:interactive => !assumeyes
|
134
|
+
)
|
39
135
|
else
|
40
|
-
sys.execute!(
|
41
|
-
|
136
|
+
sys.execute!(
|
137
|
+
command,
|
138
|
+
:interactive => !assumeyes,
|
139
|
+
:valid_exit_statuses => valid_exit_statuses
|
140
|
+
)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
# rubocop:enable Metrics/LineLength, Metrics/ParameterLists
|
42
144
|
|
145
|
+
def protector_config
|
146
|
+
File.exist?(protector_config_file) ? File.read(protector_config_file) : ''
|
147
|
+
end
|
148
|
+
|
149
|
+
def protector_config_file
|
150
|
+
PROTECTOR_CONFIG_FILE
|
151
|
+
end
|
152
|
+
|
153
|
+
def enable_protector
|
154
|
+
setup_protector(true)
|
155
|
+
end
|
156
|
+
|
157
|
+
def disable_protector
|
158
|
+
setup_protector(false)
|
159
|
+
end
|
160
|
+
|
161
|
+
def setup_protector(enabled)
|
162
|
+
config = protector_config
|
163
|
+
config += "\n" unless config[-1] == "\n"
|
164
|
+
enabled_re = /^\s*enabled\s*=.*$/
|
165
|
+
if enabled_re.match(config)
|
166
|
+
config = config.gsub(enabled_re, "enabled = #{enabled ? '1' : '0'}")
|
167
|
+
else
|
168
|
+
config += "enabled = #{enabled ? '1' : '0'}\n"
|
43
169
|
end
|
170
|
+
File.open(protector_config_file, 'w') { |file| file.puts config }
|
44
171
|
end
|
45
172
|
end
|
46
173
|
end
|
@@ -72,8 +72,8 @@ module ForemanMaintain::RepositoryManager
|
|
72
72
|
entry.split(':', 2).last.strip
|
73
73
|
end]
|
74
74
|
|
75
|
-
#
|
76
|
-
#
|
75
|
+
# repolist output includes extra info in the output
|
76
|
+
#
|
77
77
|
# rhel-7-server-rpms/7Server/x86_64
|
78
78
|
# rhel-server-rhscl-7-rpms/7Server/x86_64
|
79
79
|
# This trims anything after first '/' to get correct repo label
|
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: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -158,9 +158,7 @@ files:
|
|
158
158
|
- config/foreman_maintain.yml.packaging
|
159
159
|
- config/hammer.yml.example
|
160
160
|
- definitions/checks/backup/certs_tar_exist.rb
|
161
|
-
- definitions/checks/backup/directory_ready.rb
|
162
161
|
- definitions/checks/candlepin/db_up.rb
|
163
|
-
- definitions/checks/check_for_newer_packages.rb
|
164
162
|
- definitions/checks/check_hotfix_installed.rb
|
165
163
|
- definitions/checks/check_tmout.rb
|
166
164
|
- definitions/checks/disk/available_space.rb
|
@@ -168,15 +166,12 @@ files:
|
|
168
166
|
- definitions/checks/disk/available_space_postgresql12.rb
|
169
167
|
- definitions/checks/disk/performance.rb
|
170
168
|
- definitions/checks/env_proxy.rb
|
171
|
-
- definitions/checks/foreman/check_checkpoint_segments.rb
|
172
169
|
- definitions/checks/foreman/check_corrupted_roles.rb
|
173
170
|
- definitions/checks/foreman/check_duplicate_permission.rb
|
174
|
-
- definitions/checks/foreman/check_duplicate_roles.rb
|
175
171
|
- definitions/checks/foreman/check_puppet_capsules.rb
|
176
172
|
- definitions/checks/foreman/check_tuning_requirements.rb
|
177
173
|
- definitions/checks/foreman/db_up.rb
|
178
174
|
- definitions/checks/foreman/facts_names.rb
|
179
|
-
- definitions/checks/foreman/puppet_class_duplicates.rb
|
180
175
|
- definitions/checks/foreman/validate_external_db_version.rb
|
181
176
|
- definitions/checks/foreman_openscap/invalid_report_associations.rb
|
182
177
|
- definitions/checks/foreman_proxy/check_tftp_storage.rb
|
@@ -188,8 +183,7 @@ files:
|
|
188
183
|
- definitions/checks/foreman_tasks/not_running.rb
|
189
184
|
- definitions/checks/maintenance_mode/check_consistency.rb
|
190
185
|
- definitions/checks/non_rh_packages.rb
|
191
|
-
- definitions/checks/
|
192
|
-
- definitions/checks/package_manager/yum/validate_yum_config.rb
|
186
|
+
- definitions/checks/package_manager/dnf/validate_dnf_config.rb
|
193
187
|
- definitions/checks/pulpcore/db_up.rb
|
194
188
|
- definitions/checks/puppet/verify_no_empty_cacert_requests.rb
|
195
189
|
- definitions/checks/repositories/check_non_rh_repository.rb
|
@@ -256,14 +250,13 @@ files:
|
|
256
250
|
- definitions/procedures/backup/snapshot/mount_pulp.rb
|
257
251
|
- definitions/procedures/backup/snapshot/mount_pulpcore_db.rb
|
258
252
|
- definitions/procedures/backup/snapshot/prepare_mount.rb
|
253
|
+
- definitions/procedures/backup/snapshot/snapshot_deprecation_message.rb
|
259
254
|
- definitions/procedures/crond/start.rb
|
260
255
|
- definitions/procedures/crond/stop.rb
|
261
256
|
- definitions/procedures/files/remove.rb
|
262
|
-
- definitions/procedures/foreman/apipie_cache.rb
|
263
257
|
- definitions/procedures/foreman/fix_corrupted_roles.rb
|
264
258
|
- definitions/procedures/foreman/remove_duplicate_obsolete_roles.rb
|
265
259
|
- definitions/procedures/foreman/remove_duplicate_permissions.rb
|
266
|
-
- definitions/procedures/foreman_docker/remove_foreman_docker.rb
|
267
260
|
- definitions/procedures/foreman_maintain_features.rb
|
268
261
|
- definitions/procedures/foreman_openscap/invalid_report_associations.rb
|
269
262
|
- definitions/procedures/foreman_proxy/features.rb
|
@@ -280,6 +273,7 @@ files:
|
|
280
273
|
- definitions/procedures/maintenance_mode/disable_maintenance_mode.rb
|
281
274
|
- definitions/procedures/maintenance_mode/enable_maintenance_mode.rb
|
282
275
|
- definitions/procedures/maintenance_mode/is_enabled.rb
|
276
|
+
- definitions/procedures/packages/check_for_reboot.rb
|
283
277
|
- definitions/procedures/packages/check_update.rb
|
284
278
|
- definitions/procedures/packages/enable_modules.rb
|
285
279
|
- definitions/procedures/packages/install.rb
|
@@ -342,7 +336,6 @@ files:
|
|
342
336
|
- extras/foreman_protector/dnf/foreman-protector.py
|
343
337
|
- extras/foreman_protector/foreman-protector.conf
|
344
338
|
- extras/foreman_protector/foreman-protector.whitelist
|
345
|
-
- extras/foreman_protector/yum/foreman-protector.py
|
346
339
|
- lib/foreman_maintain.rb
|
347
340
|
- lib/foreman_maintain/check.rb
|
348
341
|
- lib/foreman_maintain/cli.rb
|
@@ -397,7 +390,6 @@ files:
|
|
397
390
|
- lib/foreman_maintain/package_manager/apt.rb
|
398
391
|
- lib/foreman_maintain/package_manager/base.rb
|
399
392
|
- lib/foreman_maintain/package_manager/dnf.rb
|
400
|
-
- lib/foreman_maintain/package_manager/yum.rb
|
401
393
|
- lib/foreman_maintain/param.rb
|
402
394
|
- lib/foreman_maintain/procedure.rb
|
403
395
|
- lib/foreman_maintain/reporter.rb
|
@@ -433,7 +425,7 @@ homepage: https://github.com/theforeman/foreman_maintain
|
|
433
425
|
licenses:
|
434
426
|
- GPL-3.0
|
435
427
|
metadata: {}
|
436
|
-
post_install_message:
|
428
|
+
post_install_message:
|
437
429
|
rdoc_options: []
|
438
430
|
require_paths:
|
439
431
|
- lib
|
@@ -451,8 +443,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
451
443
|
- !ruby/object:Gem::Version
|
452
444
|
version: '0'
|
453
445
|
requirements: []
|
454
|
-
rubygems_version: 3.
|
455
|
-
signing_key:
|
446
|
+
rubygems_version: 3.3.26
|
447
|
+
signing_key:
|
456
448
|
specification_version: 4
|
457
449
|
summary: Foreman maintenance tool belt
|
458
450
|
test_files: []
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Checks::Backup
|
2
|
-
class DirectoryReady < ForemanMaintain::Check
|
3
|
-
metadata do
|
4
|
-
description 'Check if the directory exists and is writable'
|
5
|
-
tags :backup
|
6
|
-
manual_detection
|
7
|
-
param :backup_dir, 'Directory where to backup to', :required => true
|
8
|
-
param :preserve_dir, 'Directory where to backup to', :flag => true, :default => false
|
9
|
-
param :postgres_access, 'Whether the postgres user needs access', :flag => true,
|
10
|
-
:default => false
|
11
|
-
end
|
12
|
-
|
13
|
-
def run
|
14
|
-
assert(File.directory?(@backup_dir), "Backup directory (#{@backup_dir}) does not exist.")
|
15
|
-
if feature(:instance).postgresql_local? && @postgres_access
|
16
|
-
result = system("runuser - postgres -c 'test -w #{@backup_dir}'")
|
17
|
-
assert(result, "Postgres user needs write access to the backup directory \n" \
|
18
|
-
"Please allow the postgres user write access to #{@backup_dir}" \
|
19
|
-
' or choose another directory.')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
class Checks::CheckForNewerPackages < ForemanMaintain::Check
|
2
|
-
metadata do
|
3
|
-
label :check_for_newer_packages
|
4
|
-
description 'Check for newer packages and optionally ask for confirmation if not found.'
|
5
|
-
|
6
|
-
param :packages,
|
7
|
-
'package names to validate',
|
8
|
-
:required => true
|
9
|
-
param :manual_confirmation_version,
|
10
|
-
'Version of satellite to ask the user if they are on the latest minor release of.',
|
11
|
-
:required => false
|
12
|
-
manual_detection
|
13
|
-
end
|
14
|
-
|
15
|
-
def run
|
16
|
-
check_for_package_update
|
17
|
-
if @manual_confirmation_version
|
18
|
-
question = 'Confirm that you are running the latest minor release of Satellite '\
|
19
|
-
"#{@manual_confirmation_version}"
|
20
|
-
answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
|
21
|
-
abort! if answer != :yes
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def check_for_package_update
|
26
|
-
exit_status, output = ForemanMaintain.package_manager.check_update(packages: @packages,
|
27
|
-
with_status: true)
|
28
|
-
packages_with_updates = []
|
29
|
-
if exit_status == 100
|
30
|
-
packages_with_updates = compare_pkg_versions(output).select do |_, result|
|
31
|
-
result == -1
|
32
|
-
end.keys
|
33
|
-
end
|
34
|
-
|
35
|
-
unless packages_with_updates.empty?
|
36
|
-
command = ForemanMaintain.pkg_and_cmd_name[1]
|
37
|
-
fail! 'Required updates for some packages detected.'\
|
38
|
-
"\nPlease update to the latest #{@manual_confirmation_version}.z release "\
|
39
|
-
'before proceeding, using:'\
|
40
|
-
"\n# #{command} upgrade run --target-version #{@manual_confirmation_version}.z"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def packages_and_versions(output)
|
45
|
-
pkgs_versions = {}
|
46
|
-
pkg_details = output.split("\n\n")[1].split
|
47
|
-
@packages.each do |pkg|
|
48
|
-
pkg_details.each_with_index do |ele, index|
|
49
|
-
next unless ele.start_with?(pkg)
|
50
|
-
pkgs_versions[pkg] = version(pkg_details[index + 1].split('-').first)
|
51
|
-
break
|
52
|
-
end
|
53
|
-
end
|
54
|
-
pkgs_versions
|
55
|
-
end
|
56
|
-
|
57
|
-
def compare_pkg_versions(output)
|
58
|
-
compare_pkg_versions = {}
|
59
|
-
packages_and_versions = packages_and_versions(output)
|
60
|
-
pkg_versions610 = { 'python3-pulp-2to3-migration' => version('0.12'),
|
61
|
-
'tfm-rubygem-katello' => version('4.1') }
|
62
|
-
packages_and_versions.each do |name, version|
|
63
|
-
compare_pkg_versions[name] = version.<=>(pkg_versions610[name])
|
64
|
-
end
|
65
|
-
compare_pkg_versions
|
66
|
-
end
|
67
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module Checks
|
2
|
-
module Foreman
|
3
|
-
class CheckpointSegments < ForemanMaintain::Check
|
4
|
-
metadata do
|
5
|
-
label :check_postgresql_checkpoint_segments
|
6
|
-
description 'Check if checkpoint_segments configuration exists on the system'
|
7
|
-
confine do
|
8
|
-
feature(:foreman) && feature(:installer) &&
|
9
|
-
File.exist?(feature(:installer).custom_hiera_file)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def run
|
14
|
-
failure_message = check_custom_hiera
|
15
|
-
fail! failure_message if failure_message
|
16
|
-
end
|
17
|
-
|
18
|
-
# rubocop:disable Metrics/MethodLength
|
19
|
-
def check_custom_hiera
|
20
|
-
hiera_file = feature(:installer).custom_hiera_file
|
21
|
-
begin
|
22
|
-
config = YAML.load_file(hiera_file)
|
23
|
-
if config.is_a?(Hash) && config.key?('postgresql::server::config_entries')
|
24
|
-
if config['postgresql::server::config_entries'].nil?
|
25
|
-
return <<-MESSAGE.strip_heredoc
|
26
|
-
ERROR: 'postgresql::server::config_entries' cannot be null.
|
27
|
-
Please remove it from following file and re-run the command.
|
28
|
-
- #{hiera_file}
|
29
|
-
MESSAGE
|
30
|
-
elsif config['postgresql::server::config_entries'].key?('checkpoint_segments')
|
31
|
-
message = <<-MESSAGE.strip_heredoc
|
32
|
-
ERROR: Tuning option 'checkpoint_segments' found.
|
33
|
-
This option is no longer valid for PostgreSQL 9.5 or newer.
|
34
|
-
Please remove it from following file and re-run the command.
|
35
|
-
- #{hiera_file}
|
36
|
-
MESSAGE
|
37
|
-
if feature(:katello)
|
38
|
-
message += <<-MESSAGE.strip_heredoc
|
39
|
-
The presence of checkpoint_segments in #{hiera_file} indicates manual tuning.
|
40
|
-
Manual tuning can override values provided by the --tuning parameter.
|
41
|
-
Review #{hiera_file} for values that are already provided by the built in tuning profiles.
|
42
|
-
Built in tuning profiles also provide a supported upgrade path.
|
43
|
-
MESSAGE
|
44
|
-
end
|
45
|
-
return message
|
46
|
-
end
|
47
|
-
elsif config.is_a?(String)
|
48
|
-
fail! "Error: File #{hiera_file} is not a yaml file."
|
49
|
-
exit 1
|
50
|
-
end
|
51
|
-
rescue Psych::SyntaxError
|
52
|
-
fail! "Found syntax error in file: #{hiera_file}"
|
53
|
-
exit 1
|
54
|
-
end
|
55
|
-
end
|
56
|
-
# rubocop:enable Metrics/MethodLength
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Checks
|
2
|
-
module Foreman
|
3
|
-
class CheckDuplicateRoles < ForemanMaintain::Check
|
4
|
-
metadata do
|
5
|
-
label :duplicate_roles
|
6
|
-
for_feature :foreman_database
|
7
|
-
description 'Check for duplicate roles from DB'
|
8
|
-
tags :pre_upgrade
|
9
|
-
confine do
|
10
|
-
check_max_version('foreman', '1.20')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def run
|
15
|
-
duplicate_roles = find_duplicate_roles
|
16
|
-
roles_names = duplicate_roles.map { |r| r['name'] }.uniq
|
17
|
-
assert(
|
18
|
-
duplicate_roles.empty?,
|
19
|
-
"Duplicate entries found for role(s) - #{roles_names.join(', ')} in your DB",
|
20
|
-
:next_steps => [
|
21
|
-
Procedures::Foreman::RemoveDuplicateObsoleteRoles.new,
|
22
|
-
Procedures::KnowledgeBaseArticle.new(
|
23
|
-
:doc => 'fix_db_migrate_failure_on_duplicate_roles'
|
24
|
-
),
|
25
|
-
]
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
def find_duplicate_roles
|
30
|
-
feature(:foreman_database).query(self.class.query_to_get_duplicate_roles)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.query_to_get_duplicate_roles
|
34
|
-
<<-SQL
|
35
|
-
SELECT r.id, r.name FROM roles r JOIN (
|
36
|
-
SELECT name, COUNT(*) FROM roles GROUP BY name HAVING count(*) > 1
|
37
|
-
) dr ON r.name = dr.name ORDER BY r.name
|
38
|
-
SQL
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module Checks
|
2
|
-
module Foreman
|
3
|
-
class PuppetClassDuplicates < ForemanMaintain::Check
|
4
|
-
metadata do
|
5
|
-
label :puppet_class_duplicates
|
6
|
-
for_feature :foreman_database
|
7
|
-
description 'Check for duplicate Puppet class records'
|
8
|
-
tags :pre_upgrade
|
9
|
-
confine do
|
10
|
-
check_max_version('foreman', '1.20')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def run
|
15
|
-
duplicate_names = find_duplicate_names
|
16
|
-
assert(duplicate_names.empty?, duplicate_msg(duplicate_names))
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def duplicate_msg(duplicate_names)
|
22
|
-
msg = "There are #{duplicate_names.count} Puppet classes with duplicities:\n"
|
23
|
-
classes_list = duplicate_names.reduce('') do |memo, hash|
|
24
|
-
memo.tap { |acc| acc << "#{hash['name']} - #{hash['name_count']}\n" }
|
25
|
-
end
|
26
|
-
help_msg = 'Please head over to Configure -> Classes'
|
27
|
-
help_msg << " and make sure there is only 1 Puppet class record for each name.\n"
|
28
|
-
[msg, classes_list, help_msg].join('')
|
29
|
-
end
|
30
|
-
|
31
|
-
def find_duplicate_names
|
32
|
-
feature(:foreman_database).query(duplicate_names_query)
|
33
|
-
end
|
34
|
-
|
35
|
-
def duplicate_names_query
|
36
|
-
<<-SQL
|
37
|
-
SELECT name, name_count
|
38
|
-
FROM (
|
39
|
-
SELECT name, count(name) AS name_count
|
40
|
-
FROM puppetclasses
|
41
|
-
GROUP BY name
|
42
|
-
) AS puppetclass_counts
|
43
|
-
WHERE name_count > 1
|
44
|
-
SQL
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
class Checks::OriginalAssets < ForemanMaintain::Check
|
2
|
-
metadata do
|
3
|
-
description 'Check if only installed assets are present on the system'
|
4
|
-
tags :post_upgrade
|
5
|
-
for_feature :foreman_server
|
6
|
-
end
|
7
|
-
|
8
|
-
ASSETS_DIR = '/var/lib/foreman/public/assets'.freeze
|
9
|
-
|
10
|
-
def run
|
11
|
-
custom_assets = []
|
12
|
-
product_name = feature(:instance).product_name
|
13
|
-
with_spinner('Checking for presence of non-original assets...') do
|
14
|
-
custom_assets = package_manager.files_not_owned_by_package(ASSETS_DIR)
|
15
|
-
logger.info("Non-original assets detected:\n" + custom_assets.join("\n"))
|
16
|
-
end
|
17
|
-
remove_files = Procedures::Files::Remove.new(:files => custom_assets, :assumeyes => true)
|
18
|
-
assert(custom_assets.empty?,
|
19
|
-
"Some assets not owned by #{product_name} were detected on the system.\n" \
|
20
|
-
'Possible conflicting versions can affect operation of the Web UI.',
|
21
|
-
:next_steps => remove_files)
|
22
|
-
end
|
23
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Procedures::ForemanDocker
|
2
|
-
class RemoveForemanDocker < ForemanMaintain::Procedure
|
3
|
-
metadata do
|
4
|
-
advanced_run false
|
5
|
-
description 'Drop foreman_docker plugin'
|
6
|
-
confine do
|
7
|
-
find_package(foreman_plugin_name('foreman_docker'))
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
execute!('foreman-rake foreman_docker:cleanup')
|
13
|
-
packages_action(:remove, foreman_plugin_name('foreman_docker'), :assumeyes => true)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|