5a7d18975f
The 'swiftinit' provider is a custom provider of the service type that manages swift services using swift-init. Use of the swiftinit service provider is optional, the default is to use service providers specified in params file. This provider also manages swift services starting at boot by adding or removing a templated init or services file and making systemctl calls. See README for more detail. A wrapper defined type 'swift::service' has been created to simplify use of the swiftinit provider without adding logic to every class. this wrapper also aids in input validation and testing of the swiftinit provider. Two extra runs of apply_manifest have been added to the basic_swift_spec acceptance test. The service_provider is set to "swiftinit". The first run catches any errors upgrading to the swiftinit service provider and the second run tests idempotency. This patch is an initial step towards using swift-init to manage multiple swift services out of different configuration files such as is needed to run a separate replication network. Change-Id: I2f71c82c7a6c463f8c76a193409c0a17daa15bda
72 lines
2.1 KiB
Puppet
72 lines
2.1 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.
|
|
#
|
|
define swift::service(
|
|
$os_family_service_name,
|
|
$config_file_name,
|
|
$service_ensure = undef,
|
|
$enabled = true,
|
|
$service_provider = $::swift::params::service_provider,
|
|
) {
|
|
|
|
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,
|
|
}
|
|
}
|
|
}
|