foreman_maintain 0.8.17 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/definitions/checks/check_for_newer_packages.rb +43 -4
- data/definitions/checks/foreman/check_https_proxies.rb +34 -0
- data/definitions/checks/repositories/validate.rb +1 -2
- data/definitions/checks/restore/validate_interfaces.rb +24 -0
- data/definitions/procedures/backup/metadata.rb +11 -0
- data/definitions/procedures/pulp/remove.rb +2 -1
- data/definitions/procedures/repositories/setup.rb +0 -4
- data/definitions/procedures/restore/configs.rb +5 -1
- data/definitions/scenarios/restore.rb +2 -0
- data/definitions/scenarios/upgrade_to_satellite_6_10.rb +1 -0
- data/lib/foreman_maintain/concerns/os_facts.rb +70 -0
- data/lib/foreman_maintain/concerns/system_helpers.rb +6 -30
- data/lib/foreman_maintain/utils/backup.rb +80 -14
- data/lib/foreman_maintain/utils.rb +0 -1
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain.rb +1 -0
- metadata +23 -7
- data/lib/foreman_maintain/utils/facter.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e995fb504729078ae910121820a8f286d1256b4319d07d25f27a17768ba515af
|
4
|
+
data.tar.gz: 8fb3b6231928b49a6c6cd8375a14394b31839452ead4c0a7e3dbc198f405912d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12ff59c3185962df60825149e3f34892c6bc42071fb39b35aa701b891dd34eb71843784c161e64d0218e669e66a2f85715991f76a319f48f6fb4dbeba55ddf2f
|
7
|
+
data.tar.gz: 747024ed62640c6c49406f573557253e6ea96037921633ca94489c20f34f32a1a233c4f6a9bb67bdac45aa9dd8af9bb727733f7531c8d0c5303f56ce59a8ce60
|
@@ -9,13 +9,11 @@ class Checks::CheckForNewerPackages < ForemanMaintain::Check
|
|
9
9
|
param :manual_confirmation_version,
|
10
10
|
'Version of satellite (6.9) to ask the user if they are on the latest minor release of.',
|
11
11
|
:required => false
|
12
|
+
manual_detection
|
12
13
|
end
|
13
14
|
|
14
15
|
def run
|
15
|
-
|
16
|
-
with_status: true)
|
17
|
-
assert(exit_status == 0, 'An update is available for one of these packages: '\
|
18
|
-
"#{@packages.join(',')}. Please update before proceeding.")
|
16
|
+
check_for_package_update
|
19
17
|
if @manual_confirmation_version
|
20
18
|
question = 'Confirm that you are running the latest minor release of Satellite '\
|
21
19
|
"#{@manual_confirmation_version}"
|
@@ -23,4 +21,45 @@ class Checks::CheckForNewerPackages < ForemanMaintain::Check
|
|
23
21
|
abort! if answer != :yes
|
24
22
|
end
|
25
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
|
+
failure_message = 'An update is available for package(s): '\
|
37
|
+
"#{packages_with_updates.join(',')}. Please update before proceeding!"
|
38
|
+
fail! failure_message
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def packages_and_versions(output)
|
43
|
+
pkgs_versions = {}
|
44
|
+
pkg_details = output.split("\n\n")[1].split
|
45
|
+
@packages.each do |pkg|
|
46
|
+
pkg_details.each_with_index do |ele, index|
|
47
|
+
next unless ele.start_with?(pkg)
|
48
|
+
pkgs_versions[pkg] = version(pkg_details[index + 1].split('-').first)
|
49
|
+
break
|
50
|
+
end
|
51
|
+
end
|
52
|
+
pkgs_versions
|
53
|
+
end
|
54
|
+
|
55
|
+
def compare_pkg_versions(output)
|
56
|
+
compare_pkg_versions = {}
|
57
|
+
packages_and_versions = packages_and_versions(output)
|
58
|
+
pkg_versions610 = { 'python3-pulp-2to3-migration' => version('0.12'),
|
59
|
+
'tfm-rubygem-katello' => version('4.1') }
|
60
|
+
packages_and_versions.each do |name, version|
|
61
|
+
compare_pkg_versions[name] = version.<=>(pkg_versions610[name])
|
62
|
+
end
|
63
|
+
compare_pkg_versions
|
64
|
+
end
|
26
65
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Checks
|
2
|
+
class CheckHttpsProxies < ForemanMaintain::Check
|
3
|
+
metadata do
|
4
|
+
label :https_proxies
|
5
|
+
for_feature :foreman_database
|
6
|
+
description 'Check for HTTPS proxies from the database'
|
7
|
+
manual_detection
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
https_proxies = find_https_proxies
|
12
|
+
unless https_proxies.empty?
|
13
|
+
https_proxy_names = https_proxies.map { |proxy| proxy['name'] }
|
14
|
+
question = "Syncing repositories through an 'HTTP Proxy' that uses the HTTPS\n"\
|
15
|
+
"protocol is not supported directly with Satellite 6.10.\n"\
|
16
|
+
"The following proxies use HTTPS: #{https_proxy_names.join(', ')}.\n"\
|
17
|
+
"For a suggested solution see https://access.redhat.com/solutions/6414991\n"\
|
18
|
+
'Continue upgrade?'
|
19
|
+
answer = ask_decision(question, actions_msg: 'y(yes), q(quit)')
|
20
|
+
abort! if answer != :yes
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_https_proxies
|
25
|
+
feature(:foreman_database).query(self.class.query_to_get_https_proxies)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.query_to_get_https_proxies
|
29
|
+
<<-SQL
|
30
|
+
SELECT \"http_proxies\".* FROM \"http_proxies\" WHERE (http_proxies.url ilike 'https://%')
|
31
|
+
SQL
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -3,8 +3,7 @@ module Checks::Repositories
|
|
3
3
|
metadata do
|
4
4
|
description 'Validate availability of repositories'
|
5
5
|
preparation_steps do
|
6
|
-
|
7
|
-
Procedures::Packages::Install.new(:packages => [ForemanMaintain::Utils::Facter.package])]
|
6
|
+
Checks::Repositories::CheckNonRhRepository.new
|
8
7
|
end
|
9
8
|
|
10
9
|
confine do
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'foreman_maintain/utils/backup'
|
2
|
+
|
3
|
+
module Checks::Restore
|
4
|
+
class ValidateInterfaces < ForemanMaintain::Check
|
5
|
+
metadata do
|
6
|
+
description 'Validate network interfaces match the backup'
|
7
|
+
|
8
|
+
param :backup_dir,
|
9
|
+
'Path to backup directory',
|
10
|
+
:required => true
|
11
|
+
manual_detection
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
backup = ForemanMaintain::Utils::Backup.new(@backup_dir)
|
16
|
+
invalid_interfaces = backup.validate_interfaces
|
17
|
+
msg = 'The following features are enabled in the backup, '\
|
18
|
+
"\nbut the system does not have the interfaces used by these features: "
|
19
|
+
msg << invalid_interfaces.map { |k, v| "#{k} (#{v['configured']})" }.join(', ')
|
20
|
+
msg << '.'
|
21
|
+
assert(backup.validate_interfaces.empty?, msg)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -9,6 +9,8 @@ module Procedures::Backup
|
|
9
9
|
param :online_backup, 'Select for online backup', :flag => true, :default => false
|
10
10
|
end
|
11
11
|
|
12
|
+
PROXY_CONFIG_ENTRIES = %w[dns dns_interface dhcp dhcp_interface].freeze
|
13
|
+
|
12
14
|
def run
|
13
15
|
with_spinner('Collecting metadata') do |spinner|
|
14
16
|
metadata = {}
|
@@ -18,6 +20,8 @@ module Procedures::Backup
|
|
18
20
|
metadata['rpms'] = rpms(spinner)
|
19
21
|
metadata['incremental'] = @incremental_dir || false
|
20
22
|
metadata['online'] = @online_backup
|
23
|
+
metadata['hostname'] = hostname
|
24
|
+
metadata['proxy_config'] = proxy_config(spinner)
|
21
25
|
save_metadata(metadata, spinner)
|
22
26
|
end
|
23
27
|
end
|
@@ -54,5 +58,12 @@ module Procedures::Backup
|
|
54
58
|
feature(:foreman_proxy).features
|
55
59
|
end
|
56
60
|
end
|
61
|
+
|
62
|
+
def proxy_config(spinner)
|
63
|
+
spinner.update('Collecting proxy configuration')
|
64
|
+
feature(:installer).answers['foreman_proxy'].select do |key, _|
|
65
|
+
PROXY_CONFIG_ENTRIES.include?(key)
|
66
|
+
end
|
67
|
+
end
|
57
68
|
end
|
58
69
|
end
|
@@ -2,10 +2,6 @@ module Procedures::Repositories
|
|
2
2
|
class Setup < ForemanMaintain::Procedure
|
3
3
|
metadata do
|
4
4
|
description 'Setup repositories'
|
5
|
-
preparation_steps do
|
6
|
-
Procedures::Packages::Install.new(:packages => [ForemanMaintain::Utils::Facter.package])
|
7
|
-
end
|
8
|
-
|
9
5
|
confine do
|
10
6
|
feature(:instance).downstream || feature(:upstream)
|
11
7
|
end
|
@@ -56,7 +56,11 @@ module Procedures::Restore
|
|
56
56
|
def reset_qpid_jrnls
|
57
57
|
# on restore without pulp data qpid fails to start
|
58
58
|
# https://access.redhat.com/solutions/4645231
|
59
|
-
|
59
|
+
['/var/lib/qpidd/.qpidd/', '/var/lib/qpidd/'].each do |qpidd_path|
|
60
|
+
if Dir.exist?("#{qpidd_path}/qls/dat2/")
|
61
|
+
execute("rm -rf #{qpidd_path}/qls/dat2/__db.00*")
|
62
|
+
end
|
63
|
+
end
|
60
64
|
end
|
61
65
|
end
|
62
66
|
end
|
@@ -18,6 +18,7 @@ module ForemanMaintain::Scenarios
|
|
18
18
|
add_steps_with_context(Checks::Restore::ValidateBackup,
|
19
19
|
Procedures::Restore::Confirmation,
|
20
20
|
Checks::Restore::ValidateHostname,
|
21
|
+
Checks::Restore::ValidateInterfaces,
|
21
22
|
Procedures::Selinux::SetFileSecurity,
|
22
23
|
Procedures::Restore::Configs)
|
23
24
|
add_step_with_context(Procedures::Crond::Stop) if feature(:cron)
|
@@ -87,6 +88,7 @@ module ForemanMaintain::Scenarios
|
|
87
88
|
context.map(:backup_dir,
|
88
89
|
Checks::Restore::ValidateBackup => :backup_dir,
|
89
90
|
Checks::Restore::ValidateHostname => :backup_dir,
|
91
|
+
Checks::Restore::ValidateInterfaces => :backup_dir,
|
90
92
|
Procedures::Restore::Configs => :backup_dir,
|
91
93
|
Procedures::Restore::DropDatabases => :backup_dir,
|
92
94
|
Procedures::Restore::PgGlobalObjects => :backup_dir,
|
@@ -29,6 +29,7 @@ module Scenarios::Satellite_6_10
|
|
29
29
|
add_step(Checks::CheckForNewerPackages.new(:packages => [foreman_plugin_name('katello'),
|
30
30
|
'python3-pulp-2to3-migration'],
|
31
31
|
:manual_confirmation_version => '6.9'))
|
32
|
+
add_step(Checks::CheckHttpsProxies)
|
32
33
|
add_steps(find_checks(:default))
|
33
34
|
add_steps(find_checks(:pre_upgrade))
|
34
35
|
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
module Concerns
|
3
|
+
module OsFacts
|
4
|
+
OS_RELEASE_FILE = '/etc/os-release'.freeze
|
5
|
+
FALLBACK_OS_RELEASE_FILE = '/usr/lib/os-release'.freeze
|
6
|
+
|
7
|
+
def os_release_file
|
8
|
+
if File.file?(OS_RELEASE_FILE)
|
9
|
+
return OS_RELEASE_FILE
|
10
|
+
elsif File.file?(FALLBACK_OS_RELEASE_FILE)
|
11
|
+
return FALLBACK_OS_RELEASE_FILE
|
12
|
+
else
|
13
|
+
puts "The #{OS_RELEASE_FILE} and #{FALLBACK_OS_RELEASE_FILE} files are missing! "\
|
14
|
+
"Can't continue the execution without Operating System's facts!"
|
15
|
+
exit 1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def facts
|
20
|
+
unless defined?(@facts)
|
21
|
+
@facts = {}
|
22
|
+
regex = /^(["'])(.*)(\1)$/
|
23
|
+
File.open(os_release_file) do |file|
|
24
|
+
file.readlines.each do |line|
|
25
|
+
line.strip! # drop any whitespace, including newlines from start and end of the line
|
26
|
+
next if line.start_with?('#') # ignore comments
|
27
|
+
# split at most into 2 items, if the value ever contains an =
|
28
|
+
key, value = line.split('=', 2)
|
29
|
+
next unless key && value
|
30
|
+
@facts[key] = value.gsub(regex, '\2').delete('\\')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
@facts
|
35
|
+
end
|
36
|
+
|
37
|
+
def os_version_id
|
38
|
+
facts.fetch('VERSION_ID')
|
39
|
+
end
|
40
|
+
|
41
|
+
def os_id
|
42
|
+
facts.fetch('ID')
|
43
|
+
end
|
44
|
+
|
45
|
+
def os_id_like_list
|
46
|
+
facts.fetch('ID_LIKE', '').split
|
47
|
+
end
|
48
|
+
|
49
|
+
def el?
|
50
|
+
File.exist?('/etc/redhat-release')
|
51
|
+
end
|
52
|
+
|
53
|
+
def debian?
|
54
|
+
File.exist?('/etc/debian_version')
|
55
|
+
end
|
56
|
+
|
57
|
+
def el7?
|
58
|
+
el_major_version == 7
|
59
|
+
end
|
60
|
+
|
61
|
+
def el8?
|
62
|
+
el_major_version == 8
|
63
|
+
end
|
64
|
+
|
65
|
+
def el_major_version
|
66
|
+
return os_version_id.to_i if el?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -8,6 +8,7 @@ module ForemanMaintain
|
|
8
8
|
module SystemHelpers
|
9
9
|
include Logger
|
10
10
|
include Concerns::Finders
|
11
|
+
include ForemanMaintain::Concerns::OsFacts
|
11
12
|
|
12
13
|
def self.included(klass)
|
13
14
|
klass.extend(self)
|
@@ -147,7 +148,7 @@ module ForemanMaintain
|
|
147
148
|
end
|
148
149
|
|
149
150
|
def format_shell_args(options = {})
|
150
|
-
options.map { |shell_optn, val| " #{shell_optn}
|
151
|
+
options.map { |shell_optn, val| " #{shell_optn} #{shellescape(val)}" }.join
|
151
152
|
end
|
152
153
|
|
153
154
|
def find_symlinks(dir_path)
|
@@ -184,38 +185,13 @@ module ForemanMaintain
|
|
184
185
|
ForemanMaintain.package_manager
|
185
186
|
end
|
186
187
|
|
187
|
-
def os_facts
|
188
|
-
facter = ForemanMaintain::Utils::Facter.path
|
189
|
-
@os_facts ||= JSON.parse(execute("#{facter} -j os"))
|
190
|
-
end
|
191
|
-
|
192
|
-
def el?
|
193
|
-
os_facts['os']['family'] == 'RedHat'
|
194
|
-
end
|
195
|
-
|
196
|
-
def debian?
|
197
|
-
os_facts['os']['family'] == 'Debian'
|
198
|
-
end
|
199
|
-
|
200
|
-
def el7?
|
201
|
-
os_facts['os']['release']['major'] == '7' && el?
|
202
|
-
end
|
203
|
-
|
204
|
-
def el8?
|
205
|
-
os_facts['os']['release']['major'] == '8' && el?
|
206
|
-
end
|
207
|
-
|
208
|
-
def el_major_version
|
209
|
-
return os_facts['os']['release']['major'] if el?
|
210
|
-
end
|
211
|
-
|
212
188
|
def ruby_prefix(scl = true)
|
213
|
-
if
|
189
|
+
if debian?
|
190
|
+
'ruby-'
|
191
|
+
elsif el7? && scl
|
214
192
|
'tfm-rubygem-'
|
215
|
-
|
193
|
+
else
|
216
194
|
'rubygem-'
|
217
|
-
elsif debian?
|
218
|
-
'ruby-'
|
219
195
|
end
|
220
196
|
end
|
221
197
|
|
@@ -77,11 +77,15 @@ module ForemanMaintain
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def valid_fpc_backup?
|
80
|
-
fpc_online_backup? || fpc_standard_backup? || fpc_logical_backup?
|
80
|
+
fpc_online_backup? || fpc_standard_backup? || fpc_logical_backup? || \
|
81
|
+
# fpc can have setup where mongo or pulpcore db is external but not both
|
82
|
+
fpc_hybrid_db_backup?
|
81
83
|
end
|
82
84
|
|
83
85
|
def valid_katello_backup?
|
84
|
-
katello_online_backup? || katello_standard_backup? || katello_logical_backup?
|
86
|
+
katello_online_backup? || katello_standard_backup? || katello_logical_backup? || \
|
87
|
+
# Katello can have setup where some of dbs are external but not all
|
88
|
+
katello_hybrid_db_backup?
|
85
89
|
end
|
86
90
|
|
87
91
|
def valid_foreman_backup?
|
@@ -104,7 +108,6 @@ module ForemanMaintain
|
|
104
108
|
true
|
105
109
|
end
|
106
110
|
|
107
|
-
# TODO: Need to check for pulpcore feature?
|
108
111
|
def katello_standard_backup?
|
109
112
|
present = [:pgsql_data]
|
110
113
|
absent = [:candlepin_dump, :foreman_dump, :pulpcore_dump, :mongo_dump]
|
@@ -155,6 +158,14 @@ module ForemanMaintain
|
|
155
158
|
:absent => absent)
|
156
159
|
end
|
157
160
|
|
161
|
+
def katello_hybrid_db_backup?
|
162
|
+
all_dbs = { :pgsql_data => %w[candlepin foreman], :mongo_data => [] }
|
163
|
+
all_dbs[:pgsql_data] << 'pulpcore' if feature(:pulpcore_database)
|
164
|
+
all_dbs[:mongo_data] << 'mongo' if feature(:mongo)
|
165
|
+
present, absent = dumps_for_hybrid_db_setup(all_dbs)
|
166
|
+
check_file_existence(:present => present, :absent => absent)
|
167
|
+
end
|
168
|
+
|
158
169
|
def fpc_standard_backup?
|
159
170
|
present = []
|
160
171
|
absent = [:candlepin_dump, :foreman_dump, :pulpcore_dump, :mongo_dump]
|
@@ -207,6 +218,15 @@ module ForemanMaintain
|
|
207
218
|
check_file_existence(:present => present, :absent => absent)
|
208
219
|
end
|
209
220
|
|
221
|
+
def fpc_hybrid_db_backup?
|
222
|
+
all_dbs = { :pgsql_data => [], :mongo_data => [] }
|
223
|
+
all_dbs[:pgsql_data] << 'pulpcore' if feature(:pulpcore_database)
|
224
|
+
all_dbs[:mongo_data] << 'mongo' if feature(:mongo)
|
225
|
+
present, absent = dumps_for_hybrid_db_setup(all_dbs)
|
226
|
+
absent.concat [:candlepin_dump, :foreman_dump]
|
227
|
+
check_file_existence(:present => present, :absent => absent)
|
228
|
+
end
|
229
|
+
|
210
230
|
def foreman_standard_backup?
|
211
231
|
check_file_existence(:present => [:pgsql_data],
|
212
232
|
:absent => [:candlepin_dump, :foreman_dump, :pulpcore_dump,
|
@@ -224,21 +244,67 @@ module ForemanMaintain
|
|
224
244
|
:absent => [:candlepin_dump, :mongo_data, :mongo_dump, :pulpcore_dump])
|
225
245
|
end
|
226
246
|
|
247
|
+
# rubocop:disable Metrics/MethodLength
|
248
|
+
def dumps_for_hybrid_db_setup(dbs_hash)
|
249
|
+
present = []
|
250
|
+
absent = []
|
251
|
+
dbs_hash.each do |data_file, dbs|
|
252
|
+
dbs.each do |db|
|
253
|
+
feature_label = db == 'mongo' ? db : "#{db}_database"
|
254
|
+
dump_file = "#{db}_dump"
|
255
|
+
if feature(feature_label.to_sym).local?
|
256
|
+
present |= [data_file]
|
257
|
+
absent << dump_file.to_sym
|
258
|
+
else
|
259
|
+
present << dump_file.to_sym
|
260
|
+
end
|
261
|
+
end
|
262
|
+
absent |= [data_file] unless present.include?(data_file)
|
263
|
+
end
|
264
|
+
[present, absent]
|
265
|
+
end
|
266
|
+
# rubocop:enable Metrics/MethodLength
|
267
|
+
|
227
268
|
def validate_hostname?
|
228
269
|
# make sure that the system hostname is the same as the backup
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
# Incremental backups sometimes don't include httpd.conf. Since a "base" backup
|
234
|
-
# is restored before an incremental, we can assume that the hostname is checked
|
235
|
-
# during the base backup restore
|
236
|
-
if status == 0
|
237
|
-
match = httpd_config.match(/\s*ServerName\s+"*([^ "]+)"*\s*$/)
|
238
|
-
match ? match[1] == hostname : false
|
270
|
+
hostname_from_metadata = metadata.fetch('hostname', nil)
|
271
|
+
if hostname_from_metadata
|
272
|
+
hostname_from_metadata == hostname
|
239
273
|
else
|
240
|
-
|
274
|
+
config_tarball = file_map[:config_files][:path]
|
275
|
+
tar_cmd = "tar zxf #{config_tarball} etc/httpd/conf/httpd.conf --to-stdout --occurrence=1"
|
276
|
+
status, httpd_config = execute_with_status(tar_cmd)
|
277
|
+
|
278
|
+
# Incremental backups sometimes don't include httpd.conf. Since a "base" backup
|
279
|
+
# is restored before an incremental, we can assume that the hostname is checked
|
280
|
+
# during the base backup restore
|
281
|
+
if status == 0
|
282
|
+
match = httpd_config.match(/\s*ServerName\s+"*([^ "]+)"*\s*$/)
|
283
|
+
match ? match[1] == hostname : false
|
284
|
+
else
|
285
|
+
true
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def validate_interfaces
|
291
|
+
# I wanted to do `Socket.getifaddrs.map(&:name).uniq`,
|
292
|
+
# but this has to work with Ruby 2.0, and Socket.getifaddrs is 2.1+
|
293
|
+
errors = {}
|
294
|
+
system_interfaces = Dir.children('/sys/class/net')
|
295
|
+
|
296
|
+
proxy_config = metadata.fetch('proxy_config', {})
|
297
|
+
|
298
|
+
%w[dns dhcp].each do |feature|
|
299
|
+
next unless proxy_config.fetch(feature, false)
|
300
|
+
|
301
|
+
wanted_interface = proxy_config.fetch("#{feature}_interface", 'lo')
|
302
|
+
unless system_interfaces.include?(wanted_interface)
|
303
|
+
errors[feature] = { 'configured' => wanted_interface, 'available' => system_interfaces }
|
304
|
+
end
|
241
305
|
end
|
306
|
+
|
307
|
+
return errors
|
242
308
|
end
|
243
309
|
|
244
310
|
def metadata
|
data/lib/foreman_maintain.rb
CHANGED
@@ -15,6 +15,7 @@ module ForemanMaintain
|
|
15
15
|
require 'foreman_maintain/concerns/finders'
|
16
16
|
require 'foreman_maintain/concerns/metadata'
|
17
17
|
require 'foreman_maintain/concerns/scenario_metadata'
|
18
|
+
require 'foreman_maintain/concerns/os_facts'
|
18
19
|
require 'foreman_maintain/concerns/system_helpers'
|
19
20
|
require 'foreman_maintain/concerns/system_service'
|
20
21
|
require 'foreman_maintain/concerns/hammer'
|
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.
|
4
|
+
version: 0.9.1
|
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-
|
11
|
+
date: 2021-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|
@@ -84,16 +84,30 @@ dependencies:
|
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
103
|
+
version: 0.50.0
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - '='
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
110
|
+
version: 0.50.0
|
97
111
|
description: Provides various features that helps keeping the Foreman/Satellite up
|
98
112
|
and running.
|
99
113
|
email: inecas@redhat.com
|
@@ -134,6 +148,7 @@ files:
|
|
134
148
|
- definitions/checks/foreman/check_corrupted_roles.rb
|
135
149
|
- definitions/checks/foreman/check_duplicate_permission.rb
|
136
150
|
- definitions/checks/foreman/check_duplicate_roles.rb
|
151
|
+
- definitions/checks/foreman/check_https_proxies.rb
|
137
152
|
- definitions/checks/foreman/db_up.rb
|
138
153
|
- definitions/checks/foreman/facts_names.rb
|
139
154
|
- definitions/checks/foreman/puppet_class_duplicates.rb
|
@@ -162,6 +177,7 @@ files:
|
|
162
177
|
- definitions/checks/repositories/validate.rb
|
163
178
|
- definitions/checks/restore/validate_backup.rb
|
164
179
|
- definitions/checks/restore/validate_hostname.rb
|
180
|
+
- definitions/checks/restore/validate_interfaces.rb
|
165
181
|
- definitions/checks/root_user.rb
|
166
182
|
- definitions/checks/server_ping.rb
|
167
183
|
- definitions/checks/services_up.rb
|
@@ -362,6 +378,7 @@ files:
|
|
362
378
|
- lib/foreman_maintain/concerns/hammer.rb
|
363
379
|
- lib/foreman_maintain/concerns/logger.rb
|
364
380
|
- lib/foreman_maintain/concerns/metadata.rb
|
381
|
+
- lib/foreman_maintain/concerns/os_facts.rb
|
365
382
|
- lib/foreman_maintain/concerns/primary_checks.rb
|
366
383
|
- lib/foreman_maintain/concerns/pulp_common.rb
|
367
384
|
- lib/foreman_maintain/concerns/reporter.rb
|
@@ -401,7 +418,6 @@ files:
|
|
401
418
|
- lib/foreman_maintain/utils/disk/io_device.rb
|
402
419
|
- lib/foreman_maintain/utils/disk/nil_device.rb
|
403
420
|
- lib/foreman_maintain/utils/disk/stats.rb
|
404
|
-
- lib/foreman_maintain/utils/facter.rb
|
405
421
|
- lib/foreman_maintain/utils/hash_tools.rb
|
406
422
|
- lib/foreman_maintain/utils/mongo_core.rb
|
407
423
|
- lib/foreman_maintain/utils/response.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module ForemanMaintain::Utils
|
2
|
-
module Facter
|
3
|
-
include ForemanMaintain::Concerns::SystemHelpers
|
4
|
-
|
5
|
-
FACTER_FILES = %w[/usr/bin/facter /opt/puppetlabs/bin/facter].freeze
|
6
|
-
|
7
|
-
def self.package
|
8
|
-
puppet_version = version(execute!('/opt/puppetlabs/bin/puppet --version'))
|
9
|
-
|
10
|
-
puppet_version.major >= 4 ? 'puppet-agent' : 'facter'
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.path
|
14
|
-
FACTER_FILES.find { |path| File.exist?(path) }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|