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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'plans/preflight/oscheck.pp', line 7
plan complyadm::preflight::oscheck(
Complyadm::Config $config = complyadm::config(),
) {
$supported_versions = {
'ubuntu' => [
'18.04',
'20.04',
'22.04',
],
'rhel' => [
'7',
'8',
'9',
],
'sles' => [
'12',
'15',
],
'redhat' => [
'7',
'8',
'9',
],
'rocky' => [
'8',
],
'almalinux' => [
'8',
],
'oraclelinux' => [
'8',
],
}
$supported_platform_arch = ['amd64', 'x86_64']
$targets = $config['all_targets']
$results = $targets.reduce({ 'passed' => [], 'failed' => [] }) |$memo, $target| {
$facts_hash = $target.facts
$name = $facts_hash['os']['name']
$major = $facts_hash['os']['release']['major']
$platform_arch = $facts_hash['os']['architecture']
$arch_supported = $supported_platform_arch.any |$expected| { $expected == $platform_arch }
if(!$supported_versions[$name.downcase] or !$supported_versions[$name.downcase].member($major) or !arch_supported) {
$failed = $memo['failed'] << "${target} : found ${name} ${major} (${platform_arch})"
$memo + { 'failed' => $failed }
} else {
$passed = $memo['passed'] << "${target} : found ${name} ${major} (${platform_arch})"
$memo + { 'passed' => $passed }
}
}
return $results
}
|