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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'manifests/install/package.pp', line 3
class apptainer::install::package {
assert_private()
if $facts['os']['family'] == 'RedHat' {
$source = "https://github.com/apptainer/apptainer/releases/download/v${apptainer::version}/apptainer-${apptainer::version}-1.x86_64.rpm"
$source_suid = "https://github.com/apptainer/apptainer/releases/download/v${apptainer::version}/apptainer-suid-${apptainer::version}-1.x86_64.rpm"
if $facts['apptainer_version'] {
if versioncmp($apptainer::version, $facts['apptainer_version']) < 0 {
$action = 'downgrade'
} else {
$action = 'install'
}
} else {
$action = 'install'
}
exec { "${action}-apptainer":
path => '/usr/bin:/bin:/usr/sbin:/sbin',
command => "${facts['package_provider']} ${action} -y ${source}",
unless => "rpm -q 'apptainer-${apptainer::version}'",
}
if $apptainer::install_setuid {
exec { "${action}-apptainer-suid":
path => '/usr/bin:/bin:/usr/sbin:/sbin',
command => "${facts['package_provider']} ${action} -y ${source_suid}",
unless => "rpm -q 'apptainer-suid-${apptainer::version}'",
}
}
} elsif $facts['os']['family'] == 'Debian' {
$source = "https://github.com/apptainer/apptainer/releases/download/v${apptainer::version}/apptainer_${apptainer::version}_amd64.deb"
$source_path = "/usr/local/src/apptainer_${apptainer::version}_amd64.deb"
$source_suid = "https://github.com/apptainer/apptainer/releases/download/v${apptainer::version}/apptainer-suid_${apptainer::version}_amd64.deb"
$source_suid_path = "/usr/local/src/apptainer-suid_${apptainer::version}_amd64.deb"
archive { $source_path:
source => $source,
extract => false,
cleanup => false,
user => 'root',
group => 'root',
}
exec { 'install-apptainer':
path => '/usr/bin:/bin:/usr/sbin:/sbin',
command => "apt install --force-yes -y ${source_path}",
environment => [
'DEBIAN_FRONTEND=noninteractive',
],
unless => "dpkg -s apptainer | grep 'Version: ${apptainer::version}'",
}
if $apptainer::install_setuid {
archive { $source_suid_path:
source => $source_suid,
extract => false,
cleanup => false,
user => 'root',
group => 'root',
}
exec { 'install-apptainer-suid':
path => '/usr/bin:/bin:/usr/sbin:/sbin',
command => "apt install --force-yes -y ${source_suid_path}",
environment => [
'DEBIAN_FRONTEND=noninteractive',
],
unless => "dpkg -s apptainer-suid | grep 'Version: ${apptainer::version}'",
}
}
} else {
fail('Module apptainer only supports package installs on RedHat or Debian os family')
}
}
|