-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathcheck_subscription_manager_release.rb
More file actions
41 lines (32 loc) · 1.23 KB
/
check_subscription_manager_release.rb
File metadata and controls
41 lines (32 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Checks::CheckSubscriptionManagerRelease < ForemanMaintain::Check
metadata do
label :check_subscription_manager_release
description 'Check if subscription-manager release is not set to a minor version'
confine do
feature(:instance).downstream
end
end
def run
status, output = execute_with_status('LC_ALL=C subscription-manager release --show')
# If command fails (subscription-manager not installed or system not registered), pass the check
return if status != 0
assert(valid_release?(output), error_message(output))
end
private
def valid_release?(output)
# Valid formats: "Release not set" or "Release: X" where X is a major version without dots
return true if output == 'Release not set'
return true if /^Release:\s+\d+$/.match?(output)
false
end
def extract_release(output)
match = output.match(/^Release:\s+(.+)$/)
match ? match[1] : output
end
def error_message(output)
subman_release = extract_release(output)
"Your system is configured to use RHEL #{subman_release}, but Satellite is only "\
"supported on the latest RHEL. Please unset the release in subscription-manager by "\
"calling `subscription-manager release --unset`."
end
end