forked from CERIT-SC/puppet-yum
-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
install.pp
48 lines (46 loc) · 1.23 KB
/
install.pp
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
42
43
44
45
46
47
48
# Define: yum::install
#
# This definition installs or removes rpms from local file or URL via
# yum install command. This can be better than using just the rpm
# provider because it will pull all the dependencies.
#
# Parameters:
# [*ensure*] - specifies if package group should be
# present (installed) or absent (purged)
# [*source*] - file or URL where RPM is available
#
# Actions:
#
# Requires:
# RPM based system
#
# Sample usage:
# yum::install { 'epel-release':
# ensure => 'present',
# source => 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm',
# }
#
define yum::install (
String $source,
Enum['present', 'installed', 'absent', 'purged'] $ensure = 'present',
Optional[Integer] $timeout = undef,
) {
Exec {
path => '/bin:/usr/bin:/sbin:/usr/sbin',
environment => 'LC_ALL=C',
}
case $ensure {
'present', 'installed', default: {
exec { "yum-install-${name}":
command => "yum -y install '${source}'",
unless => "rpm -q '${name}'",
timeout => $timeout,
}
}
'absent', 'purged': {
package { $name:
ensure => $ensure,
}
}
}
}