-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for swift-object-expirer service
The swift-object-expirer service was not supported by puppet-swift. Adding support by creating a new class (swift::objectexpirer), and its associated custom type/provider. Change-Id: I498ffe525a7316c0091e4c9d8b7d9658234231f6
- Loading branch information
1 parent
c298933
commit bf329c9
Showing
5 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
swift/lib/puppet/provider/swift_object_expirer_config/ini_setting.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Puppet::Type.type(:swift_object_expirer_config).provide( | ||
:ini_setting, | ||
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) | ||
) do | ||
|
||
def self.file_path | ||
'/etc/swift/object-expirer.conf' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Puppet::Type.newtype(:swift_object_expirer_config) do | ||
|
||
ensurable | ||
|
||
newparam(:name, :namevar => true) do | ||
desc 'Section/setting name to manage from /etc/swift/object-expirer.conf' | ||
newvalues(/\S+\/\S+/) | ||
end | ||
|
||
newproperty(:value) do | ||
desc 'The value of the setting to be defined.' | ||
munge do |value| | ||
value = value.to_s.strip | ||
value.capitalize! if value =~ /^(true|false)$/i | ||
value | ||
end | ||
|
||
def is_to_s( currentvalue ) | ||
if resource.secret? | ||
return '[old secret redacted]' | ||
else | ||
return currentvalue | ||
end | ||
end | ||
|
||
def should_to_s( newvalue ) | ||
if resource.secret? | ||
return '[new secret redacted]' | ||
else | ||
return newvalue | ||
end | ||
end | ||
end | ||
|
||
newparam(:secret, :boolean => true) do | ||
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.' | ||
newvalues(:true, :false) | ||
defaultto false | ||
end | ||
|
||
newparam(:ensure_absent_val) do | ||
desc 'A value that is specified as the value property will behave as if ensure => absent was specified' | ||
defaultto('<SERVICE DEFAULT>') | ||
end | ||
|
||
# Require the package providing object-expirer to be present | ||
if Facter['osfamily'].value == 'Debian' | ||
autorequire(:package) do | ||
'swift-object-expirer' | ||
end | ||
elsif Facter['osfamily'].value == 'RedHat' | ||
autorequire(:package) do | ||
'openstack-swift-proxy' | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Class swift::objectexpirer | ||
# | ||
# == Parameters | ||
# [*enabled*] | ||
# (optional) Should the service be enabled. | ||
# Defaults to true | ||
# | ||
# [*manage_service*] | ||
# (optional) Whether the service should be managed by Puppet. | ||
# Defaults to true. | ||
# | ||
# [*package_ensure*] | ||
# (optional) Value of package resource parameter 'ensure'. | ||
# Defaults to 'present'. | ||
# | ||
# [*pipeline*] | ||
# (optional) The list of elements of the object expirer pipeline. | ||
# Defaults to ['catch_errors', 'cache', 'proxy-server'] | ||
# | ||
# [*auto_create_account_prefix*] | ||
# (optional) Prefix to use when automatically creating accounts. | ||
# Defaults to '.'. | ||
# | ||
# [*concurrency*] | ||
# (optional) Number of replication workers to spawn. | ||
# Defaults to 1. | ||
# | ||
# [*expiring_objects_account_name*] | ||
# (optional) Account name used for expiring objects. | ||
# Defaults to 'expiring_objects'. | ||
# | ||
# [*interval*] | ||
# (optional) Minimum time for a pass to take. | ||
# Defaults to 300. | ||
# | ||
# [*process*] | ||
# (optional) Which part of the work defined by $processes | ||
# will this instance take. | ||
# Defaults to 0. | ||
# | ||
# [*processes*] | ||
# (optional) How many parts to divide the work into, one part per | ||
# process. 0 means a single process will do all work. | ||
# Defaults to 0. | ||
# | ||
# [*reclaim_age*] | ||
# (optional) Time elapsed in seconds before an object can be | ||
# reclaimed. | ||
# Defaults to 604800 (1 week). | ||
# | ||
# [*recon_cache_path*] | ||
# (optional) Directory where stats for a few items will be stored. | ||
# Defaults to '/var/cache/swift'. | ||
# | ||
# [*report_interval*] | ||
# (optional) Report interval | ||
# Defaults to 300. | ||
# | ||
|
||
class swift::objectexpirer( | ||
$manage_service = true, | ||
$enabled = true, | ||
$package_ensure = 'present', | ||
$pipeline = ['catch_errors', 'cache', 'proxy-server'], | ||
$auto_create_account_prefix = '.', | ||
$concurrency = 1, | ||
$expiring_objects_account_name = 'expiring_objects', | ||
$interval = 300, | ||
$process = 0, | ||
$processes = 0, | ||
$reclaim_age = 604800, | ||
$recon_cache_path = '/var/cache/swift', | ||
$report_interval = 300, | ||
) { | ||
|
||
include ::swift::params | ||
|
||
Swift_config<| |> ~> Service['swift-object-expirer'] | ||
Swift_object_expirer_config<||> ~> Service['swift-object-expirer'] | ||
|
||
# On Red Hat platforms, it may be defined already, | ||
# because it is part of openstack-swift-proxy | ||
if $::swift::params::object_expirer_package_name != $::swift::params::proxy_package_name { | ||
package { 'swift-object-expirer': | ||
ensure => $package_ensure, | ||
name => $::swift::params::object_expirer_package_name, | ||
tag => ['openstack', 'swift-package'], | ||
} | ||
} | ||
|
||
swift_object_expirer_config { | ||
'pipeline:main/pipeline': value => join($pipeline, ' '); | ||
'object-expirer/auto_create_account_prefix': value => $auto_create_account_prefix; | ||
'object-expirer/concurrency': value => $concurrency; | ||
'object-expirer/expiring_objects_account_name': value => $expiring_objects_account_name; | ||
'object-expirer/interval': value => $interval; | ||
'object-expirer/process': value => $process; | ||
'object-expirer/processes': value => $processes; | ||
'object-expirer/reclaim_age': value => $reclaim_age; | ||
'object-expirer/recon_cache_path': value => $recon_cache_path; | ||
'object-expirer/report_interval': value => $report_interval; | ||
} | ||
|
||
if $manage_service { | ||
if $enabled { | ||
$service_ensure = 'running' | ||
} else { | ||
$service_ensure = 'stopped' | ||
} | ||
} | ||
|
||
service { 'swift-object-expirer': | ||
ensure => $service_ensure, | ||
name => $::swift::params::object_expirer_service_name, | ||
enable => $enabled, | ||
provider => $::swift::params::service_provider, | ||
tag => 'swift-service', | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters