puppet-swift/manifests/service.pp
Emilien Macchi 1b8869e6ae Pass subscribe and require into service resource
Before this update, subscribe and require could be passed
into the service class and work due to some default puppet
behaviors. This resulted in unknown variable warnings.  Removal
of these parameters would remove the required resource dependencies.

Adding new parameters 'service_subscribe' and 'service_require'
to pass in these dependencies. The 'service_' prefix is used
here because use of 'subscribe' or 'require' as parameter names
would also print a meta parameter warning.

Change-Id: I33d2d6028347bbe50dc9b3f36b3f86b217db7c0c
2016-11-21 23:35:23 +00:00

84 lines
2.4 KiB
Puppet

# == 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.
#
define swift::service(
$os_family_service_name,
$config_file_name,
$service_ensure = undef,
$enabled = true,
$service_provider = $::swift::params::service_provider,
$service_subscribe = undef,
$service_require = 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")
}
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 => $service_subscribe,
require => $service_require,
}
} 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 => $service_subscribe,
require => $service_require,
}
}
}