foreman_maintain 1.12.1 → 1.12.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/definitions/features/iop.rb +1 -1
- data/definitions/features/iop_advisor_database.rb +11 -4
- data/definitions/features/iop_inventory_database.rb +11 -4
- data/definitions/features/iop_remediations_database.rb +11 -4
- data/definitions/features/iop_vmaas_database.rb +11 -4
- data/definitions/features/iop_vulnerability_database.rb +11 -4
- data/definitions/scenarios/foreman_upgrade.rb +0 -4
- data/definitions/scenarios/satellite_upgrade.rb +0 -6
- data/definitions/scenarios/self_upgrade.rb +0 -2
- data/lib/foreman_maintain/cli/report_command.rb +1 -66
- data/lib/foreman_maintain/concerns/os_facts.rb +0 -4
- data/lib/foreman_maintain/utils/report_condenser.rb +72 -0
- data/lib/foreman_maintain/utils.rb +1 -0
- data/lib/foreman_maintain/version.rb +1 -1
- data/lib/foreman_maintain.rb +0 -14
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 841269b0b17944b3a732b728e7c51ba5c11bdec27b47c45ce6b13fb61ec8be06
|
4
|
+
data.tar.gz: 966dd22a328585cb68ecb248341b8b566787f7efa6f590eb8dc1877203fdc895
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f996ba857e7ad9598f6b4e26811710387d8592c2841bb26dbf63660d44774c388312ab217d795dbd24c258767b3c276b048f13ced797927703dd6c85dbde106f
|
7
|
+
data.tar.gz: 72cc8e83ee3ff2fb76fdcaa226695c05b90fe70ed63bb82b7d65e8307d82cbab6b6141b51a8f5ceaac410648d41f9308744998b255a9ab2e9f8bf43b0d50d8fa
|
data/definitions/features/iop.rb
CHANGED
@@ -23,13 +23,19 @@ class Features::IopAdvisorDatabase < ForemanMaintain::Feature
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
+
# rubocop:disable Metrics/MethodLength
|
26
27
|
def load_configuration
|
27
28
|
podman_command = "podman exec iop-service-advisor-backend-api bash -c 'env |grep DB_'"
|
28
|
-
podman_result =
|
29
|
-
|
30
|
-
|
29
|
+
podman_result = begin
|
30
|
+
execute!(podman_command, merge_stderr: false).lines.map do |l|
|
31
|
+
l.strip.split('=')
|
32
|
+
end.to_h
|
33
|
+
rescue ForemanMaintain::Error::ExecutionError
|
34
|
+
{}
|
35
|
+
end
|
31
36
|
|
32
|
-
db_host = if podman_result['ADVISOR_DB_HOST'].
|
37
|
+
db_host = if podman_result['ADVISOR_DB_HOST'].nil? ||
|
38
|
+
podman_result['ADVISOR_DB_HOST'].start_with?('/var/run/postgresql')
|
33
39
|
'localhost'
|
34
40
|
else
|
35
41
|
podman_result['ADVISOR_DB_HOST']
|
@@ -42,4 +48,5 @@ class Features::IopAdvisorDatabase < ForemanMaintain::Feature
|
|
42
48
|
'username' => podman_result['ADVISOR_DB_USER'],
|
43
49
|
}
|
44
50
|
end
|
51
|
+
# rubocop:enable Metrics/MethodLength
|
45
52
|
end
|
@@ -23,13 +23,19 @@ class Features::IopInventoryDatabase < ForemanMaintain::Feature
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
+
# rubocop:disable Metrics/MethodLength
|
26
27
|
def load_configuration
|
27
28
|
podman_command = "podman exec iop-core-host-inventory bash -c 'env |grep INVENTORY_DB_'"
|
28
|
-
podman_result =
|
29
|
-
|
30
|
-
|
29
|
+
podman_result = begin
|
30
|
+
execute!(podman_command, merge_stderr: false).lines.map do |l|
|
31
|
+
l.strip.split('=')
|
32
|
+
end.to_h
|
33
|
+
rescue ForemanMaintain::Error::ExecutionError
|
34
|
+
{}
|
35
|
+
end
|
31
36
|
|
32
|
-
db_host = if podman_result['INVENTORY_DB_HOST'].
|
37
|
+
db_host = if podman_result['INVENTORY_DB_HOST'].nil? ||
|
38
|
+
podman_result['INVENTORY_DB_HOST'].start_with?('/var/run/postgresql')
|
33
39
|
'localhost'
|
34
40
|
else
|
35
41
|
podman_result['INVENTORY_DB_HOST']
|
@@ -42,4 +48,5 @@ class Features::IopInventoryDatabase < ForemanMaintain::Feature
|
|
42
48
|
'username' => podman_result['INVENTORY_DB_USER'],
|
43
49
|
}
|
44
50
|
end
|
51
|
+
# rubocop:enable Metrics/MethodLength
|
45
52
|
end
|
@@ -23,13 +23,19 @@ class Features::IopRemediationsDatabase < ForemanMaintain::Feature
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
+
# rubocop:disable Metrics/MethodLength
|
26
27
|
def load_configuration
|
27
28
|
podman_command = "podman exec iop-service-remediations-api bash -c 'env |grep DB_'"
|
28
|
-
podman_result =
|
29
|
-
|
30
|
-
|
29
|
+
podman_result = begin
|
30
|
+
execute!(podman_command, merge_stderr: false).lines.map do |l|
|
31
|
+
l.strip.split('=')
|
32
|
+
end.to_h
|
33
|
+
rescue ForemanMaintain::Error::ExecutionError
|
34
|
+
{}
|
35
|
+
end
|
31
36
|
|
32
|
-
db_host = if podman_result['DB_HOST'].
|
37
|
+
db_host = if podman_result['DB_HOST'].nil? ||
|
38
|
+
podman_result['DB_HOST'].start_with?('/var/run/postgresql')
|
33
39
|
'localhost'
|
34
40
|
else
|
35
41
|
podman_result['DB_HOST']
|
@@ -42,4 +48,5 @@ class Features::IopRemediationsDatabase < ForemanMaintain::Feature
|
|
42
48
|
'username' => podman_result['DB_USERNAME'],
|
43
49
|
}
|
44
50
|
end
|
51
|
+
# rubocop:enable Metrics/MethodLength
|
45
52
|
end
|
@@ -23,13 +23,19 @@ class Features::IopVmaasDatabase < ForemanMaintain::Feature
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
+
# rubocop:disable Metrics/MethodLength
|
26
27
|
def load_configuration
|
27
28
|
podman_command = "podman exec iop-service-vmaas-reposcan bash -c 'env |grep POSTGRESQL_'"
|
28
|
-
podman_result =
|
29
|
-
|
30
|
-
|
29
|
+
podman_result = begin
|
30
|
+
execute!(podman_command, merge_stderr: false).lines.map do |l|
|
31
|
+
l.strip.split('=')
|
32
|
+
end.to_h
|
33
|
+
rescue ForemanMaintain::Error::ExecutionError
|
34
|
+
{}
|
35
|
+
end
|
31
36
|
|
32
|
-
db_host = if podman_result['POSTGRESQL_HOST'].
|
37
|
+
db_host = if podman_result['POSTGRESQL_HOST'].nil? ||
|
38
|
+
podman_result['POSTGRESQL_HOST'].start_with?('/var/run/postgresql')
|
33
39
|
'localhost'
|
34
40
|
else
|
35
41
|
podman_result['POSTGRESQL_HOST']
|
@@ -42,4 +48,5 @@ class Features::IopVmaasDatabase < ForemanMaintain::Feature
|
|
42
48
|
'username' => podman_result['POSTGRESQL_USER'],
|
43
49
|
}
|
44
50
|
end
|
51
|
+
# rubocop:enable Metrics/MethodLength
|
45
52
|
end
|
@@ -23,13 +23,19 @@ class Features::IopVulnerabilityDatabase < ForemanMaintain::Feature
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
+
# rubocop:disable Metrics/MethodLength
|
26
27
|
def load_configuration
|
27
28
|
podman_command = "podman exec iop-service-vuln-manager bash -c 'env |grep POSTGRES_'"
|
28
|
-
podman_result =
|
29
|
-
|
30
|
-
|
29
|
+
podman_result = begin
|
30
|
+
execute!(podman_command, merge_stderr: false).lines.map do |l|
|
31
|
+
l.strip.split('=')
|
32
|
+
end.to_h
|
33
|
+
rescue ForemanMaintain::Error::ExecutionError
|
34
|
+
{}
|
35
|
+
end
|
31
36
|
|
32
|
-
db_host = if podman_result['POSTGRES_HOST'].
|
37
|
+
db_host = if podman_result['POSTGRES_HOST'].nil? ||
|
38
|
+
podman_result['POSTGRES_HOST'].start_with?('/var/run/postgresql')
|
33
39
|
'localhost'
|
34
40
|
else
|
35
41
|
podman_result['POSTGRES_HOST']
|
@@ -42,4 +48,5 @@ class Features::IopVulnerabilityDatabase < ForemanMaintain::Feature
|
|
42
48
|
'username' => podman_result['POSTGRES_USER'],
|
43
49
|
}
|
44
50
|
end
|
51
|
+
# rubocop:enable Metrics/MethodLength
|
45
52
|
end
|
@@ -90,10 +90,6 @@ module Scenarios::Foreman
|
|
90
90
|
|
91
91
|
def compose
|
92
92
|
add_step(Procedures::Repositories::Setup.new(:version => 'nightly'))
|
93
|
-
if el8?
|
94
|
-
modules_to_switch = ['postgresql:13']
|
95
|
-
add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch))
|
96
|
-
end
|
97
93
|
|
98
94
|
add_step(Procedures::Packages::Update.new(
|
99
95
|
:assumeyes => true,
|
@@ -92,12 +92,6 @@ module Scenarios::Satellite
|
|
92
92
|
|
93
93
|
def compose
|
94
94
|
add_step(Procedures::Repositories::Setup.new(:version => target_version))
|
95
|
-
if el8?
|
96
|
-
modules_to_switch = ['postgresql:13']
|
97
|
-
add_step(Procedures::Packages::SwitchModules.new(:module_names => modules_to_switch))
|
98
|
-
modules_to_enable = ["#{feature(:instance).downstream.module_name}:#{el_short_name}"]
|
99
|
-
add_step(Procedures::Packages::EnableModules.new(:module_names => modules_to_enable))
|
100
|
-
end
|
101
95
|
add_steps(
|
102
96
|
Procedures::Packages::Update.new(
|
103
97
|
:assumeyes => true,
|
@@ -45,76 +45,11 @@ module ForemanMaintain
|
|
45
45
|
generate_report
|
46
46
|
end
|
47
47
|
|
48
|
-
report = condense_report(data)
|
48
|
+
report = Utils::ReportCondenser.condense_report(data)
|
49
49
|
report = prefix_keys(report)
|
50
50
|
save_report(JSON.dump(report), @output)
|
51
51
|
end
|
52
52
|
|
53
|
-
def condense_report(data)
|
54
|
-
result = {}
|
55
|
-
%w[advisor_on_prem_remediations_count rhel_ai_workload_host_count].each do |key|
|
56
|
-
result[key] = data[key] || 0
|
57
|
-
end
|
58
|
-
result.merge!(aggregate_host_count(data))
|
59
|
-
result.merge!(aggregate_image_mode_host_count(data))
|
60
|
-
result.merge!(aggregate_networking_metrics(data))
|
61
|
-
result
|
62
|
-
end
|
63
|
-
|
64
|
-
# Aggregates the host count numbers. The goal is to distinguish
|
65
|
-
# - RHEL hosts
|
66
|
-
# - RedHat family but not RHEL hosts
|
67
|
-
# - Other hosts
|
68
|
-
def aggregate_host_count(data)
|
69
|
-
result = {}
|
70
|
-
rhel_count = data['hosts_by_os_count|RedHat'] || 0
|
71
|
-
rh_count = data['hosts_by_family_count|Redhat'] || 0
|
72
|
-
result['host_rhel_count'] = rhel_count
|
73
|
-
result['host_redhat_count'] = rh_count - rhel_count
|
74
|
-
result['host_other_count'] = data.select do |k, _|
|
75
|
-
k.start_with?('hosts_by_os_count')
|
76
|
-
end.values.sum - rhel_count - rh_count
|
77
|
-
result
|
78
|
-
end
|
79
|
-
|
80
|
-
def aggregate_image_mode_host_count(data)
|
81
|
-
count = data.select { |k, _| k.start_with?('image_mode_hosts_by_os_count') }.values.sum
|
82
|
-
{ 'image_mode_host_count' => count }
|
83
|
-
end
|
84
|
-
|
85
|
-
def aggregate_networking_metrics(data)
|
86
|
-
ipv6 = any_positive?(data, %w[subnet_ipv6_count hosts_with_ipv6only_interface_count
|
87
|
-
foreman_interfaces_ipv6only_count])
|
88
|
-
# Deployment is considered to run in dualstack mode if:
|
89
|
-
# - Foreman has both ipv6 and ipv4 addresses on a single interface
|
90
|
-
# - or if any host in Foreman has both ipv6 and ipv4 addresses on a single interface
|
91
|
-
dualstack = any_positive?(data, %w[hosts_with_dualstack_interface_count
|
92
|
-
foreman_interfaces_dualstack_count])
|
93
|
-
|
94
|
-
# - or if there are both ipv4 and ipv6 subnets defined
|
95
|
-
dualstack |= all_positive?(data, %w[subnet_ipv4_count subnet_ipv6_count])
|
96
|
-
|
97
|
-
# - or if any host in Foreman has an interface with only an ipv4 address
|
98
|
-
# as well as another interface with ipv6 address
|
99
|
-
dualstack |= all_positive?(data, %w[hosts_with_ipv4only_interface_count
|
100
|
-
hosts_with_ipv6only_interface_count])
|
101
|
-
|
102
|
-
# - or if Foreman has an interface with only an ipv4 address
|
103
|
-
# as well as another interface with ipv6 address
|
104
|
-
dualstack |= all_positive?(data,
|
105
|
-
%w[foreman_interfaces_ipv4only_count foreman_interfaces_ipv6only_count])
|
106
|
-
|
107
|
-
{ 'use_dualstack' => dualstack, 'use_ipv6' => ipv6 }
|
108
|
-
end
|
109
|
-
|
110
|
-
def all_positive?(source, keys)
|
111
|
-
source.values_at(*keys).map { |x| x || 0 }.all?(&:positive?)
|
112
|
-
end
|
113
|
-
|
114
|
-
def any_positive?(source, keys)
|
115
|
-
source.values_at(*keys).map { |x| x || 0 }.any?(&:positive?)
|
116
|
-
end
|
117
|
-
|
118
53
|
def prefix_keys(data)
|
119
54
|
data.transform_keys { |key| 'foreman.' + key }
|
120
55
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module ForemanMaintain::Utils
|
2
|
+
module ReportCondenser
|
3
|
+
class << self
|
4
|
+
def condense_report(data)
|
5
|
+
result = {}
|
6
|
+
%w[advisor_on_prem_remediations_count rhel_ai_workload_host_count].each do |key|
|
7
|
+
result[key] = data[key] || 0
|
8
|
+
end
|
9
|
+
result.merge!(aggregate_host_count(data))
|
10
|
+
result.merge!(aggregate_image_mode_host_count(data))
|
11
|
+
result.merge!(aggregate_networking_metrics(data))
|
12
|
+
result
|
13
|
+
end
|
14
|
+
|
15
|
+
# Aggregates the host count numbers. The goal is to distinguish
|
16
|
+
# - RHEL hosts
|
17
|
+
# - RedHat family but not RHEL hosts
|
18
|
+
# - Other hosts
|
19
|
+
def aggregate_host_count(data)
|
20
|
+
result = {}
|
21
|
+
rhel_count = data['hosts_by_os_count|RedHat'] || 0
|
22
|
+
rh_count = data['hosts_by_family_count|Redhat'] || 0
|
23
|
+
result['host_rhel_count'] = rhel_count
|
24
|
+
result['host_redhat_without_rhel_count'] = rh_count - rhel_count
|
25
|
+
result['host_other_count'] = data.select do |k, _|
|
26
|
+
k.start_with?('hosts_by_os_count')
|
27
|
+
end.values.sum - rh_count
|
28
|
+
result
|
29
|
+
end
|
30
|
+
|
31
|
+
def aggregate_image_mode_host_count(data)
|
32
|
+
count = data.select { |k, _| k.start_with?('image_mode_hosts_by_os_count') }.values.sum
|
33
|
+
{ 'image_mode_host_count' => count }
|
34
|
+
end
|
35
|
+
|
36
|
+
def aggregate_networking_metrics(data)
|
37
|
+
ipv6 = any_positive?(data, %w[subnet_ipv6_count hosts_with_ipv6only_interface_count
|
38
|
+
foreman_interfaces_ipv6only_count])
|
39
|
+
# Deployment is considered to run in dualstack mode if:
|
40
|
+
# - Foreman has both ipv6 and ipv4 addresses on a single interface
|
41
|
+
# - or if any host in Foreman has both ipv6 and ipv4 addresses on a single interface
|
42
|
+
dualstack = any_positive?(data, %w[hosts_with_dualstack_interface_count
|
43
|
+
foreman_interfaces_dualstack_count])
|
44
|
+
|
45
|
+
# - or if there are both ipv4 and ipv6 subnets defined
|
46
|
+
dualstack |= all_positive?(data, %w[subnet_ipv4_count subnet_ipv6_count])
|
47
|
+
|
48
|
+
# - or if any host in Foreman has an interface with only an ipv4 address
|
49
|
+
# as well as another interface with ipv6 address
|
50
|
+
dualstack |= all_positive?(data, %w[hosts_with_ipv4only_interface_count
|
51
|
+
hosts_with_ipv6only_interface_count])
|
52
|
+
|
53
|
+
# - or if Foreman has an interface with only an ipv4 address
|
54
|
+
# as well as another interface with ipv6 address
|
55
|
+
dualstack |= all_positive?(data,
|
56
|
+
%w[foreman_interfaces_ipv4only_count foreman_interfaces_ipv6only_count])
|
57
|
+
|
58
|
+
{ 'use_dualstack' => dualstack, 'use_ipv6' => ipv6 }
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def all_positive?(source, keys)
|
64
|
+
source.values_at(*keys).map { |x| x || 0 }.all?(&:positive?)
|
65
|
+
end
|
66
|
+
|
67
|
+
def any_positive?(source, keys)
|
68
|
+
source.values_at(*keys).map { |x| x || 0 }.any?(&:positive?)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -4,5 +4,6 @@ require 'foreman_maintain/utils/disk'
|
|
4
4
|
require 'foreman_maintain/utils/bash'
|
5
5
|
require 'foreman_maintain/utils/hash_tools'
|
6
6
|
require 'foreman_maintain/utils/curl_response'
|
7
|
+
require 'foreman_maintain/utils/report_condenser'
|
7
8
|
require 'foreman_maintain/utils/service'
|
8
9
|
require 'foreman_maintain/utils/system_helpers'
|
data/lib/foreman_maintain.rb
CHANGED
@@ -191,7 +191,6 @@ module ForemanMaintain
|
|
191
191
|
|
192
192
|
puts "Checking for new version of #{packages_to_update_str}..."
|
193
193
|
|
194
|
-
enable_maintenance_module
|
195
194
|
package_manager = ForemanMaintain.package_manager
|
196
195
|
|
197
196
|
if package_manager.update_available?(packages_to_update)
|
@@ -204,19 +203,6 @@ module ForemanMaintain
|
|
204
203
|
puts "Nothing to update, can't find new version of #{packages_to_update_str}."
|
205
204
|
end
|
206
205
|
|
207
|
-
def enable_maintenance_module
|
208
|
-
return unless el8?
|
209
|
-
|
210
|
-
maintenance_module = 'satellite-maintenance:el8'
|
211
|
-
package_manager = ForemanMaintain.package_manager
|
212
|
-
|
213
|
-
if package_manager.module_exists?(maintenance_module) &&
|
214
|
-
!package_manager.module_enabled?(maintenance_module)
|
215
|
-
puts "\nEnabling #{maintenance_module} module"
|
216
|
-
package_manager.enable_module(maintenance_module)
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
206
|
def main_package_name
|
221
207
|
el? ? 'rubygem-foreman_maintain' : 'ruby-foreman-maintain'
|
222
208
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_maintain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
@@ -445,6 +445,7 @@ files:
|
|
445
445
|
- lib/foreman_maintain/utils/disk/nil_device.rb
|
446
446
|
- lib/foreman_maintain/utils/disk/stats.rb
|
447
447
|
- lib/foreman_maintain/utils/hash_tools.rb
|
448
|
+
- lib/foreman_maintain/utils/report_condenser.rb
|
448
449
|
- lib/foreman_maintain/utils/response.rb
|
449
450
|
- lib/foreman_maintain/utils/service.rb
|
450
451
|
- lib/foreman_maintain/utils/service/abstract.rb
|