Refactor of swift server configs
This commit performs a refactor of the swift::storage::config to use fragments. Updates server templates - makes workers,user, and mount_checks configurable - adds a default for concurrency - makes the pipeline configurable - remove vm_test_mode flag Updates swift::storage::server to use fragments for the config file. This has been refactored to allow the end user a greater level of flexibility over how they can configure custom plugins for swift. Also adds additional class params: pipeline, mount_check, user, workers, concurrency. Update the unit tests for swift::storage:server
This commit is contained in:
parent
aaf2784c73
commit
59afc07d3b
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ spec/fixtures/modules/rsync
|
|||||||
spec/fixtures/modules/ssh
|
spec/fixtures/modules/ssh
|
||||||
spec/fixtures/modules/stdlib
|
spec/fixtures/modules/stdlib
|
||||||
spec/fixtures/modules/xinetd
|
spec/fixtures/modules/xinetd
|
||||||
|
spec/fixtures/modules/*
|
||||||
|
@ -10,11 +10,25 @@ define swift::storage::server(
|
|||||||
$owner = 'swift',
|
$owner = 'swift',
|
||||||
$group = 'swift',
|
$group = 'swift',
|
||||||
$max_connections = 25,
|
$max_connections = 25,
|
||||||
|
$pipeline = ["${type}-server"],
|
||||||
|
$mount_check = 'false',
|
||||||
|
$user = 'swift',
|
||||||
|
$workers = '1',
|
||||||
|
$concurrency = $::processorcount,
|
||||||
# this parameters needs to be specified after type and name
|
# this parameters needs to be specified after type and name
|
||||||
$config_file_path = "${type}-server/${name}.conf"
|
$config_file_path = "${type}-server/${name}.conf"
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
# TODO if array does not include type-server, warn
|
||||||
|
if(
|
||||||
|
(is_array($pipeline) and ! member($pipeline, "${type}-server")) or
|
||||||
|
$pipline != "${type}-server"
|
||||||
|
) {
|
||||||
|
warning("swift storage server ${type} must specify ${type}-server")
|
||||||
|
}
|
||||||
|
|
||||||
include "swift::storage::$type"
|
include "swift::storage::$type"
|
||||||
|
include 'concat::setup'
|
||||||
|
|
||||||
validate_re($name, '^\d+$')
|
validate_re($name, '^\d+$')
|
||||||
validate_re($type, '^object|container|account$')
|
validate_re($type, '^object|container|account$')
|
||||||
@ -31,11 +45,17 @@ define swift::storage::server(
|
|||||||
read_only => false,
|
read_only => false,
|
||||||
}
|
}
|
||||||
|
|
||||||
file { "/etc/swift/${config_file_path}":
|
concat { "/etc/swift/${config_file_path}":
|
||||||
content => template("swift/${type}-server.conf.erb"),
|
|
||||||
owner => $owner,
|
owner => $owner,
|
||||||
group => $group,
|
group => $group,
|
||||||
notify => Service["swift-${type}"],
|
notify => Service["swift-${type}"],
|
||||||
|
mode => 640,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ describe 'swift::storage::server' do
|
|||||||
let :facts do
|
let :facts do
|
||||||
{
|
{
|
||||||
:operatingsystem => 'Ubuntu',
|
:operatingsystem => 'Ubuntu',
|
||||||
:osfamily => 'Debian'
|
:osfamily => 'Debian',
|
||||||
|
:processorcount => 1
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -21,8 +22,6 @@ describe 'swift::storage::server' do
|
|||||||
:max_connections => '25'}
|
:max_connections => '25'}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
describe 'with an invalid title' do
|
describe 'with an invalid title' do
|
||||||
let :params do
|
let :params do
|
||||||
{:storage_local_net_ip => '127.0.0.1',
|
{:storage_local_net_ip => '127.0.0.1',
|
||||||
@ -39,66 +38,97 @@ describe 'swift::storage::server' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
['account', 'object', 'container'].each do |t|
|
['account', 'object', 'container'].each do |t|
|
||||||
[{:storage_local_net_ip => '10.0.0.1',
|
|
||||||
:type => t},
|
describe "for type #{t}" do
|
||||||
{:storage_local_net_ip => '127.0.0.1',
|
|
||||||
:type => t}
|
|
||||||
].each do |param_set|
|
|
||||||
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
|
|
||||||
let :title do
|
let :title do
|
||||||
'8000'
|
'8000'
|
||||||
end
|
end
|
||||||
let :param_hash do
|
|
||||||
default_params.merge(param_set)
|
let :req_params do
|
||||||
|
{:storage_local_net_ip => '10.0.0.1', :type => t}
|
||||||
end
|
end
|
||||||
let :params do
|
let :params do
|
||||||
param_set
|
req_params
|
||||||
end
|
|
||||||
let :config_file_path do
|
|
||||||
"#{t}-server/#{title}.conf"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should contain_package("swift-#{t}").with_ensure('present') }
|
it { should contain_package("swift-#{t}").with_ensure('present') }
|
||||||
it { should contain_service("swift-#{t}").with(
|
it { should contain_service("swift-#{t}").with(
|
||||||
:ensure => 'running',
|
:ensure => 'running',
|
||||||
:enable => true,
|
:enable => true,
|
||||||
:hasstatus => true
|
:hasstatus => true
|
||||||
)}
|
)}
|
||||||
it { should contain_file("/etc/swift/#{t}-server/").with(
|
let :fragment_file do
|
||||||
:ensure => 'directory',
|
"/var/lib/puppet/concat/_etc_swift_#{t}-server_#{title}.conf/fragments/00_swift-#{t}-#{title}"
|
||||||
:owner => 'swift',
|
end
|
||||||
:group => 'swift'
|
|
||||||
)}
|
describe 'when parameters are overridden' do
|
||||||
it { should contain_rsync__server__module("#{t}#{title}").with(
|
{
|
||||||
:path => param_hash[:devices],
|
:devices => '/tmp/foo',
|
||||||
:lock_file => "/var/lock/#{t}#{title}.lock",
|
:user => 'dan',
|
||||||
:uid => param_hash[:owner],
|
:mount_check => true,
|
||||||
:gid => param_hash[:group],
|
:concurrency => 5,
|
||||||
:max_connections => param_hash[:max_connections],
|
:workers => 7,
|
||||||
:read_only => false
|
:pipeline => 'foo'
|
||||||
)}
|
}.each do |k,v|
|
||||||
it { should contain_file("/etc/swift/#{config_file_path}").with(
|
describe "when #{k} is set" do
|
||||||
:owner => param_hash[:owner],
|
let :params do req_params.merge({k => v}) end
|
||||||
:group => param_hash[:group]
|
it { should contain_file(fragment_file) \
|
||||||
)}
|
.with_content(/^#{k.to_s}\s*=\s*#{v}\s*$/)
|
||||||
it 'should have some contents' do
|
}
|
||||||
content = param_value(
|
end
|
||||||
subject,
|
describe "when pipline is passed an array" do
|
||||||
'file', "/etc/swift/#{config_file_path}",
|
let :params do req_params.merge({:pipeline => [1,2,3]}) end
|
||||||
'content'
|
it { should contain_file(fragment_file) \
|
||||||
)
|
.with_content(/^pipeline\s*=\s*1 2 3\s*$/)
|
||||||
expected_lines =
|
}
|
||||||
[
|
end
|
||||||
'[DEFAULT]',
|
|
||||||
"devices = #{param_hash[:devices]}",
|
|
||||||
"bind_ip = #{param_hash[:storage_local_net_ip]}",
|
|
||||||
"bind_port = #{title}"
|
|
||||||
]
|
|
||||||
(content.split("\n") & expected_lines).should =~ expected_lines
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO - I do not want to add tests for the upstart stuff
|
describe 'with all allowed defaults' do
|
||||||
# I need to check the tickets and see if this stuff is fixed
|
let :params do
|
||||||
|
req_params
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should contain_rsync__server__module("#{t}#{title}").with(
|
||||||
|
:path => '/srv/node',
|
||||||
|
:lock_file => "/var/lock/#{t}#{title}.lock",
|
||||||
|
:uid => 'swift',
|
||||||
|
:gid => 'swift',
|
||||||
|
:max_connections => 25,
|
||||||
|
:read_only => false
|
||||||
|
)}
|
||||||
|
|
||||||
|
# verify template lines
|
||||||
|
it { should contain_file(fragment_file) \
|
||||||
|
.with_content(/^devices\s*=\s*\/srv\/node\s*$/)
|
||||||
|
}
|
||||||
|
it { should contain_file(fragment_file) \
|
||||||
|
.with_content(/^bind_ip\s*=\s*10\.0\.0\.1\s*$/)
|
||||||
|
}
|
||||||
|
it { should contain_file(fragment_file) \
|
||||||
|
.with_content(/^bind_port\s*=\s*#{title}\s*$/)
|
||||||
|
}
|
||||||
|
it { should contain_file(fragment_file) \
|
||||||
|
.with_content(/^mount_check\s*=\s*false\s*$/)
|
||||||
|
}
|
||||||
|
it { should contain_file(fragment_file) \
|
||||||
|
.with_content(/^user\s*=\s*swift\s*$/)
|
||||||
|
}
|
||||||
|
it { should contain_file(fragment_file) \
|
||||||
|
.with_content(/^log_facility\s*=\s*LOG_LOCAL2\s*$/)
|
||||||
|
}
|
||||||
|
it { should contain_file(fragment_file) \
|
||||||
|
.with_content(/^workers\s*=\s*1\s*$/)
|
||||||
|
}
|
||||||
|
it { should contain_file(fragment_file) \
|
||||||
|
.with_content(/^concurrency\s*=\s*1\s*$/)
|
||||||
|
}
|
||||||
|
it { should contain_file(fragment_file) \
|
||||||
|
.with_content(/^pipeline\s*=\s*#{t}-server\s*$/)
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,11 @@ def param_value(subject, type, title, param)
|
|||||||
subject.resource(type, title).send(:parameters)[param.to_sym]
|
subject.resource(type, title).send(:parameters)[param.to_sym]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def verify_contents(subject, title, expected_lines)
|
||||||
|
content = subject.resource('file', title).send(:parameters)[:content]
|
||||||
|
(content.split("\n") & expected_lines).should == expected_lines
|
||||||
|
end
|
||||||
|
|
||||||
RSpec.configure do |c|
|
RSpec.configure do |c|
|
||||||
c.module_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures/modules'))
|
c.module_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures/modules'))
|
||||||
# Using an empty site.pp file to avoid: https://github.com/rodjek/rspec-puppet/issues/15
|
# Using an empty site.pp file to avoid: https://github.com/rodjek/rspec-puppet/issues/15
|
||||||
|
@ -2,19 +2,19 @@
|
|||||||
devices = <%= devices %>
|
devices = <%= devices %>
|
||||||
bind_ip = <%= storage_local_net_ip %>
|
bind_ip = <%= storage_local_net_ip %>
|
||||||
bind_port = <%= bind_port %>
|
bind_port = <%= bind_port %>
|
||||||
mount_check = false
|
mount_check = <%= mount_check %>
|
||||||
user = swift
|
user = <%= user %>
|
||||||
log_facility = LOG_LOCAL2
|
log_facility = LOG_LOCAL2
|
||||||
workers = 2
|
workers = <%= workers %>
|
||||||
|
concurrency = <%= concurrency %>
|
||||||
|
|
||||||
[pipeline:main]
|
[pipeline:main]
|
||||||
pipeline = account-server
|
pipeline = <%= pipeline.to_a.join(' ') %>
|
||||||
|
|
||||||
[app:account-server]
|
[app:account-server]
|
||||||
use = egg:swift#account
|
use = egg:swift#account
|
||||||
|
|
||||||
[account-replicator]
|
[account-replicator]
|
||||||
vm_test_mode = yes
|
|
||||||
|
|
||||||
[account-auditor]
|
[account-auditor]
|
||||||
|
|
||||||
|
@ -2,19 +2,19 @@
|
|||||||
devices = <%= devices %>
|
devices = <%= devices %>
|
||||||
bind_ip = <%= storage_local_net_ip %>
|
bind_ip = <%= storage_local_net_ip %>
|
||||||
bind_port = <%= bind_port %>
|
bind_port = <%= bind_port %>
|
||||||
mount_check = false
|
mount_check = <%= mount_check %>
|
||||||
user = swift
|
user = <%= user %>
|
||||||
log_facility = LOG_LOCAL2
|
log_facility = LOG_LOCAL2
|
||||||
workers = 2
|
workers = <%= workers %>
|
||||||
|
concurrency = <%= concurrency %>
|
||||||
|
|
||||||
[pipeline:main]
|
[pipeline:main]
|
||||||
pipeline = container-server
|
pipeline = <%= pipeline.to_a.join(' ') %>
|
||||||
|
|
||||||
[app:container-server]
|
[app:container-server]
|
||||||
use = egg:swift#container
|
use = egg:swift#container
|
||||||
|
|
||||||
[container-replicator]
|
[container-replicator]
|
||||||
vm_test_mode = yes
|
|
||||||
|
|
||||||
[container-updater]
|
[container-updater]
|
||||||
|
|
||||||
|
@ -2,19 +2,19 @@
|
|||||||
devices = <%= devices %>
|
devices = <%= devices %>
|
||||||
bind_ip = <%= storage_local_net_ip %>
|
bind_ip = <%= storage_local_net_ip %>
|
||||||
bind_port = <%= bind_port %>
|
bind_port = <%= bind_port %>
|
||||||
mount_check = false
|
mount_check = <%= mount_check %>
|
||||||
user = swift
|
user = <%= user %>
|
||||||
log_facility = LOG_LOCAL2
|
log_facility = LOG_LOCAL2
|
||||||
workers = 2
|
workers = <%= workers %>
|
||||||
|
concurrency = <%= concurrency %>
|
||||||
|
|
||||||
[pipeline:main]
|
[pipeline:main]
|
||||||
pipeline = object-server
|
pipeline = <%= pipeline.to_a.join(' ') %>
|
||||||
|
|
||||||
[app:object-server]
|
[app:object-server]
|
||||||
use = egg:swift#object
|
use = egg:swift#object
|
||||||
|
|
||||||
[object-replicator]
|
[object-replicator]
|
||||||
vm_test_mode = yes
|
|
||||||
|
|
||||||
[object-updater]
|
[object-updater]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user