forked from cblument/puppetlabs-nova
/
generic_service.pp
56 lines (49 loc) · 1.31 KB
/
generic_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
#
# This class implements basic nova services.
# It is introduced to attempt to consolidate
# common code.
#
# It also allows users to specify ad-hoc services
# as needed
#
#
# This define creates a service resource with title nova-${name} and
# conditionally creates a package resource with title nova-${name}
#
define nova::generic_service(
$package_name,
$service_name,
$enabled = false,
$ensure_package = 'present'
) {
include nova::params
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
$nova_title = "nova-${name}"
# ensure that the service is only started after
# all nova config entries have been set
Exec['post-nova_config'] ~> Service<| title == $nova_title |>
# ensure that the service has only been started
# after the initial db sync
Exec<| title == 'nova-db-sync' |> ~> Service<| title == $nova_title |>
# I need to mark that ths package should be
# installed before nova_config
if ($package_name) {
package { $nova_title:
name => $package_name,
ensure => $ensure_package,
notify => Service[$nova_title],
}
}
if ($service_name) {
service { $nova_title:
name => $service_name,
ensure => $service_ensure,
enable => $enabled,
require => Package['nova-common'],
}
}
}