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
88 lines
2.7 KiB
Puppet
88 lines
2.7 KiB
Puppet
# Creates the files packages and services that are
|
|
# needed to deploy each type of storage server.
|
|
#
|
|
# == Parameters
|
|
# [*enabled*]
|
|
# (optional) Should the service be enabled to start
|
|
# at boot. Defaults to true
|
|
#
|
|
# [*manage_service*]
|
|
# (optional) Whether the service should be managed by Puppet.
|
|
# Defaults to true.
|
|
#
|
|
# [*package_ensure*]
|
|
# (optional) The desired ensure state of the swift storage packages.
|
|
# Defaults to present.
|
|
#
|
|
# [*config_file_name*]
|
|
# (optional) The configuration file name.
|
|
# Starting at the path "/etc/swift/"
|
|
# Defaults to "${name}-server.conf"
|
|
#
|
|
# [*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.
|
|
#
|
|
# == Dependencies
|
|
# Requires Class[swift::storage]
|
|
#
|
|
define swift::storage::generic(
|
|
$manage_service = true,
|
|
$enabled = true,
|
|
$package_ensure = 'present',
|
|
$config_file_name = "${name}-server.conf",
|
|
$service_provider = $::swift::params::service_provider
|
|
) {
|
|
|
|
include ::swift::params
|
|
|
|
Class['swift::storage'] -> Swift::Storage::Generic[$name]
|
|
Swift_config<| |> ~> Service["swift-${name}-server"]
|
|
|
|
validate_re($name, '^object|container|account$')
|
|
|
|
package { "swift-${name}":
|
|
ensure => $package_ensure,
|
|
name => getvar("::swift::params::${name}_package_name"),
|
|
tag => ['openstack', 'swift-package'],
|
|
before => Service["swift-${name}-server", "swift-${name}-replicator"],
|
|
}
|
|
|
|
file { "/etc/swift/${name}-server/":
|
|
ensure => directory,
|
|
owner => 'swift',
|
|
group => 'swift',
|
|
require => Package["swift-${name}"],
|
|
}
|
|
|
|
if $manage_service {
|
|
if $enabled {
|
|
$service_ensure = 'running'
|
|
} else {
|
|
$service_ensure = 'stopped'
|
|
}
|
|
}
|
|
|
|
swift::service { "swift-${name}-server":
|
|
os_family_service_name => getvar("::swift::params::${name}_server_service_name"),
|
|
service_ensure => $service_ensure,
|
|
enabled => $enabled,
|
|
config_file_name => $config_file_name,
|
|
service_provider => $service_provider,
|
|
subscribe => Package["swift-${name}"],
|
|
}
|
|
|
|
swift::service { "swift-${name}-replicator":
|
|
os_family_service_name => getvar("::swift::params::${name}_replicator_service_name"),
|
|
service_ensure => $service_ensure,
|
|
enabled => $enabled,
|
|
config_file_name => $config_file_name,
|
|
service_provider => $service_provider,
|
|
subscribe => Package["swift-${name}"],
|
|
}
|
|
}
|