File: service.pp

package info (click to toggle)
puppet-module-swift 9.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,248 kB
  • ctags: 95
  • sloc: ruby: 5,804; python: 35; makefile: 17; sh: 15
file content (72 lines) | stat: -rw-r--r-- 2,129 bytes parent folder | download
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
# == 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.
#
define swift::service(
  $os_family_service_name,
  $config_file_name,
  $service_ensure   = undef,
  $enabled          = true,
  $service_provider = $::swift::params::service_provider,
) {

  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")
  }

  if $service_provider != 'swiftinit' {
    service { $name:
      ensure    => $service_ensure,
      name      => $os_family_service_name,
      hasstatus => true,
      enable    => $enabled,
      provider  => $service_provider,
      tag       => 'swift-service',
      subscribe => $subscribe,
    }
  } elsif $service_provider == 'swiftinit' {
    service { $name:
      ensure     => $service_ensure,
      enable     => $enabled,
      hasstatus  => true,
      hasrestart => true,
      provider   => 'swiftinit',
      pattern    => $os_family_service_name,
      manifest   => $config_file_name,
      tag        => 'swift-service',
      subscribe  => $subscribe,
    }
  }
}