-
Notifications
You must be signed in to change notification settings - Fork 269
/
plugin.pp
59 lines (57 loc) · 1.65 KB
/
plugin.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
49
50
51
52
53
54
55
56
57
58
59
# @summary Manages a plugin installation and optionally its configuration
#
# @param version
# The version to ensure
#
# @param package
# The package to manage
#
# @param config
# Content of the configg
#
# @param config_file
# The path to the config file. Only relevant if `config` is given.
#
# @param config_file_mode
# The mode of the config file. Only relevant if `config` is given.
#
# @param config_file_owner
# The owner of the config file. Only relevant if `config` is given.
#
# @param config_file_group
# The mode of the config file. Only relevant if `config` is given.
define foreman::plugin(
String[1] $version = $foreman::plugin_version,
String[1] $package = "${foreman::plugin_prefix}${title}",
Stdlib::Absolutepath $config_file = "${foreman::plugin_config_dir}/foreman_${title}.yaml",
String[1] $config_file_owner = 'root',
String[1] $config_file_group = $foreman::group,
Stdlib::Filemode $config_file_mode = '0640',
Optional[String] $config = undef,
) {
# Debian gem2deb converts underscores to hyphens
case $facts['os']['family'] {
'Debian': {
$real_package = regsubst($package,'_','-','G')
}
default: {
$real_package = $package
}
}
package { $real_package:
ensure => $version,
}
~> Foreman::Rake['apipie:cache:index', 'apipie_dsl:cache']
if $config {
file { $config_file:
ensure => file,
owner => $config_file_owner,
group => $config_file_group,
mode => $config_file_mode,
content => $config,
require => Package[$real_package],
}
}
Foreman::Plugin[$name] -> Class['foreman::database']
Foreman::Plugin[$name] ~> Class['foreman::service']
}