Use ini provider to manage storage config files
With this change now config files for storage services(account, container and object) are managed by ini provider instead of concat resources. This allows us to use the default file provided by packages instead of replacing the whole file content by our templates, and use the $::os_service_default value instead of hard-coding own defaults. Related-Bug: #1921319 Change-Id: I375634214e88acc5075f64090287f934ce8451d1
This commit is contained in:
parent
efcef86de7
commit
453b1a9731
@ -28,6 +28,18 @@
|
||||
# (optional) Allow configuration of arbitrary Swift Proxy configurations.
|
||||
# The value is an hash of swift_proxy_config resources.
|
||||
#
|
||||
# [*swift_account_config*]
|
||||
# (optional) Allow configuration of arbitrary Swift Account configurations.
|
||||
# The value is an hash of swift_account_config resources.
|
||||
#
|
||||
# [*swift_container_config*]
|
||||
# (optional) Allow configuration of arbitrary Swift Container configurations.
|
||||
# The value is an hash of swift_container_config resources.
|
||||
#
|
||||
# [*swift_object_config*]
|
||||
# (optional) Allow configuration of arbitrary Swift Object configurations.
|
||||
# The value is an hash of swift_object_config resources.
|
||||
#
|
||||
# [*swift_internal_client_config*]
|
||||
# (optional) Allow configuration of arbitrary Swift internal client
|
||||
# configurations.
|
||||
@ -37,6 +49,9 @@ class swift::config (
|
||||
$swift_config = {},
|
||||
$swift_container_sync_realms_config = {},
|
||||
$swift_proxy_config = {},
|
||||
$swift_account_config = {},
|
||||
$swift_container_config = {},
|
||||
$swift_object_config = {},
|
||||
$swift_internal_client_config = {},
|
||||
) {
|
||||
|
||||
@ -45,10 +60,16 @@ class swift::config (
|
||||
validate_legacy(Hash, 'validate_hash', $swift_config)
|
||||
validate_legacy(Hash, 'validate_hash', $swift_container_sync_realms_config)
|
||||
validate_legacy(Hash, 'validate_hash', $swift_proxy_config)
|
||||
validate_legacy(Hash, 'validate_hash', $swift_account_config)
|
||||
validate_legacy(Hash, 'validate_hash', $swift_container_config)
|
||||
validate_legacy(Hash, 'validate_hash', $swift_object_config)
|
||||
validate_legacy(Hash, 'validate_hash', $swift_internal_client_config)
|
||||
|
||||
create_resources('swift_config', $swift_config)
|
||||
create_resources('swift_container_sync_realms_config', $swift_container_sync_realms_config)
|
||||
create_resources('swift_proxy_config', $swift_proxy_config)
|
||||
create_resources('swift_account_config', $swift_proxy_config)
|
||||
create_resources('swift_container_config', $swift_container_config)
|
||||
create_resources('swift_object_config', $swift_object_config)
|
||||
create_resources('swift_internal_client_config', $swift_internal_client_config)
|
||||
}
|
||||
|
@ -45,11 +45,6 @@ class swift::deps {
|
||||
-> Swift_internal_client_config<||>
|
||||
~> Anchor['swift::config::end']
|
||||
|
||||
Anchor['swift::config::begin']
|
||||
-> File<| tag == 'swift-file' |>
|
||||
-> Concat<| tag == 'swift-concat' |>
|
||||
~> Anchor['swift::config::end']
|
||||
|
||||
# On any uwsgi config change, we must restart Swift.
|
||||
Anchor['swift::config::begin']
|
||||
-> Swift_proxy_uwsgi_config<||>
|
||||
|
@ -35,7 +35,6 @@ class swift::storage::account(
|
||||
) inherits swift::params {
|
||||
|
||||
include swift::deps
|
||||
Swift_config<| |> ~> Service['swift-account-reaper']
|
||||
|
||||
swift::storage::generic { 'account':
|
||||
manage_service => $manage_service,
|
||||
@ -59,7 +58,5 @@ class swift::storage::account(
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
service_require => Package['swift-account'],
|
||||
service_subscribe => Concat["/etc/swift/${config_file_name}"],
|
||||
}
|
||||
}
|
||||
|
@ -37,14 +37,11 @@ class swift::storage::container(
|
||||
$package_ensure = 'present',
|
||||
$allowed_sync_hosts = ['127.0.0.1'],
|
||||
$config_file_name = 'container-server.conf',
|
||||
$service_provider = $::swift::params::service_provider
|
||||
$service_provider = $::swift::params::service_provider
|
||||
) inherits swift::params {
|
||||
|
||||
include swift::deps
|
||||
|
||||
Swift_config<| |> ~> Service['swift-container-updater']
|
||||
Swift_config<| |> ~> Service['swift-container-sync']
|
||||
|
||||
swift::storage::generic { 'container':
|
||||
manage_service => $manage_service,
|
||||
enabled => $enabled,
|
||||
@ -67,8 +64,6 @@ class swift::storage::container(
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
service_require => Package['swift-container'],
|
||||
service_subscribe => Concat["/etc/swift/${config_file_name}"],
|
||||
}
|
||||
|
||||
swift::service { 'swift-container-sync':
|
||||
@ -77,8 +72,6 @@ class swift::storage::container(
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
service_require => Package['swift-container'],
|
||||
service_subscribe => Concat["/etc/swift/${config_file_name}"],
|
||||
}
|
||||
|
||||
swift::service { 'swift-container-sharder':
|
||||
@ -87,7 +80,5 @@ class swift::storage::container(
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
service_require => Package['swift-container'],
|
||||
service_subscribe => Concat["/etc/swift/${config_file_name}"],
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ define swift::storage::filter::healthcheck(
|
||||
|
||||
include swift::deps
|
||||
|
||||
concat::fragment { "swift_healthcheck_${name}":
|
||||
target => "/etc/swift/${name}-server.conf",
|
||||
content => template('swift/healthcheck.conf.erb'),
|
||||
order => '25',
|
||||
}
|
||||
$config_type = "swift_${name}_config"
|
||||
|
||||
create_resources($config_type, {
|
||||
'filter:healthcheck/use' => {'value' => 'egg:swift#healthcheck'},
|
||||
})
|
||||
}
|
||||
|
@ -2,8 +2,9 @@
|
||||
# Configure swift recon.
|
||||
#
|
||||
# == Parameters
|
||||
# [*cache_path*] The path for recon cache
|
||||
# Optional. Defaults to '/var/cache/swift/'
|
||||
# [*cache_path*]
|
||||
# (Optional) The path for recon cache
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# == Dependencies
|
||||
#
|
||||
@ -19,15 +20,16 @@
|
||||
# Copyright 2011 Puppetlabs Inc, unless otherwise noted.
|
||||
#
|
||||
define swift::storage::filter::recon(
|
||||
$cache_path = '/var/cache/swift'
|
||||
$cache_path = $::os_service_default,
|
||||
) {
|
||||
|
||||
include swift::deps
|
||||
|
||||
concat::fragment { "swift_recon_${name}":
|
||||
target => "/etc/swift/${name}-server.conf",
|
||||
content => template('swift/recon.conf.erb'),
|
||||
order => '35',
|
||||
}
|
||||
$config_type = "swift_${name}_config"
|
||||
|
||||
create_resources($config_type, {
|
||||
'filter:recon/use' => {'value' => 'egg:swift#recon'},
|
||||
'filter:recon/recon_cache_path' => {'value' => $cache_path},
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -42,9 +42,6 @@ define swift::storage::generic(
|
||||
include swift::params
|
||||
|
||||
Class['swift::storage'] -> Swift::Storage::Generic[$name]
|
||||
Swift_config<| |> ~> Service["swift-${name}-server"]
|
||||
Swift_config<| |> ~> Service["swift-${name}-auditor"]
|
||||
Swift_config<| |> ~> Service["swift-${name}-replicator"]
|
||||
|
||||
validate_legacy(Enum['object', 'container', 'account'], 'validate_re',
|
||||
$name, ['^object|container|account$'])
|
||||
@ -53,14 +50,14 @@ define swift::storage::generic(
|
||||
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::params::user,
|
||||
group => $::swift::params::group,
|
||||
tag => 'swift-file',
|
||||
ensure => directory,
|
||||
owner => $::swift::params::user,
|
||||
group => $::swift::params::group,
|
||||
require => Anchor['swift::config::begin'],
|
||||
before => Anchor['swift::config::end'],
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
@ -77,7 +74,6 @@ define swift::storage::generic(
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
service_subscribe => Package["swift-${name}"],
|
||||
}
|
||||
|
||||
swift::service { "swift-${name}-replicator":
|
||||
@ -86,7 +82,6 @@ define swift::storage::generic(
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
service_subscribe => Package["swift-${name}"],
|
||||
}
|
||||
|
||||
swift::service { "swift-${name}-auditor":
|
||||
@ -95,6 +90,5 @@ define swift::storage::generic(
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
service_subscribe => Package["swift-${name}"],
|
||||
}
|
||||
}
|
||||
|
@ -58,8 +58,6 @@ class swift::storage::object(
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
require => Anchor['swift::install::end'],
|
||||
service_subscribe => Concat["/etc/swift/${config_file_name}"],
|
||||
}
|
||||
|
||||
swift::service { 'swift-object-reconstructor':
|
||||
@ -68,8 +66,6 @@ class swift::storage::object(
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
require => Anchor['swift::install::end'],
|
||||
service_subscribe => Concat["/etc/swift/${config_file_name}"],
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@
|
||||
# "local" ring devices across all storage policies. This can help provide
|
||||
# the isolation of threads_per_disk without the severe overhead. The default
|
||||
# value of 0 disables this feature.
|
||||
# Defaults to 0.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*user*]
|
||||
# (optional) User to run as
|
||||
@ -74,7 +74,7 @@
|
||||
#
|
||||
# [*replicator_interval*]
|
||||
# (optional) Minimum time for a pass to take, in seconds.
|
||||
# Defaults to 30.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*updater_concurrency*]
|
||||
# (optional) Number of updater workers to spawn.
|
||||
@ -112,14 +112,14 @@
|
||||
# good for seeing errors if true
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*config_file_path*]
|
||||
# (optional) The configuration file name.
|
||||
# Starting at the path "/etc/swift/"
|
||||
# Defaults to "${type}-server.conf"
|
||||
# [*config_file_path*]
|
||||
# (optional) The configuration file name.
|
||||
# Starting at the path "/etc/swift/"
|
||||
# Defaults to "${type}-server.conf"
|
||||
#
|
||||
# [*statsd_enabled*]
|
||||
# (optional) Should statsd configuration items be writen out to config files
|
||||
# Defaults to false.
|
||||
# (optional) Should statsd configuration items be writen out to config files
|
||||
# Defaults to false.
|
||||
#
|
||||
# [*log_statsd_host*]
|
||||
# (optional) statsd host to send data to.
|
||||
@ -127,69 +127,69 @@
|
||||
#
|
||||
# [*log_statsd_port*]
|
||||
# (optional) statsd port to send data to.
|
||||
# Defaults to 8125
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*log_statsd_default_sample_rate*]
|
||||
# (optional) Default sample rate for data. This should be a number between 0
|
||||
# and 1. According to the documentation this should be set to 1 and the
|
||||
# sample rate factor should be adjusted.
|
||||
# Defaults to '1.0'
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*log_statsd_sample_rate_factor*]
|
||||
# (optional) sample rate factor for data.
|
||||
# Defaults to '1.0'
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*log_statsd_metric_prefix*]
|
||||
# (optional) Prefix for data being sent to statsd.
|
||||
# Defaults to ''
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*network_chunk_size*]
|
||||
# (optional) Size of chunks to read/write over the network.
|
||||
# Defaults to 65536.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*disk_chunk_size*]
|
||||
# (optional) Size of chunks to read/write to disk.
|
||||
# Defaults to 65536.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*auditor_disk_chunk_size*]
|
||||
# (optional) Object-auditor size of chunks to read/write to disk.
|
||||
# Defaults to undef.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*client_timeout*]
|
||||
# (optional) Object-server timeout in seconds to read one chunk from a client
|
||||
# external services.
|
||||
# Defaults to 60.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*rsync_timeout*]
|
||||
# (optional) Max duration of a partition rsync.
|
||||
# Default to 900.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*rsync_bwlimit*]
|
||||
# (optional) Bandwidth limit for rsync in kB/s. 0 means unlimited.
|
||||
# Default to 0.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*splice*]
|
||||
# (optional) Use splice for zero-copy object GETs. This requires Linux Kernel
|
||||
# version 3.0 or greater.
|
||||
# Defaults to false.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*object_server_mb_per_sync*]
|
||||
# (optional) Number of MB allocated for the cache.
|
||||
# Defaults to 512, which is the swift default value.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*container_sharder_auto_shard*]
|
||||
# (optional) If the auto_shard option is true then the sharder will
|
||||
# automatically select containers to shard, scan for shard ranges,
|
||||
# and select shards to shrink.
|
||||
# Default to false.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*container_sharder_concurrency*]
|
||||
# (optional) Number of replication workers to spawn.
|
||||
# Default to 8.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
# [*container_sharder_interval*]
|
||||
# (optional) Time in seconds to wait between sharder cycles.
|
||||
# Default to 30.
|
||||
# Default to $::os_service_default.
|
||||
#
|
||||
define swift::storage::server(
|
||||
$type,
|
||||
@ -202,11 +202,11 @@ define swift::storage::server(
|
||||
$max_connections = 25,
|
||||
$pipeline = ["${type}-server"],
|
||||
$mount_check = true,
|
||||
$servers_per_port = 0,
|
||||
$servers_per_port = $::os_service_default,
|
||||
$user = undef,
|
||||
$workers = $::os_workers,
|
||||
$replicator_concurrency = 1,
|
||||
$replicator_interval = 30,
|
||||
$replicator_interval = $::os_service_default,
|
||||
$updater_concurrency = 1,
|
||||
$reaper_concurrency = 1,
|
||||
$log_facility = 'LOG_LOCAL2',
|
||||
@ -220,23 +220,23 @@ define swift::storage::server(
|
||||
$config_file_path = "${type}-server.conf",
|
||||
$statsd_enabled = false,
|
||||
$log_statsd_host = 'localhost',
|
||||
$log_statsd_port = 8125,
|
||||
$log_statsd_default_sample_rate = '1.0',
|
||||
$log_statsd_sample_rate_factor = '1.0',
|
||||
$log_statsd_metric_prefix = '',
|
||||
$network_chunk_size = 65536,
|
||||
$disk_chunk_size = 65536,
|
||||
$client_timeout = 60,
|
||||
$auditor_disk_chunk_size = undef,
|
||||
$rsync_timeout = 900,
|
||||
$rsync_bwlimit = 0,
|
||||
$splice = false,
|
||||
$object_server_mb_per_sync = 512,
|
||||
$log_statsd_port = $::os_service_default,
|
||||
$log_statsd_default_sample_rate = $::os_service_default,
|
||||
$log_statsd_sample_rate_factor = $::os_service_default,
|
||||
$log_statsd_metric_prefix = $::os_service_default,
|
||||
$network_chunk_size = $::os_service_default,
|
||||
$disk_chunk_size = $::os_service_default,
|
||||
$client_timeout = $::os_service_default,
|
||||
$auditor_disk_chunk_size = $::os_service_default,
|
||||
$rsync_timeout = $::os_service_default,
|
||||
$rsync_bwlimit = $::os_service_default,
|
||||
$splice = $::os_service_default,
|
||||
$object_server_mb_per_sync = $::os_service_default,
|
||||
# These parameters only apply to container-server.conf,
|
||||
# and define options for the container-sharder service.
|
||||
$container_sharder_auto_shard = false,
|
||||
$container_sharder_concurrency = 8,
|
||||
$container_sharder_interval = 30,
|
||||
$container_sharder_auto_shard = $::os_service_default,
|
||||
$container_sharder_concurrency = $::os_service_default,
|
||||
$container_sharder_interval = $::os_service_default,
|
||||
){
|
||||
|
||||
include swift::deps
|
||||
@ -260,11 +260,15 @@ define swift::storage::server(
|
||||
validate_legacy(Enum['object', 'container', 'account'], 'validate_re',
|
||||
$type, ['^object|container|account$'])
|
||||
validate_legacy(Array, 'validate_array', $pipeline)
|
||||
validate_legacy(Boolean, 'validate_bool', $splice)
|
||||
# TODO - validate that name is an integer
|
||||
|
||||
if ! is_service_default($splice) {
|
||||
validate_legacy(Boolean, 'validate_bool', $splice)
|
||||
}
|
||||
|
||||
$bind_port = $name
|
||||
|
||||
# rsync::server should be included before rsync::server::module
|
||||
include swift::storage
|
||||
rsync::server::module { $type:
|
||||
path => $devices,
|
||||
lock_file => "/var/lock/${type}.lock",
|
||||
@ -276,13 +280,8 @@ define swift::storage::server(
|
||||
read_only => false,
|
||||
}
|
||||
|
||||
concat { "/etc/swift/${config_file_path}":
|
||||
owner => pick($owner, $::swift::params::user),
|
||||
group => pick($group, $::swift::params::group),
|
||||
notify => Anchor['swift::config::end'],
|
||||
require => Anchor['swift::install::end'],
|
||||
tag => 'swift-concat',
|
||||
}
|
||||
$config_file_full_path = "/etc/swift/${config_file_path}"
|
||||
|
||||
|
||||
$required_middlewares = split(
|
||||
inline_template(
|
||||
@ -292,24 +291,183 @@ define swift::storage::server(
|
||||
end.join(',')
|
||||
%>"), ',')
|
||||
|
||||
# you can now add your custom fragments at the user level
|
||||
concat::fragment { "swift-${type}-${name}":
|
||||
target => "/etc/swift/${config_file_path}",
|
||||
content => template("swift/${type}-server.conf.erb"),
|
||||
order => '00',
|
||||
# require classes for each of the elements of the pipeline
|
||||
# this is to ensure the user gets reasonable elements if he
|
||||
# does not specify the backends for every specified element of
|
||||
# the pipeline
|
||||
file { $config_file_full_path:
|
||||
ensure => present,
|
||||
owner => pick($owner, $::swift::params::user),
|
||||
group => pick($group, $::swift::params::group),
|
||||
replace => false,
|
||||
tag => 'swift-config-file',
|
||||
before => $required_middlewares,
|
||||
require => Anchor['swift::install::end'],
|
||||
}
|
||||
|
||||
# common settings
|
||||
$common_opts = {
|
||||
'DEFAULT/devices' => {'value' => $devices},
|
||||
'DEFAULT/bind_ip' => {'value' => $storage_local_net_ip},
|
||||
'DEFAULT/bind_port' => {'value' => $bind_port},
|
||||
'DEFAULT/mount_check' => {'value' => $mount_check},
|
||||
'DEFAULT/user' => {'value' => $user_real},
|
||||
'DEFAULT/workers' => {'value' => $workers},
|
||||
'DEFAULT/log_name' => {'value' => $log_name},
|
||||
'DEFAULT/log_facility' => {'value' => $log_facility},
|
||||
'DEFAULT/log_level' => {'value' => $log_level},
|
||||
'DEFAULT/log_address' => {'value' => $log_address},
|
||||
# pipeline
|
||||
'pipeline:main/pipeline' => {'value' => join($pipeline, ' ')},
|
||||
# server
|
||||
"app:${type}-server/use" => {'value' => "egg:swift#${type}"},
|
||||
"app:${type}-server/set log_name" => {'value' => $log_name},
|
||||
"app:${type}-server/set log_facility" => {'value' => $log_facility},
|
||||
"app:${type}-server/set log_level" => {'value' => $log_level},
|
||||
"app:${type}-server/set log_requests" => {'value' => $log_requests},
|
||||
"app:${type}-server/set log_address" => {'value' => $log_address},
|
||||
# auditor
|
||||
# replicator
|
||||
}
|
||||
|
||||
file_line { "${type}-auditor":
|
||||
path => $config_file_full_path,
|
||||
line => "[${type}-auditor]",
|
||||
tag => 'swift-config-file',
|
||||
}
|
||||
|
||||
file_line { "${type}-replicator":
|
||||
path => $config_file_full_path,
|
||||
line => "[${type}-replicator]",
|
||||
tag => 'swift-config-file',
|
||||
}
|
||||
|
||||
Anchor['swift::config::begin']
|
||||
-> File[$config_file_full_path]
|
||||
-> File_line<| path == $config_file_full_path |>
|
||||
~> Anchor['swift::config::end']
|
||||
|
||||
# udp log transfer
|
||||
if $log_udp_host {
|
||||
$log_udp_opts = {
|
||||
'DEFAULT/log_udp_host' => {'value' => $log_udp_host},
|
||||
'DEFAULT/log_udp_port' => {'value' => pick($log_udp_port, $::os_service_default)},
|
||||
}
|
||||
} else {
|
||||
$log_udp_opts = {
|
||||
'DEFAULT/log_udp_host' => {'value' => $::os_service_default},
|
||||
'DEFAULT/log_udp_port' => {'value' => $::os_service_default},
|
||||
}
|
||||
}
|
||||
|
||||
# statsd
|
||||
if $statsd_enabled {
|
||||
$log_statsd_opts = {
|
||||
'DEFAULT/log_statsd_host' => {'value' => $log_statsd_host},
|
||||
'DEFAULT/log_statsd_port' => {'value' => $log_statsd_port},
|
||||
'DEFAULT/log_statsd_default_sample_rate' => {'value' => $log_statsd_default_sample_rate},
|
||||
'DEFAULT/log_statsd_sample_rate_factor' => {'value' => $log_statsd_sample_rate_factor},
|
||||
'DEFAULT/log_statsd_metric_prefix' => {'value' => $log_statsd_metric_prefix},
|
||||
}
|
||||
} else {
|
||||
$log_statsd_opts = {
|
||||
'DEFAULT/log_statsd_host' => {'value' => $::os_service_default},
|
||||
'DEFAULT/log_statsd_port' => {'value' => $::os_service_default},
|
||||
'DEFAULT/log_statsd_default_sample_rate' => {'value' => $::os_service_default},
|
||||
'DEFAULT/log_statsd_sample_rate_factor' => {'value' => $::os_service_default},
|
||||
'DEFAULT/log_statsd_metric_prefix' => {'value' => $::os_service_default},
|
||||
}
|
||||
}
|
||||
|
||||
case $type {
|
||||
'object': { Concat["/etc/swift/${config_file_path}"] -> Swift_object_config <||> }
|
||||
'container': { Concat["/etc/swift/${config_file_path}"] -> Swift_container_config <||> }
|
||||
'account': { Concat["/etc/swift/${config_file_path}"] -> Swift_account_config <||> }
|
||||
default : { warning("swift storage server ${type} must specify ${type}-server") }
|
||||
'account': {
|
||||
$type_opts = {
|
||||
# account-server
|
||||
# account-auditor
|
||||
# account-replicator
|
||||
'account-replicator/concurrency' => {'value' => $replicator_concurrency},
|
||||
'account-replicator/interval' => {'value' => $replicator_interval},
|
||||
# account-reaper
|
||||
'account-reaper/concurrency' => {'value' => $reaper_concurrency},
|
||||
}
|
||||
|
||||
file_line { 'account-reaper':
|
||||
path => $config_file_full_path,
|
||||
line => '[account-reaper]',
|
||||
tag => 'swift-config-file',
|
||||
}
|
||||
}
|
||||
'container': {
|
||||
$type_opts = {
|
||||
'DEFAULT/allowed_sync_hosts' => {'value' => join($::swift::storage::container::allowed_sync_hosts, ',')},
|
||||
# container-server
|
||||
# container-auditor
|
||||
# container-replicator
|
||||
'container-replicator/concurrency' => {'value' => $replicator_concurrency},
|
||||
'container-replicator/interval' => {'value' => $replicator_interval},
|
||||
# container-updater
|
||||
'container-updater/concurrency' => {'value' => $updater_concurrency},
|
||||
# container-sync
|
||||
# container-sharder
|
||||
'container-sharder/auto_shard' => {'value' => $container_sharder_auto_shard},
|
||||
'container-sharder/concurrency' => {'value' => $container_sharder_concurrency},
|
||||
'container-sharder/interval' => {'value' => $container_sharder_interval},
|
||||
}
|
||||
|
||||
file_line { 'container-updater':
|
||||
path => $config_file_full_path,
|
||||
line => '[container-updater]',
|
||||
tag => 'swift-config-file',
|
||||
}
|
||||
file_line { 'container-sync':
|
||||
path => $config_file_full_path,
|
||||
line => '[container-sync]',
|
||||
tag => 'swift-config-file',
|
||||
}
|
||||
file_line { 'container-sharder':
|
||||
path => $config_file_full_path,
|
||||
line => '[container-sharder]',
|
||||
tag => 'swift-config-file',
|
||||
}
|
||||
}
|
||||
'object': {
|
||||
$type_opts = {
|
||||
'DEFAULT/servers_per_port' => {'value' => $servers_per_port},
|
||||
'DEFAULT/network_chunk_size' => {'value' => $network_chunk_size},
|
||||
'DEFAULT/disk_chunk_size' => {'value' => $disk_chunk_size},
|
||||
'DEFAULT/client_timeout' => {'value' => $client_timeout},
|
||||
# object-server
|
||||
'app:object-server/splice' => {'value' => $splice},
|
||||
'app:object-server/mb_per_sync' => {'value' => $object_server_mb_per_sync},
|
||||
# object-auditor
|
||||
'object-auditor/disk_chunk_size' => {'value' => pick($auditor_disk_chunk_size, $::os_service_default)},
|
||||
# object-replicator
|
||||
'object-replicator/concurrency' => {'value' => $replicator_concurrency},
|
||||
'object-replicator/rsync_timeout' => {'value' => $rsync_timeout},
|
||||
'object-replicator/rsync_bwlimit' => {'value' => $rsync_bwlimit},
|
||||
# object-updater
|
||||
'object-updater/concurrency' => {'value' => $updater_concurrency},
|
||||
# object-reconstructor
|
||||
}
|
||||
|
||||
file_line { 'object-updater':
|
||||
path => $config_file_full_path,
|
||||
line => '[object-updater]',
|
||||
tag => 'swift-config-file',
|
||||
}
|
||||
file_line { 'object-reconstructor':
|
||||
path => $config_file_full_path,
|
||||
line => '[object-reconstructor]',
|
||||
tag => 'swift-config-file',
|
||||
}
|
||||
}
|
||||
default: {
|
||||
# nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
create_resources("swift_${type}_config", merge(
|
||||
$common_opts,
|
||||
$log_udp_opts,
|
||||
$log_statsd_opts,
|
||||
$type_opts,
|
||||
), {
|
||||
#'path' => $config_file_full_path,
|
||||
'require' => File[$config_file_full_path]
|
||||
})
|
||||
}
|
||||
|
8
releasenotes/notes/storage-config-43804c0fae439026.yaml
Normal file
8
releasenotes/notes/storage-config-43804c0fae439026.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The ``swift::config`` class now supports the following three parameters.
|
||||
|
||||
- ``swift_account_config``
|
||||
- ``swift_container_config``
|
||||
- ``swift_object_config``
|
@ -12,6 +12,21 @@ describe 'swift::config' do
|
||||
'DEFAULT/bar' => { 'value' => 'barValue' },
|
||||
'DEFAULT/baz' => { 'ensure' => 'absent' }
|
||||
},
|
||||
:swift_account_config => {
|
||||
'DEFAULT/foo' => { 'value' => 'fooValue' },
|
||||
'DEFAULT/bar' => { 'value' => 'barValue' },
|
||||
'DEFAULT/baz' => { 'ensure' => 'absent' }
|
||||
},
|
||||
:swift_container_config => {
|
||||
'DEFAULT/foo' => { 'value' => 'fooValue' },
|
||||
'DEFAULT/bar' => { 'value' => 'barValue' },
|
||||
'DEFAULT/baz' => { 'ensure' => 'absent' }
|
||||
},
|
||||
:swift_object_config => {
|
||||
'DEFAULT/foo' => { 'value' => 'fooValue' },
|
||||
'DEFAULT/bar' => { 'value' => 'barValue' },
|
||||
'DEFAULT/baz' => { 'ensure' => 'absent' }
|
||||
},
|
||||
:swift_internal_client_config => {
|
||||
'DEFAULT/foo' => { 'value' => 'fooValue' },
|
||||
'DEFAULT/bar' => { 'value' => 'barValue' },
|
||||
@ -33,6 +48,24 @@ describe 'swift::config' do
|
||||
is_expected.to contain_swift_proxy_config('DEFAULT/baz').with_ensure('absent')
|
||||
end
|
||||
|
||||
it 'configures arbitrary swift account configurations' do
|
||||
is_expected.to contain_swift_account_config('DEFAULT/foo').with_value('fooValue')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/bar').with_value('barValue')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/baz').with_ensure('absent')
|
||||
end
|
||||
|
||||
it 'configures arbitrary swift container configurations' do
|
||||
is_expected.to contain_swift_container_config('DEFAULT/foo').with_value('fooValue')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/bar').with_value('barValue')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/baz').with_ensure('absent')
|
||||
end
|
||||
|
||||
it 'configures arbitrary swift object configurations' do
|
||||
is_expected.to contain_swift_object_config('DEFAULT/foo').with_value('fooValue')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/bar').with_value('barValue')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/baz').with_ensure('absent')
|
||||
end
|
||||
|
||||
it 'configures arbitrary swift internal client configurations' do
|
||||
is_expected.to contain_swift_internal_client_config('DEFAULT/foo').with_value('fooValue')
|
||||
is_expected.to contain_swift_internal_client_config('DEFAULT/bar').with_value('barValue')
|
||||
|
@ -125,55 +125,6 @@ describe 'swift::storage::all' do
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
describe "when specifying statsd enabled" do
|
||||
let :params do
|
||||
{
|
||||
:storage_local_net_ip => '127.0.0.1',
|
||||
:statsd_enabled => true,
|
||||
:log_statsd_host => 'statsd.example.com',
|
||||
:log_statsd_port => '9999',
|
||||
:log_statsd_default_sample_rate => '2.0',
|
||||
:log_statsd_sample_rate_factor => '1.5',
|
||||
:log_statsd_metric_prefix => 'foo',
|
||||
}
|
||||
end
|
||||
|
||||
{'object' => '6000', 'container' => '6001', 'account' => '6002'}.each do |type,name|
|
||||
it "should configure statsd in the #{type} config file" do
|
||||
is_expected.to contain_concat_fragment("swift-#{type}-#{name}").with_content(
|
||||
/log_statsd_host = statsd.example.com/
|
||||
).with_content(
|
||||
/log_statsd_port = 9999/
|
||||
).with_content(
|
||||
/log_statsd_default_sample_rate = 2.0/
|
||||
).with_content(
|
||||
/log_statsd_sample_rate_factor = 1.5/
|
||||
).with_content(
|
||||
/log_statsd_metric_prefix = foo/
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "when specifying number of workers" do
|
||||
let :params do
|
||||
{
|
||||
:storage_local_net_ip => '127.0.0.1',
|
||||
:account_server_workers => '42',
|
||||
:container_server_workers => '42',
|
||||
:object_server_workers => '42',
|
||||
}
|
||||
end
|
||||
|
||||
{'object' => '6000', 'container' => '6001', 'account' => '6002'}.each do |type,name|
|
||||
it "should define worker count in the #{type} config file" do
|
||||
is_expected.to contain_concat_fragment("swift-#{type}-#{name}").with_content(
|
||||
/workers = 42/
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'swift::storage::all debian' do
|
||||
|
@ -2,15 +2,13 @@ require 'spec_helper'
|
||||
|
||||
describe 'swift::storage::filter::healthcheck' do
|
||||
let :title do
|
||||
'dummy'
|
||||
'account'
|
||||
end
|
||||
|
||||
shared_examples 'swift::storage::filter::healthcheck' do
|
||||
it 'should build the fragment with correct content' do
|
||||
is_expected.to contain_concat_fragment('swift_healthcheck_dummy').with_content('
|
||||
[filter:healthcheck]
|
||||
use = egg:swift#healthcheck
|
||||
')
|
||||
it 'should configure the healthcheck middleware' do
|
||||
is_expected.to contain_swift_account_config('filter:healthcheck/use').\
|
||||
with_value('egg:swift#healthcheck')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -2,29 +2,31 @@ require 'spec_helper'
|
||||
|
||||
describe 'swift::storage::filter::recon' do
|
||||
let :title do
|
||||
'dummy'
|
||||
'account'
|
||||
end
|
||||
|
||||
shared_examples 'swift::storage::filter::recon' do
|
||||
describe 'when passing default parameters' do
|
||||
it 'should build the fragment with correct content' do
|
||||
is_expected.to contain_concat_fragment('swift_recon_dummy').with_content('
|
||||
[filter:recon]
|
||||
use = egg:swift#recon
|
||||
recon_cache_path = /var/cache/swift
|
||||
')
|
||||
it 'should configure the recon middleware' do
|
||||
is_expected.to contain_swift_account_config('filter:recon/use').\
|
||||
with_value('egg:swift#recon')
|
||||
is_expected.to contain_swift_account_config('filter:recon/recon_cache_path').\
|
||||
with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when overriding default parameters' do
|
||||
let :params do
|
||||
{
|
||||
:cache_path => '/some/other/path'
|
||||
:cache_path => '/var/cache/swift'
|
||||
}
|
||||
end
|
||||
|
||||
it 'should build the fragment with correct content' do
|
||||
is_expected.to contain_concat_fragment('swift_recon_dummy').with_content(/recon_cache_path = \/some\/other\/path/)
|
||||
it 'should configure the recon middleware' do
|
||||
is_expected.to contain_swift_account_config('filter:recon/use').\
|
||||
with_value('egg:swift#recon')
|
||||
is_expected.to contain_swift_account_config('filter:recon/recon_cache_path').\
|
||||
with_value('/var/cache/swift')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -4,12 +4,6 @@ describe 'swift::storage::server' do
|
||||
let :pre_condition do
|
||||
"class { 'swift': swift_hash_path_suffix => 'foo' }
|
||||
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }
|
||||
swift::storage::filter::healthcheck { 'container': }
|
||||
swift::storage::filter::recon { 'container': }
|
||||
swift::storage::filter::healthcheck { 'object': }
|
||||
swift::storage::filter::recon { 'object': }
|
||||
swift::storage::filter::healthcheck { 'account': }
|
||||
swift::storage::filter::recon { 'account': }
|
||||
"
|
||||
end
|
||||
|
||||
@ -28,8 +22,10 @@ describe 'swift::storage::server' do
|
||||
shared_examples 'swift::storage::server' do
|
||||
describe 'with an invalid title' do
|
||||
let :params do
|
||||
{:storage_local_net_ip => '127.0.0.1',
|
||||
:type => 'object'}
|
||||
{
|
||||
:storage_local_net_ip => '127.0.0.1',
|
||||
:type => 'object'
|
||||
}
|
||||
end
|
||||
|
||||
let :title do
|
||||
@ -39,183 +35,270 @@ describe 'swift::storage::server' do
|
||||
it { should raise_error(Puppet::Error) }
|
||||
end
|
||||
|
||||
['account', 'object', 'container'].each do |t|
|
||||
describe "for type #{t}" do
|
||||
let :title do
|
||||
'8000'
|
||||
describe 'for type account' do
|
||||
let :title do
|
||||
'6002'
|
||||
end
|
||||
|
||||
let :req_params do
|
||||
{
|
||||
:storage_local_net_ip => '10.0.0.1',
|
||||
:type => 'account'
|
||||
}
|
||||
end
|
||||
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_package('swift-account').with_ensure('present') }
|
||||
it { is_expected.to contain_service('swift-account-server').with(
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_rsync__server__module('account').with(
|
||||
:path => '/srv/node',
|
||||
:lock_file => '/var/lock/account.lock',
|
||||
:uid => 'swift',
|
||||
:gid => 'swift',
|
||||
:incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
|
||||
:outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
|
||||
:max_connections => 25,
|
||||
:read_only => false,
|
||||
)}
|
||||
|
||||
it {
|
||||
is_expected.to contain_swift_account_config('DEFAULT/devices').with_value('/srv/node')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/bind_ip').with_value('10.0.0.1')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/bind_port').with_value('6002')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/mount_check').with_value(true)
|
||||
is_expected.to contain_swift_account_config('DEFAULT/user').with_value('swift')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/workers').with_value(4)
|
||||
is_expected.to contain_swift_account_config('DEFAULT/log_name').with_value('account-server')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/log_facility').with_value('LOG_LOCAL2')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/log_level').with_value('INFO')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/log_address').with_value('/dev/log')
|
||||
is_expected.to contain_swift_account_config('pipeline:main/pipeline').with_value('account-server')
|
||||
is_expected.to contain_swift_account_config('app:account-server/use').with_value('egg:swift#account')
|
||||
is_expected.to contain_swift_account_config('app:account-server/set log_name').with_value('account-server')
|
||||
is_expected.to contain_swift_account_config('app:account-server/set log_facility').with_value('LOG_LOCAL2')
|
||||
is_expected.to contain_swift_account_config('app:account-server/set log_level').with_value('INFO')
|
||||
is_expected.to contain_swift_account_config('app:account-server/set log_requests').with_value(true)
|
||||
is_expected.to contain_swift_account_config('app:account-server/set log_address').with_value('/dev/log')
|
||||
|
||||
is_expected.to contain_swift_account_config('DEFAULT/log_statsd_host').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/log_statsd_port').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/log_statsd_default_sample_rate').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/log_statsd_sample_rate_factor').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_account_config('DEFAULT/log_statsd_metric_prefix').with_value('<SERVICE DEFAULT>')
|
||||
|
||||
is_expected.to contain_swift_account_config('account-replicator/concurrency').with_value(1)
|
||||
is_expected.to contain_swift_account_config('account-replicator/interval').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_account_config('account-reaper/concurrency').with_value(1)
|
||||
}
|
||||
|
||||
context 'with customized pipeline' do
|
||||
let :pre_condition do
|
||||
"class { 'swift': swift_hash_path_suffix => 'foo' }
|
||||
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }
|
||||
swift::storage::filter::healthcheck { 'account': }
|
||||
swift::storage::filter::recon { 'account': }
|
||||
"
|
||||
end
|
||||
|
||||
let :req_params do
|
||||
{:storage_local_net_ip => '10.0.0.1', :type => t}
|
||||
before do
|
||||
params.merge!({
|
||||
:pipeline => ['healthcheck', 'recon', 'account-server']
|
||||
})
|
||||
end
|
||||
|
||||
let :params do
|
||||
req_params
|
||||
it {
|
||||
is_expected.to contain_swift_account_config('pipeline:main/pipeline').with_value('healthcheck recon account-server')
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe 'for type container' do
|
||||
let :title do
|
||||
'6001'
|
||||
end
|
||||
|
||||
let :req_params do
|
||||
{
|
||||
:storage_local_net_ip => '10.0.0.1',
|
||||
:type => 'container'
|
||||
}
|
||||
end
|
||||
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_package('swift-container').with_ensure('present') }
|
||||
it { is_expected.to contain_service('swift-container-server').with(
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_rsync__server__module('container').with(
|
||||
:path => '/srv/node',
|
||||
:lock_file => '/var/lock/container.lock',
|
||||
:uid => 'swift',
|
||||
:gid => 'swift',
|
||||
:incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
|
||||
:outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
|
||||
:max_connections => 25,
|
||||
:read_only => false,
|
||||
)}
|
||||
|
||||
it {
|
||||
is_expected.to contain_swift_container_config('DEFAULT/devices').with_value('/srv/node')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/bind_ip').with_value('10.0.0.1')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/bind_port').with_value('6001')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/mount_check').with_value(true)
|
||||
is_expected.to contain_swift_container_config('DEFAULT/user').with_value('swift')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/workers').with_value(4)
|
||||
is_expected.to contain_swift_container_config('DEFAULT/log_name').with_value('container-server')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/log_facility').with_value('LOG_LOCAL2')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/log_level').with_value('INFO')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/log_address').with_value('/dev/log')
|
||||
is_expected.to contain_swift_container_config('pipeline:main/pipeline').with_value('container-server')
|
||||
is_expected.to contain_swift_container_config('app:container-server/use').with_value('egg:swift#container')
|
||||
is_expected.to contain_swift_container_config('app:container-server/set log_name').with_value('container-server')
|
||||
is_expected.to contain_swift_container_config('app:container-server/set log_facility').with_value('LOG_LOCAL2')
|
||||
is_expected.to contain_swift_container_config('app:container-server/set log_level').with_value('INFO')
|
||||
is_expected.to contain_swift_container_config('app:container-server/set log_requests').with_value(true)
|
||||
is_expected.to contain_swift_container_config('app:container-server/set log_address').with_value('/dev/log')
|
||||
|
||||
is_expected.to contain_swift_container_config('DEFAULT/log_statsd_host').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/log_statsd_port').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/log_statsd_default_sample_rate').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/log_statsd_sample_rate_factor').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_container_config('DEFAULT/log_statsd_metric_prefix').with_value('<SERVICE DEFAULT>')
|
||||
|
||||
is_expected.to contain_swift_container_config('DEFAULT/allowed_sync_hosts').with_value('127.0.0.1')
|
||||
is_expected.to contain_swift_container_config('container-replicator/concurrency').with_value(1)
|
||||
is_expected.to contain_swift_container_config('container-replicator/interval').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_container_config('container-updater/concurrency').with_value(1)
|
||||
is_expected.to contain_swift_container_config('container-sharder/auto_shard').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_container_config('container-sharder/concurrency').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_container_config('container-sharder/interval').with_value('<SERVICE DEFAULT>')
|
||||
}
|
||||
|
||||
context 'with customized pipeline' do
|
||||
let :pre_condition do
|
||||
"class { 'swift': swift_hash_path_suffix => 'foo' }
|
||||
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }
|
||||
swift::storage::filter::healthcheck { 'container': }
|
||||
swift::storage::filter::recon { 'container': }
|
||||
"
|
||||
end
|
||||
|
||||
it { is_expected.to contain_package("swift-#{t}").with_ensure('present') }
|
||||
it { is_expected.to contain_service("swift-#{t}-server").with(
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
)}
|
||||
|
||||
describe 'when parameters are overridden' do
|
||||
{
|
||||
:devices => '/tmp/foo',
|
||||
:user => 'dan',
|
||||
:mount_check => true,
|
||||
:workers => 7,
|
||||
:pipeline => ['healthcheck'],
|
||||
}.each do |k,v|
|
||||
describe "when #{k} is set" do
|
||||
let :params do req_params.merge({k => v}) end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^#{k.to_s}\s*=\s*#{v.is_a?(Array) ? v.join(' ') : v}\s*$/) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "when pipeline is passed an array" do
|
||||
let :params do req_params.merge({:pipeline => ['healthcheck','recon']}) end
|
||||
it { is_expected.to contain_concat__fragment("swift-#{t}-#{title}").with(
|
||||
:content => /^pipeline\s*=\s*healthcheck recon\s*$/,
|
||||
:before => ["Swift::Storage::Filter::Healthcheck[#{t}]", "Swift::Storage::Filter::Recon[#{t}]",]
|
||||
)}
|
||||
end
|
||||
|
||||
describe "when pipeline is not passed an array" do
|
||||
let :params do req_params.merge({:pipeline => 'not an array'}) end
|
||||
it { should raise_error(Puppet::Error) }
|
||||
end
|
||||
|
||||
describe "when replicator_concurrency is set" do
|
||||
let :params do req_params.merge({:replicator_concurrency => 42}) end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-replicator\]\nconcurrency\s*=\s*42\s*$/m) }
|
||||
end
|
||||
|
||||
if t != 'object'
|
||||
describe "when replicator_concurrency and replicator_interval are set" do
|
||||
let :params do req_params.merge(
|
||||
{ :replicator_concurrency => 42,
|
||||
:replicator_interval => 42})
|
||||
end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-replicator\]\nconcurrency\s*=\s*42\ninterval\s*=\s*42\s*$/m) }
|
||||
end
|
||||
end
|
||||
|
||||
if t != 'account'
|
||||
describe "when updater_concurrency is set" do
|
||||
let :params do req_params.merge({:updater_concurrency => 73}) end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-updater\]\nconcurrency\s*=\s*73\s*$/m) }
|
||||
end
|
||||
else
|
||||
describe "when reaper_concurrency is set" do
|
||||
let :params do req_params.merge({:reaper_concurrency => 4682}) end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/\[#{t}-reaper\]\nconcurrency\s*=\s*4682\s*$/m) }
|
||||
end
|
||||
end
|
||||
|
||||
if t == 'container'
|
||||
# Nothing to test now
|
||||
end
|
||||
|
||||
if t == 'object'
|
||||
describe "when splice is not set" do
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^splice\s*=\s*false\s*$/) }
|
||||
end
|
||||
describe "when splice is set" do
|
||||
let :params do req_params.merge({ :splice => true, }) end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^splice\s*=\s*true\s*$/) }
|
||||
end
|
||||
|
||||
describe "when client_timeout is not set" do
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^client_timeout\s*=\s*60\s*$/) }
|
||||
end
|
||||
describe "when client_timeout is set" do
|
||||
let :params do req_params.merge({ :client_timeout => 30, }) end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^client_timeout\s*=\s*30\s*$/) }
|
||||
end
|
||||
|
||||
describe "when rsync_timeout is not set" do
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^rsync_timeout\s*=\s*900\s*$/) }
|
||||
end
|
||||
describe "when rsync_timeout is set" do
|
||||
let :params do req_params.merge({ :rsync_timeout => 600, }) end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^rsync_timeout\s*=\s*600\s*$/) }
|
||||
end
|
||||
|
||||
describe "when rsync_bwlimit is not set" do
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^rsync_bwlimit\s*=\s*0\s*$/) }
|
||||
end
|
||||
describe "when rsync_bwlimit is set" do
|
||||
let :params do req_params.merge({ :rsync_bwlimit => 2048, }) end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^rsync_bwlimit\s*=\s*2048\s*$/) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "when log_udp_port is set" do
|
||||
context 'and log_udp_host is not set' do
|
||||
let :params do req_params.merge({ :log_udp_port => 514}) end
|
||||
it_raises 'a Puppet::Error', /log_udp_port requires log_udp_host to be set/
|
||||
end
|
||||
context 'and log_udp_host is set' do
|
||||
let :params do req_params.merge(
|
||||
{ :log_udp_host => '127.0.0.1',
|
||||
:log_udp_port => '514'})
|
||||
end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^log_udp_host\s*=\s*127\.0\.0\.1\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^log_udp_port\s*=\s*514\s*$/) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "when using swift_#{t}_config resource" do
|
||||
let :pre_condition do
|
||||
"
|
||||
class { 'swift': swift_hash_path_suffix => 'foo' }
|
||||
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }
|
||||
swift_#{t}_config { 'foo/bar': value => 'foo' }
|
||||
"
|
||||
end
|
||||
it { is_expected.to contain_concat("/etc/swift/#{t}-server.conf").that_comes_before("Swift_#{t}_config[foo/bar]") }
|
||||
end
|
||||
|
||||
describe "when log_requests is turned off" do
|
||||
let :params do req_params.merge({:log_requests => false}) end
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_requests\s*=\s*false\s*$/) }
|
||||
end
|
||||
before do
|
||||
params.merge!({
|
||||
:pipeline => ['healthcheck', 'recon', 'container-server']
|
||||
})
|
||||
end
|
||||
|
||||
describe 'with all allowed defaults' do
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
it {
|
||||
is_expected.to contain_swift_container_config('pipeline:main/pipeline').with_value('healthcheck recon container-server')
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
it { is_expected.to contain_rsync__server__module("#{t}").with(
|
||||
:path => '/srv/node',
|
||||
:lock_file => "/var/lock/#{t}.lock",
|
||||
:uid => 'swift',
|
||||
:gid => 'swift',
|
||||
:incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
|
||||
:outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
|
||||
:max_connections => 25,
|
||||
:read_only => false
|
||||
)}
|
||||
describe 'for type object' do
|
||||
let :title do
|
||||
'6000'
|
||||
end
|
||||
|
||||
# verify template lines
|
||||
it { is_expected.to contain_concat("/etc/swift/#{t}-server.conf") }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^devices\s*=\s*\/srv\/node\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^bind_ip\s*=\s*10\.0\.0\.1\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^bind_port\s*=\s*#{title}\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^mount_check\s*=\s*true\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^user\s*=\s*swift\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_name\s*=\s*#{t}-server\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_facility\s*=\s*LOG_LOCAL2\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_level\s*=\s*INFO\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_address\s*=\s*\/dev\/log\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^set log_requests\s*=\s*true\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^workers\s*=\s*2\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^concurrency\s*=\s*1\s*$/) }
|
||||
it { is_expected.to contain_concat_fragment("swift-#{t}-#{title}").with_content(/^pipeline\s*=\s*#{t}-server\s*$/) }
|
||||
let :req_params do
|
||||
{
|
||||
:storage_local_net_ip => '10.0.0.1',
|
||||
:type => 'object'
|
||||
}
|
||||
end
|
||||
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_package('swift-object').with_ensure('present') }
|
||||
it { is_expected.to contain_service('swift-object-server').with(
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
)}
|
||||
|
||||
it { is_expected.to contain_rsync__server__module('object').with(
|
||||
:path => '/srv/node',
|
||||
:lock_file => '/var/lock/object.lock',
|
||||
:uid => 'swift',
|
||||
:gid => 'swift',
|
||||
:incoming_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
|
||||
:outgoing_chmod => 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
|
||||
:max_connections => 25,
|
||||
:read_only => false,
|
||||
)}
|
||||
|
||||
it {
|
||||
is_expected.to contain_swift_object_config('DEFAULT/devices').with_value('/srv/node')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/bind_ip').with_value('10.0.0.1')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/bind_port').with_value('6000')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/mount_check').with_value(true)
|
||||
is_expected.to contain_swift_object_config('DEFAULT/user').with_value('swift')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/workers').with_value(4)
|
||||
is_expected.to contain_swift_object_config('DEFAULT/log_name').with_value('object-server')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/log_facility').with_value('LOG_LOCAL2')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/log_level').with_value('INFO')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/log_address').with_value('/dev/log')
|
||||
is_expected.to contain_swift_object_config('pipeline:main/pipeline').with_value('object-server')
|
||||
is_expected.to contain_swift_object_config('app:object-server/use').with_value('egg:swift#object')
|
||||
is_expected.to contain_swift_object_config('app:object-server/set log_name').with_value('object-server')
|
||||
is_expected.to contain_swift_object_config('app:object-server/set log_facility').with_value('LOG_LOCAL2')
|
||||
is_expected.to contain_swift_object_config('app:object-server/set log_level').with_value('INFO')
|
||||
is_expected.to contain_swift_object_config('app:object-server/set log_requests').with_value(true)
|
||||
is_expected.to contain_swift_object_config('app:object-server/set log_address').with_value('/dev/log')
|
||||
|
||||
is_expected.to contain_swift_object_config('DEFAULT/log_statsd_host').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/log_statsd_port').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/log_statsd_default_sample_rate').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/log_statsd_sample_rate_factor').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/log_statsd_metric_prefix').with_value('<SERVICE DEFAULT>')
|
||||
|
||||
is_expected.to contain_swift_object_config('DEFAULT/servers_per_port').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/network_chunk_size').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/disk_chunk_size').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('DEFAULT/client_timeout').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('app:object-server/splice').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('app:object-server/mb_per_sync').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('object-auditor/disk_chunk_size').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('object-replicator/concurrency').with_value(1)
|
||||
is_expected.to contain_swift_object_config('object-replicator/rsync_timeout').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('object-replicator/rsync_bwlimit').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_swift_object_config('object-updater/concurrency').with_value(1)
|
||||
}
|
||||
|
||||
context 'with customized pipeline' do
|
||||
let :pre_condition do
|
||||
"class { 'swift': swift_hash_path_suffix => 'foo' }
|
||||
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }
|
||||
swift::storage::filter::healthcheck { 'object': }
|
||||
swift::storage::filter::recon { 'object': }
|
||||
"
|
||||
end
|
||||
|
||||
before do
|
||||
params.merge!({
|
||||
:pipeline => ['healthcheck', 'recon', 'object-server']
|
||||
})
|
||||
end
|
||||
|
||||
it {
|
||||
is_expected.to contain_swift_object_config('pipeline:main/pipeline').with_value('healthcheck recon object-server')
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -225,7 +308,9 @@ describe 'swift::storage::server' do
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge(OSDefaults.get_facts())
|
||||
facts.merge(OSDefaults.get_facts({
|
||||
:os_workers => 4
|
||||
}))
|
||||
end
|
||||
|
||||
it_configures 'swift::storage::server'
|
||||
|
@ -1,45 +0,0 @@
|
||||
[DEFAULT]
|
||||
devices = <%= @devices %>
|
||||
bind_ip = <%= @storage_local_net_ip %>
|
||||
bind_port = <%= @bind_port %>
|
||||
mount_check = <%= @mount_check %>
|
||||
user = <%= @user_real %>
|
||||
workers = <%= @workers %>
|
||||
log_name = <%= @log_name %>
|
||||
log_facility = <%= @log_facility %>
|
||||
log_level = <%= @log_level %>
|
||||
log_address = <%= @log_address %>
|
||||
<% if @log_udp_host -%>
|
||||
# If set, log_udp_host will override log_address
|
||||
log_udp_host = <%= @log_udp_host -%>
|
||||
<% end %>
|
||||
<% if @log_udp_host and @log_udp_port -%>
|
||||
log_udp_port = <%= @log_udp_port -%>
|
||||
<% end %>
|
||||
<%- if @statsd_enabled -%>
|
||||
log_statsd_host = <%=@log_statsd_host%>
|
||||
log_statsd_port = <%=@log_statsd_port%>
|
||||
log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%>
|
||||
log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%>
|
||||
log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%>
|
||||
<%- end -%>
|
||||
|
||||
[pipeline:main]
|
||||
pipeline = <%= @pipeline.to_a.join(' ') %>
|
||||
|
||||
[app:account-server]
|
||||
use = egg:swift#account
|
||||
set log_name = <%= @log_name %>
|
||||
set log_facility = <%= @log_facility %>
|
||||
set log_level = <%= @log_level %>
|
||||
set log_requests = <%= @log_requests %>
|
||||
set log_address = <%= @log_address %>
|
||||
|
||||
[account-replicator]
|
||||
concurrency = <%= @replicator_concurrency %>
|
||||
interval = <%= @replicator_interval %>
|
||||
|
||||
[account-auditor]
|
||||
|
||||
[account-reaper]
|
||||
concurrency = <%= @reaper_concurrency %>
|
@ -1,53 +0,0 @@
|
||||
[DEFAULT]
|
||||
devices = <%= @devices %>
|
||||
bind_ip = <%= @storage_local_net_ip %>
|
||||
bind_port = <%= @bind_port %>
|
||||
mount_check = <%= @mount_check %>
|
||||
user = <%= @user_real %>
|
||||
log_name = <%= @log_name %>
|
||||
log_facility = <%= @log_facility %>
|
||||
log_level = <%= @log_level %>
|
||||
log_address = <%= @log_address %>
|
||||
<% if @log_udp_host -%>
|
||||
# If set, log_udp_host will override log_address
|
||||
log_udp_host = <%= @log_udp_host -%>
|
||||
<% end %>
|
||||
<% if @log_udp_host and @log_udp_port -%>
|
||||
log_udp_port = <%= @log_udp_port -%>
|
||||
<% end %>
|
||||
workers = <%= @workers %>
|
||||
allowed_sync_hosts = <%= scope.lookupvar("swift::storage::container::allowed_sync_hosts").to_a.join(',') %>
|
||||
<%- if @statsd_enabled -%>
|
||||
log_statsd_host = <%=@log_statsd_host%>
|
||||
log_statsd_port = <%=@log_statsd_port%>
|
||||
log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%>
|
||||
log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%>
|
||||
log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%>
|
||||
<%- end -%>
|
||||
|
||||
[pipeline:main]
|
||||
pipeline = <%= @pipeline.to_a.join(' ') %>
|
||||
|
||||
[app:container-server]
|
||||
use = egg:swift#container
|
||||
set log_name = <%= @log_name %>
|
||||
set log_facility = <%= @log_facility %>
|
||||
set log_level = <%= @log_level %>
|
||||
set log_requests = <%= @log_requests %>
|
||||
set log_address = <%= @log_address %>
|
||||
|
||||
[container-replicator]
|
||||
concurrency = <%= @replicator_concurrency %>
|
||||
interval = <%= @replicator_interval %>
|
||||
|
||||
[container-updater]
|
||||
concurrency = <%= @updater_concurrency %>
|
||||
|
||||
[container-auditor]
|
||||
|
||||
[container-sync]
|
||||
|
||||
[container-sharder]
|
||||
auto_shard = <%= @container_sharder_auto_shard %>
|
||||
concurrency = <%= @container_sharder_concurrency %>
|
||||
interval = <%= @container_sharder_interval %>
|
@ -1,3 +0,0 @@
|
||||
|
||||
[filter:healthcheck]
|
||||
use = egg:swift#healthcheck
|
@ -1,57 +0,0 @@
|
||||
[DEFAULT]
|
||||
devices = <%= @devices %>
|
||||
bind_ip = <%= @storage_local_net_ip %>
|
||||
bind_port = <%= @bind_port %>
|
||||
mount_check = <%= @mount_check %>
|
||||
servers_per_port = <%= @servers_per_port %>
|
||||
user = <%= @user_real %>
|
||||
log_name = <%= @log_name %>
|
||||
log_facility = <%= @log_facility %>
|
||||
log_level = <%= @log_level %>
|
||||
log_address = <%= @log_address %>
|
||||
<% if @log_udp_host -%>
|
||||
# If set, log_udp_host will override log_address
|
||||
log_udp_host = <%= @log_udp_host -%>
|
||||
<% end %>
|
||||
<% if @log_udp_host and @log_udp_port -%>
|
||||
log_udp_port = <%= @log_udp_port -%>
|
||||
<% end %>
|
||||
workers = <%= @workers %>
|
||||
<% if @statsd_enabled -%>
|
||||
log_statsd_host = <%=@log_statsd_host%>
|
||||
log_statsd_port = <%=@log_statsd_port%>
|
||||
log_statsd_default_sample_rate = <%=@log_statsd_default_sample_rate%>
|
||||
log_statsd_sample_rate_factor = <%=@log_statsd_sample_rate_factor%>
|
||||
log_statsd_metric_prefix = <%=@log_statsd_metric_prefix%>
|
||||
<% end -%>
|
||||
network_chunk_size = <%= @network_chunk_size%>
|
||||
disk_chunk_size = <%= @disk_chunk_size%>
|
||||
client_timeout = <%= @client_timeout %>
|
||||
|
||||
[pipeline:main]
|
||||
pipeline = <%= @pipeline.to_a.join(' ') %>
|
||||
|
||||
[app:object-server]
|
||||
use = egg:swift#object
|
||||
set log_name = <%= @log_name %>
|
||||
set log_facility = <%= @log_facility %>
|
||||
set log_level = <%= @log_level %>
|
||||
set log_requests = <%= @log_requests %>
|
||||
set log_address = <%= @log_address %>
|
||||
splice = <%= @splice %>
|
||||
mb_per_sync = <%= @object_server_mb_per_sync %>
|
||||
|
||||
[object-replicator]
|
||||
concurrency = <%= @replicator_concurrency %>
|
||||
rsync_timeout = <%= @rsync_timeout%>
|
||||
rsync_bwlimit = <%= @rsync_bwlimit%>
|
||||
|
||||
[object-updater]
|
||||
concurrency = <%= @updater_concurrency %>
|
||||
|
||||
[object-auditor]
|
||||
<% if @auditor_disk_chunk_size -%>
|
||||
disk_chunk_size = <%= @auditor_disk_chunk_size %>
|
||||
<% end -%>
|
||||
|
||||
[object-reconstructor]
|
@ -1,4 +0,0 @@
|
||||
|
||||
[filter:recon]
|
||||
use = egg:swift#recon
|
||||
recon_cache_path = <%= @cache_path %>
|
Loading…
Reference in New Issue
Block a user