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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'manifests/extpack.pp', line 31
define virtualbox::extpack (
String $source,
Enum['present', 'absent'] $ensure = 'present',
Boolean $verify_checksum = true,
Optional[String] $checksum_string = undef,
Enum['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'] $checksum_type = 'md5',
Boolean $follow_redirects = false,
Stdlib::Absolutepath $extpack_path = '/usr/lib/virtualbox/ExtensionPacks',
Optional[Enum['puppet','puppet-community','voxpupuli','camptocamp']] $archive_provider = undef,
) {
if $verify_checksum {
$_checksum_type = $checksum_type
$_checksum_string = $checksum_string
} else {
$_checksum_type = undef
$_checksum_string = undef
}
$dest = "${extpack_path}/${name}"
if $archive_provider {
$valid_archive_provider = $archive_provider
} else {
$metadata = load_module_metadata('archive')
$valid_archive_provider = $metadata['source'] ? {
/github\.com\/camptocamp/ => 'camptocamp',
/github\.com\/(puppet-community|voxpupuli)/ => 'voxpupuli',
}
}
case $valid_archive_provider {
'camptocamp': {
warning 'Support for module camptocamp/archive is deprecated. Futur version of this module will only support puppet/archive.'
archive::download { "${name}.tgz":
ensure => $ensure,
url => $source,
checksum => $verify_checksum,
digest_type => $_checksum_type,
digest_string => $_checksum_string,
follow_redirects => $follow_redirects,
require => Class['virtualbox'],
}
if $ensure =~ /^present$/ {
Archive::Download["${name}.tgz"] -> Exec["${name} unpack"]
}
}
/^(voxpupuli|puppet-community|puppet)$/: {
unless $follow_redirects {
warning("The puppet/archive module does not support the \$follow_redirects parameter.")
}
archive { "/usr/src/${name}.tgz":
ensure => $ensure,
source => $source,
checksum => $_checksum_string,
checksum_type => $_checksum_type,
checksum_verify => $verify_checksum,
extract => false,
require => Class['virtualbox'],
}
if $ensure =~ /^present$/ {
Archive["/usr/src/${name}.tgz"] -> Exec["${name} unpack"]
}
}
default: { fail('Unknown Archive module. Please install puppet/archive or camptocamp/archive.') }
}
case $ensure {
'present': {
exec { "${name} unpack":
command => "mkdir -p ${dest} && tar --no-same-owner --no-same-permissions -xzf /usr/src/${name}.tgz -C ${dest}",
creates => $dest,
timeout => 120,
path => $::path,
}
}
'absent': {
file { $dest:
ensure => absent,
recurse => true,
purge => true,
force => true,
}
}
default: { fail('Unknown value for $ensure.') }
}
}
|