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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'manifests/plugin.pp', line 19
define singularity::plugin (
Enum['present', 'absent'] $ensure = 'present',
Optional[String] $source_dir = undef,
Optional[String] $sif_name = undef,
) {
include singularity
if $singularity::install_method != 'source' {
fail("Define singularity::plugin ${name} can only be done for source installation")
}
if $ensure == 'present' and $source_dir =~ Undef {
fail("Define singularity::plugin ${name} must define source_dir")
}
$exec_path = "${singularity::prefix}/bin:${singularity::source_exec_path}"
if $ensure == 'present' {
$basename = split($name, '/')[-1]
$_sif_name = pick($sif_name, "${basename}.sif")
$sif_path = "${singularity::install::source::source_dir}/${source_dir}/${_sif_name}"
if $singularity::manage_go and $singularity::rebuild_on_go {
Class['golang'] ~> Exec["singularity-plugin-recompile-${name}"]
}
exec { "singularity-plugin-compile-${name}":
path => $exec_path,
environment => $singularity::install::source::build_env,
command => "singularity plugin compile ${source_dir}",
cwd => $singularity::install::source::source_dir,
creates => $sif_path,
require => Class['singularity::install::source'],
}
exec { "singularity-plugin-recompile-${name}":
path => $exec_path,
environment => $singularity::install::source::build_env,
command => "singularity plugin compile ${source_dir}",
cwd => $singularity::install::source::source_dir,
onlyif => "test -f ${sif_path}",
refreshonly => true,
require => Class['singularity::install::source'],
notify => Exec["singularity-plugin-reinstall-${name}"],
}
exec { "singularity-plugin-install-${name}":
path => $exec_path,
command => "singularity plugin install ${sif_path}",
unless => "singularity plugin list | grep '${name}'",
require => Exec["singularity-plugin-compile-${name}"],
}
exec { "singularity-plugin-reinstall-${name}":
path => $exec_path,
command => "singularity plugin install ${sif_path}",
onlyif => "singularity plugin list | grep '${name}'",
refreshonly => true,
subscribe => Exec["singularity-plugin-compile-${name}"],
}
exec { "singularity-plugin-enable-${name}":
path => $exec_path,
command => "singularity plugin enable ${name}",
unless => "singularity plugin list | grep '${name}' | grep yes",
require => [
Exec["singularity-plugin-install-${name}"],
Exec["singularity-plugin-reinstall-${name}"],
],
}
} else {
exec { "singularity-plugin-uninstall-${name}":
path => $exec_path,
command => "singularity plugin uninstall ${name}",
onlyif => "singularity plugin list | grep '${name}'",
}
}
}
|