From 44b1c56d74f97b366a5477dc97a7c712690fd7e2 Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Tue, 14 Feb 2012 14:09:01 -0800 Subject: [PATCH] Renamed storage::device to storage::server Changed the name of the defined resource type: swift::storage::device to be swift::storage::server. This change was made in order to better align with the swift terminology since this define was configuring a swift component server which has no direct association with a device. This commit also makes the swift::storage::server the only place where the swift server template is used. This allowed me to assume that the variables device and bind_port will always be available. Also updates declarations of the renamed type to use the correct type name. Removes the direct server file config from swift::storage, replacing it instead with declarations of swift::storage::server. --- manifests/storage.pp | 31 +++++++++++++--------- manifests/storage/node.pp | 8 +++--- manifests/storage/{device.pp => server.pp} | 10 ++++--- templates/account-server.conf.erb | 4 --- templates/container-server.conf.erb | 4 --- templates/object-server.conf.erb | 4 --- 6 files changed, 28 insertions(+), 33 deletions(-) rename manifests/storage/{device.pp => server.pp} (73%) diff --git a/manifests/storage.pp b/manifests/storage.pp index 2dee991e..397efd47 100644 --- a/manifests/storage.pp +++ b/manifests/storage.pp @@ -21,7 +21,8 @@ class swift::storage( $package_ensure = 'present', # TODO - should this default to 0.0.0.0? - $storage_local_net_ip = '127.0.0.1' + $storage_local_net_ip = '127.0.0.1', + $devices = '/srv/nodes' ) inherits swift { @@ -42,6 +43,11 @@ class swift::storage( group => 'swift', } + Swift::Storage::Server { + devices => $devices, + storage_local_net_ip => $storage_local_net_ip, + } + # package dependencies package { ['xfsprogs', 'parted']: ensure => 'present' @@ -51,10 +57,9 @@ class swift::storage( ensure => $package_ensure, } - file { '/etc/swift/account-server.conf': - ensure => present, - mode => 0660, - content => template('swift/account-server.conf.erb') + swift::storage::server { '6002': + type => 'account', + config_file_path => 'account-server.conf', } file { '/etc/swift/account-server/': @@ -65,14 +70,14 @@ class swift::storage( provider => 'upstart', } + # container server configuration package { 'swift-container': ensure => $package_ensure, } - file { '/etc/swift/container-server.conf': - ensure => present, - mode => 0660, - content => template('swift/container-server.conf.erb') + swift::storage::server { '6001': + type => 'container', + config_file_path => 'container-server.conf', } file { '/etc/swift/container-server/': @@ -83,14 +88,14 @@ class swift::storage( provider => 'upstart', } + # object server configuration package { 'swift-object': ensure => $package_ensure, } - file { '/etc/swift/object-server.conf': - ensure => present, - mode => 0660, - content => template('swift/object-server.conf.erb') + swift::storage::server { '6000': + type => 'object', + config_file_path => 'object-server.conf', } file { '/etc/swift/object-server/': diff --git a/manifests/storage/node.pp b/manifests/storage/node.pp index 4469e719..90df96e2 100644 --- a/manifests/storage/node.pp +++ b/manifests/storage/node.pp @@ -15,7 +15,7 @@ define swift::storage::node( $manage_ring = true ) { - Swift::Storage::Device { + Swift::Storage::Server { storage_local_net_ip => $storage_local_net_ip, devices => $mnt_base_dir, max_connections => $max_connections, @@ -23,7 +23,7 @@ define swift::storage::node( group => $group, } - swift::storage::device { "60${name}0": + swift::storage::server { "60${name}0": type => 'object', } ring_object_device { "${storage_local_net_ip}:60${name}0": @@ -32,7 +32,7 @@ define swift::storage::node( weight => $weight, } - swift::storage::device { "60${name}1": + swift::storage::server { "60${name}1": type => 'container', } ring_container_device { "${storage_local_net_ip}:60${name}1": @@ -41,7 +41,7 @@ define swift::storage::node( weight => $weight, } - swift::storage::device { "60${name}2": + swift::storage::server { "60${name}2": type => 'account', } ring_account_device { "${storage_local_net_ip}:60${name}2": diff --git a/manifests/storage/device.pp b/manifests/storage/server.pp similarity index 73% rename from manifests/storage/device.pp rename to manifests/storage/server.pp index d0ed32a0..e806a38c 100644 --- a/manifests/storage/device.pp +++ b/manifests/storage/server.pp @@ -3,13 +3,15 @@ # - should it be device? # # name - is going to be port -define swift::storage::device( +define swift::storage::server( $type, $devices = '/srv/node', $owner = 'swift', $group = 'swift', $max_connections = 25, - $storage_local_net_ip = '127.0.0.1' + $storage_local_net_ip = '127.0.0.1', + # this parameters needs to be specified after type and name + $config_file_path = "${type}-server/${name}.conf" ) { validate_re($name, '^\d+$') @@ -19,7 +21,7 @@ define swift::storage::device( # This makes me think that perhaps the rsync class # should be split into install and config # - Swift::Storage::Device[$name] ~> Service['rsync'] + Swift::Storage::Server[$name] ~> Service['rsync'] $bind_port = $name @@ -32,7 +34,7 @@ define swift::storage::device( read_only => false, } - file { "/etc/swift/${type}-server/${name}.conf": + file { "/etc/swift/${config_file_path}": content => template("swift/${type}-server.conf.erb"), owner => $owner, group => $group, diff --git a/templates/account-server.conf.erb b/templates/account-server.conf.erb index 069528f1..52f49f1e 100644 --- a/templates/account-server.conf.erb +++ b/templates/account-server.conf.erb @@ -1,11 +1,7 @@ [DEFAULT] -<% if has_variable?('devices') -%> devices = <%= devices %> -<% end -%> bind_ip = <%= storage_local_net_ip %> -<% if has_variable?('bind_port') -%> bind_port = <%= bind_port %> -<% end -%> mount_check = false user = swift log_facility = LOG_LOCAL2 diff --git a/templates/container-server.conf.erb b/templates/container-server.conf.erb index b07296e0..de27c6c2 100644 --- a/templates/container-server.conf.erb +++ b/templates/container-server.conf.erb @@ -1,11 +1,7 @@ [DEFAULT] -<% if has_variable?('devices') -%> devices = <%= devices %> -<% end -%> bind_ip = <%= storage_local_net_ip %> -<% if has_variable?('bind_port') -%> bind_port = <%= bind_port %> -<% end -%> mount_check = false user = swift log_facility = LOG_LOCAL2 diff --git a/templates/object-server.conf.erb b/templates/object-server.conf.erb index 20f71d95..4eea4ddf 100644 --- a/templates/object-server.conf.erb +++ b/templates/object-server.conf.erb @@ -1,11 +1,7 @@ [DEFAULT] -<% if has_variable?('devices') -%> devices = <%= devices %> -<% end -%> bind_ip = <%= storage_local_net_ip %> -<% if has_variable?('bind_port') -%> bind_port = <%= bind_port %> -<% end -%> mount_check = false user = swift log_facility = LOG_LOCAL2