foreman_maintain 1.12.1 → 1.12.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c68595e8b757aec62c30d2aca14100da46392a4a892d25ed080f6ad57f4a237d
4
- data.tar.gz: 5ad55189dadfd2791e6c40b0ed4248749dab26b45356508191d2b4517497875f
3
+ metadata.gz: b5e95ad904a84a122e5c9d82120299674f55998997acab8c8d29af3848a78d42
4
+ data.tar.gz: 66e3dbc6a9f9862a23d8c9ec0dd82f5fd3e3b856fbf5d3844eadbf448b762284
5
5
  SHA512:
6
- metadata.gz: a4c03cd903549a848cc1b8418eefc643a045df59e6db12b2890347280ec9854f2c6761e54cd9c2410adc81db93c563eb29a034211b5deab8b30f5f88d7386048
7
- data.tar.gz: cc197601d09d86ecd99a56ab13add58ad211e49908b619c4224ecf9c7d4b57903b73ff36928b99110b9876ba72cb468c1c15bf184661de2f772ea1a33a69021d
6
+ metadata.gz: ab607c39722607f8e80a56ffe3406d34bed7c72335bcba543b5fe76c339bc5e12216a588d5dacbc665f943f79b07cd00c293496425c925932d2a6dd9130efc91
7
+ data.tar.gz: '0290ebaa45d7c32847a1d0f92b23dd12f98e0b951c486c10f2cc043d8f53c488085a3f1095e585b70e2db60b9dbb12ad5ee60bcd9eec1741cb269e5ce2b08830'
@@ -5,7 +5,7 @@ module Checks::Container
5
5
  confine do
6
6
  feature(:satellite)&.connected? && feature(:containers)
7
7
  end
8
- description 'Check whether podman is logged in to registry'
8
+ description 'Check whether podman needs to be logged in to the registry'
9
9
  tags :pre_upgrade
10
10
  end
11
11
 
@@ -10,7 +10,7 @@ class Features::Iop < ForemanMaintain::Feature
10
10
 
11
11
  def config_files
12
12
  [
13
- '/var/lib/kafka',
13
+ '/var/lib/containers/storage/volumes/iop-core-kafka-data',
14
14
  '/var/lib/vmaas',
15
15
  ]
16
16
  end
@@ -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 = execute!(podman_command, merge_stderr: false).lines.map do |l|
29
- l.strip.split('=')
30
- end.to_h
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'].start_with?('/var/run/postgresql')
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 = execute!(podman_command, merge_stderr: false).lines.map do |l|
29
- l.strip.split('=')
30
- end.to_h
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'].start_with?('/var/run/postgresql')
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 = execute!(podman_command, merge_stderr: false).lines.map do |l|
29
- l.strip.split('=')
30
- end.to_h
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'].start_with?('/var/run/postgresql')
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 = execute!(podman_command, merge_stderr: false).lines.map do |l|
29
- l.strip.split('=')
30
- end.to_h
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'].start_with?('/var/run/postgresql')
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 = execute!(podman_command, merge_stderr: false).lines.map do |l|
29
- l.strip.split('=')
30
- end.to_h
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'].start_with?('/var/run/postgresql')
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,
@@ -74,8 +74,6 @@ module ForemanMaintain::Scenarios
74
74
  )
75
75
  end
76
76
 
77
- ForemanMaintain.enable_maintenance_module
78
-
79
77
  add_step(Procedures::Packages::Update.new(packages: pkgs_to_update, assumeyes: true,
80
78
  enabled_repos: req_repos_to_update_pkgs))
81
79
  end
@@ -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
@@ -54,10 +54,6 @@ module ForemanMaintain
54
54
  File.exist?('/etc/redhat-release')
55
55
  end
56
56
 
57
- def el8?
58
- el_major_version == 8
59
- end
60
-
61
57
  def debian?
62
58
  os_id == 'debian'
63
59
  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
@@ -12,8 +12,9 @@ module ForemanMaintain::Utils
12
12
  def command(action)
13
13
  all = @options.fetch(:all, false)
14
14
  skip_enablement = @options.fetch(:skip_enablement, false)
15
- if skip_enablement && %w[enable disable].include?(action)
16
- return skip_enablement_message(action, @name)
15
+ if %w[enable disable].include?(action)
16
+ return skip_enablement_message(action, @name) if skip_enablement
17
+ return if generated?
17
18
  end
18
19
 
19
20
  cmd = "systemctl #{action} #{@name}"
@@ -59,6 +60,10 @@ module ForemanMaintain::Utils
59
60
  end
60
61
  end
61
62
 
63
+ def generated?
64
+ service_enabled_status == 'generated'
65
+ end
66
+
62
67
  def matches?(service)
63
68
  if service.is_a? String
64
69
  service == @name || File.fnmatch(service, @name)
@@ -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'
@@ -1,3 +1,3 @@
1
1
  module ForemanMaintain
2
- VERSION = '1.12.1'.freeze
2
+ VERSION = '1.12.3'.freeze
3
3
  end
@@ -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.1
4
+ version: 1.12.3
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