-
Notifications
You must be signed in to change notification settings - Fork 48
/
service.pp
89 lines (85 loc) · 2.71 KB
/
service.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
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
# == Define: swift::service
#
# Wrapper class to configure swift service providers
#
# === Parameters:
#
# [*title*] The name of the swift service to manage
# Mandatory. ex: 'swift-object-server' valid names
# are listed in swift::params.pp at $swift_init_service_names
#
# [*os_family_service_name*]
# (required) The distribution specific service name.
#
# [*config_file_name*]
# (required) The service configuration file name.
# Starting at the path "/etc/swift/" ex:"object-server.conf"
#
# [*service_ensure*]
# (optional) State of service to ensure, running or stopped.
# Default: undef
#
# [*enabled*]
# (optional) Should the service be enabled to start
# at boot. Default: true
#
# [*service_provider*]
# (optional)
# To use the swiftinit service provider to manage swift services, set
# service_provider to "swiftinit". When enable is true the provider
# will populate boot files that start swift using swift-init at boot.
# See README for more details.
# Defaults to $::swift::params::service_provider.
#
# [*service_subscribe*]
# (optional) Parameter used to pass in resources that this service should
# subscribe to.
#
# [*service_require*]
# (optional) Parameter used to pass in resources that this service requires.
#
# [*service_tag*]
# (optional) Additional tag to be added to the service resource
#
define swift::service(
String[1] $os_family_service_name,
String[1] $config_file_name,
$service_ensure = undef,
Boolean $enabled = true,
Swift::ServiceProvider $service_provider = $::swift::params::service_provider,
$service_subscribe = undef,
$service_require = undef,
Optional[String[1]] $service_tag = undef,
) {
include swift::deps
include swift::params
if(! member($::swift::params::swift_init_service_names, $name)) {
fail("swift::service name: ${name} is not a valid swift_init_service_name")
}
$tag = delete_undef_values(['swift-service', $service_tag])
if $service_provider != 'swiftinit' {
service { $name:
ensure => $service_ensure,
name => $os_family_service_name,
hasstatus => true,
enable => $enabled,
provider => $service_provider,
tag => $tag,
subscribe => $service_subscribe,
require => $service_require,
}
} else {
service { $name:
ensure => $service_ensure,
enable => $enabled,
hasstatus => true,
hasrestart => true,
provider => 'swiftinit',
pattern => $os_family_service_name,
manifest => $config_file_name,
tag => $tag,
subscribe => $service_subscribe,
require => $service_require,
}
}
}