Manage swift with swiftinit service provider
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
This commit is contained in:
parent
b62ed3a5ca
commit
5a7d18975f
77
README.md
77
README.md
@ -22,7 +22,7 @@ The swift module is a part of [OpenStack](https://github.com/openstack), an effo
|
||||
Module Description
|
||||
------------------
|
||||
|
||||
The swift module is a thorough attempt to make Puppet capable of managing the entirety of swift. This includes manifests to provision such things as keystone, storage backends, proxies, and the ring. Types are shipped as part of the swift module to assist in manipulation of configuration files. The classes in this module will deploy Swift using best practices for a typical deployment.
|
||||
The swift module is a thorough attempt to make Puppet capable of managing the entirety of swift. This includes manifests to provision such things as keystone, storage backends, proxies, and the ring. Types are shipped as part of the swift module to assist in manipulation of configuration files. A custom service provider built around the swift-init tool is also provided as an option for enhanced swift service management. The classes in this module will deploy Swift using best practices for a typical deployment.
|
||||
|
||||
This module is tested in combination with other modules needed to build and leverage an entire Openstack software stack. These modules can be found, all pulled together in the [openstack module](https://github.com/stackforge/puppet-openstack). In addition, this module requires Puppet's [exported resources](http://docs.puppetlabs.com/puppet/3/reference/lang_exported.html).
|
||||
|
||||
@ -88,8 +88,7 @@ class { 'swift::storage::all':
|
||||
weight => 1,
|
||||
}
|
||||
|
||||
Swift::Ringsync<<||>>
|
||||
```
|
||||
Swift::Ringsync<<||>>```
|
||||
|
||||
Usage
|
||||
-----
|
||||
@ -245,6 +244,76 @@ class { 'swift::objectexpirer': }
|
||||
|
||||
It is assumed that the object expirer service will usually be installed in a proxy node. On Red Hat-based distributions, if the class is included in a non-proxy node, the openstack-swift-proxy package will need to be installed.
|
||||
|
||||
|
||||
##Swiftinit service provider
|
||||
|
||||
The 'swiftinit' provider is a custom provider of the service type.
|
||||
|
||||
"Swift services are generally managed with swift-init. the general usage is swift-init <service> <command>, where service is the swift service to manage (for example object, container, account, proxy)"
|
||||
From http://docs.openstack.org/developer/swift/admin_guide.html#managing-services
|
||||
|
||||
This new provider is intended to improve puppet-swift deployments in the following ways:
|
||||
|
||||
* The default service provider for puppet-swift is to use distribution specific service providers such as systemd and upstart. If distribution provided init scripts do not specify the full range of service commands, puppet will fall back to methods such as process name matching which is not very reliable. For example, if you were to tail a log file with the same name as a swift process, puppet will interpret that process table match as the swift-proxy service running and fail to start the swift service.
|
||||
* Minimize customer impact: Using the swiftinit service provider enables more specific and targeted control of swift services. Swift-init provides grateful stop/start reload/restart of swift services which will allow swift processes to finish any current requests before completely stopping the old processes.
|
||||
* Specific control of services starting at boot is implemented by adding or removing
|
||||
a templated init or services file. This is managed by this provider. For EL and non Ubuntu Debian OS types, this provider will also make calls out to systemctl reload and systemctl enable/disable.
|
||||
* Future use of the swiftinit provider is planed to allow for starting multiple servers using swift-init and multiple configuration files, to support a dedicated replication network.
|
||||
|
||||
|
||||
### Using the swiftinit service provider
|
||||
* To use the swiftinit service provider set "service_provider" on the supported components you have defined in your config manifest.
|
||||
|
||||
Setting: `service_provider => 'swiftinit'`
|
||||
Is supported on the following components:
|
||||
|
||||
* swift::storage:all
|
||||
* swift::storage:node
|
||||
* swift::storage:server
|
||||
* swift::storage::(account|container|object)
|
||||
* swift::proxy
|
||||
|
||||
Moving from the default service providers to the swiftinit service provider is supported. On the next puppet run after setting the swiftinit service provider swift services are stopped on the old provider and immediately started using swift-init. This provides a supported upgrade path with no down time.
|
||||
|
||||
The swiftinit service provider uses the following service type parameters to
|
||||
manage swift services in a non standard way.
|
||||
|
||||
* `manifest` is used to pass in the config file the service should be
|
||||
configured with. Ex `object-server.conf`
|
||||
* `pattern` is used to pass in the debian/redhat osfamily specific service names as found in params.pp. Used to match names on services files as provided by distro packages. Debian/Ubuntu service names already match names used by swift-init.
|
||||
|
||||
To aid with input validation to the swiftinit provider there is a defined type swift::service
|
||||
|
||||
### Class: swift::service
|
||||
|
||||
This is a wrapper defined type for the swift service providers.
|
||||
It provides a centraziled location to manage and validate in put for use to the default
|
||||
as well as the swiftinit service providers.
|
||||
|
||||
####`namevar`
|
||||
The namevar/title of swift::service must be one of the swift_init_service_names listed in swift::params.pp.
|
||||
These names are parsed by the swiftinit provider to provide service management as well as template boot files.
|
||||
|
||||
####`os_family_service_name`
|
||||
The distribution specific service name from swift::params. This name is passed to the default service provider.
|
||||
This name is used by the swiftinit provider to match on default provider service names when moving from a default
|
||||
provider to the swiftinit provider. The swiftinit provider also uses the service_name to manage service and init files.
|
||||
|
||||
####`config_file_name`
|
||||
The swift service configuration file name. It must be one of the following:
|
||||
object-server.conf, account-server.conf, container-server.conf, proxy-server.conf, object-expirer.conf.
|
||||
|
||||
####`service_ensure`
|
||||
The state of the service to ensure, running or stopped.
|
||||
|
||||
####`enabled`
|
||||
Should the service be enabled to start at boot.
|
||||
|
||||
####`service_provider`
|
||||
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. Defaults to $::swift::params::service_provider.
|
||||
|
||||
|
||||
### Verifying installation
|
||||
|
||||
This modules ships with a simple Ruby script that validates whether or not your swift cluster is functional.
|
||||
@ -258,7 +327,7 @@ Implementation
|
||||
|
||||
### swift
|
||||
|
||||
swift is a combination of Puppet manifest and ruby code to delivery configuration and extra functionality through types and providers.
|
||||
puppet-swift is a combination of Puppet manifest and ruby code to deliver configuration and extra functionality through types and providers.
|
||||
|
||||
### Types
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
# Temporarily managed by Puppet until
|
||||
# 931893 is resolved
|
||||
# swift-account-server - SWIFT Object Server
|
||||
#
|
||||
# The swift account server.
|
||||
|
||||
description "SWIFT Account Server"
|
||||
author "Marc Cluet <marc.cluet@ubuntu.com>"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [016]
|
||||
|
||||
pre-start script
|
||||
if [ $(find /etc/swift/account-server/ -type f 2>/dev/null | wc -l) -gt 0 ]; then
|
||||
exec /usr/bin/swift-init account-server start
|
||||
elif [ -f /etc/swift/account-server.conf ]; then
|
||||
exec /usr/bin/swift-init account-server start
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
end script
|
||||
|
||||
post-stop exec /usr/bin/swift-init account-server stop
|
@ -1,20 +0,0 @@
|
||||
# swift-container-sync - SWIFT Container Sync
|
||||
#
|
||||
# The swift container sync.
|
||||
|
||||
description "SWIFT Container Sync"
|
||||
author "Sergio Rubio <rubiojr@bvox.net>"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [016]
|
||||
|
||||
pre-start script
|
||||
if [ -f "/etc/swift/container-server.conf" ]; then
|
||||
exec /usr/bin/swift-init container-sync start
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
end script
|
||||
|
||||
post-stop exec /usr/bin/swift-init container-sync stop
|
||||
|
@ -1,23 +0,0 @@
|
||||
# Temporarily managed by Puppet until
|
||||
# 931893 is resolved
|
||||
# swift-container-server - SWIFT Object Server
|
||||
#
|
||||
# The swift container server.
|
||||
|
||||
description "SWIFT Container Server"
|
||||
author "Marc Cluet <marc.cluet@ubuntu.com>"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [016]
|
||||
|
||||
pre-start script
|
||||
if [ $(find /etc/swift/container-server/ -type f 2>/dev/null | wc -l) -gt 0 ]; then
|
||||
exec /usr/bin/swift-init container-server start
|
||||
elif [ -f /etc/swift/container-server.conf ]; then
|
||||
exec /usr/bin/swift-init container-server start
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
end script
|
||||
|
||||
post-stop exec /usr/bin/swift-init container-server stop
|
@ -1,23 +0,0 @@
|
||||
# Temporarily managed by Puppet until
|
||||
# 931893 is resolved
|
||||
# swift-object-server - SWIFT Object Server
|
||||
#
|
||||
# The swift object server.
|
||||
|
||||
description "SWIFT Object Server"
|
||||
author "Marc Cluet <marc.cluet@ubuntu.com>"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [016]
|
||||
|
||||
pre-start script
|
||||
if [ $(find /etc/swift/object-server/ -type f 2>/dev/null | wc -l) -gt 0 ]; then
|
||||
exec /usr/bin/swift-init object-server start
|
||||
elif [ -f /etc/swift/object-server.conf ]; then
|
||||
exec /usr/bin/swift-init object-server start
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
end script
|
||||
|
||||
post-stop exec /usr/bin/swift-init object-server stop
|
202
lib/puppet/provider/service/swiftinit.rb
Normal file
202
lib/puppet/provider/service/swiftinit.rb
Normal file
@ -0,0 +1,202 @@
|
||||
# swift-init service management
|
||||
#
|
||||
# author Adam Vinsh <adam.vinsh@twcable.com>
|
||||
Puppet::Type.type(:service).provide :swiftinit, :parent => :service do
|
||||
desc 'Manage swift services using swift-init'
|
||||
|
||||
has_feature :enableable
|
||||
has_feature :refreshable
|
||||
|
||||
confine :any => [
|
||||
Facter.value(:osfamily) == 'Debian',
|
||||
Facter.value(:osfamily) == 'RedHat'
|
||||
]
|
||||
|
||||
# Check if swift service is running using swift-init
|
||||
def status
|
||||
if swiftinit_run('status', false).exitstatus == 0
|
||||
return :running
|
||||
else
|
||||
# Transition block for systemd systems. If swift-init reports service is
|
||||
# not running then send stop to systemctl so that service can be started
|
||||
# with swift-init and fully managed by this provider.
|
||||
if Facter.value(:operatingsystem) != 'Ubuntu'
|
||||
systemctl_run('stop', [resource[:pattern]], false)
|
||||
systemctl_run('disable', [resource[:pattern]], false)
|
||||
end
|
||||
return :stopped
|
||||
end
|
||||
end
|
||||
|
||||
# Start this swift service using swift-init
|
||||
def start
|
||||
swiftinit_run('start', true)
|
||||
end
|
||||
|
||||
# Stop this swift service using swift-init allowing
|
||||
# current requests to finish on supporting servers
|
||||
def stop
|
||||
swiftinit_run('shutdown', true)
|
||||
end
|
||||
|
||||
# Restart this swift service using swift-init reload,
|
||||
# graceful shutdown then restart on supporting servers
|
||||
def restart
|
||||
swiftinit_run('reload', true)
|
||||
end
|
||||
|
||||
def refresh
|
||||
if (@paramaters[:ensure] == running)
|
||||
provider.restart
|
||||
else
|
||||
debug 'Skipping restart, service is not running'
|
||||
end
|
||||
end
|
||||
|
||||
# Returns service enabled status using systemctl on Redhat/Debian
|
||||
# and using presence of init file on Ubuntu.
|
||||
def enabled?
|
||||
if Facter.value(:operatingsystem) != 'Ubuntu'
|
||||
if Puppet::FileSystem.exist?("/etc/systemd/system/#{resource[:pattern]}.service")
|
||||
if systemctl_run('is-enabled', [resource[:pattern]], false).exitstatus == 0
|
||||
return :true
|
||||
end
|
||||
else
|
||||
return :false
|
||||
end
|
||||
elsif Facter.value(:operatingsystem) == 'Ubuntu'
|
||||
if Puppet::FileSystem.exist?("/etc/init/#{resource[:pattern]}.conf")
|
||||
return :true
|
||||
else
|
||||
return :false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Enable the service at boot. For Redhat and Debian create services
|
||||
# file and notify systemctl. For Ubuntu create init file.
|
||||
def enable
|
||||
if Facter.value(:operatingsystem) != 'Ubuntu'
|
||||
file = Puppet::Type.type(:file).new(
|
||||
:name => "/etc/systemd/system/#{resource[:pattern]}.service",
|
||||
:ensure => :present,
|
||||
:content => systemd_template,
|
||||
:mode => '0644'
|
||||
)
|
||||
file.write(file)
|
||||
systemctl_run('daemon-reload', nil, true)
|
||||
systemctl_run('enable', [resource[:pattern]], false)
|
||||
elsif Facter.value(:operatingsystem) == 'Ubuntu'
|
||||
file = Puppet::Type.type(:file).new(
|
||||
:name => "/etc/init/#{resource[:pattern]}.conf",
|
||||
:ensure => :present,
|
||||
:content => upstart_template,
|
||||
:mode => '0644'
|
||||
)
|
||||
file.write(file)
|
||||
end
|
||||
end
|
||||
|
||||
# Disable the service at boot. For Redhat and Debain,
|
||||
# delete services file and notify systemctl. For Ubuntu
|
||||
# remove init file.
|
||||
def disable
|
||||
if Facter.value(:operatingsystem) != 'Ubuntu'
|
||||
systemctl_run('disable', [resource[:pattern]], false)
|
||||
File.delete("/etc/systemd/system/#{resource[:pattern]}.service")
|
||||
systemctl_run('daemon-reload', nil, true)
|
||||
elsif Facter.value(:operatingsystem) == 'Ubuntu'
|
||||
File.delete("/etc/init/#{resource[:pattern]}.conf")
|
||||
end
|
||||
end
|
||||
|
||||
# Wrapper to handle swift-init calls on supported osfamily
|
||||
def swiftinit_run(command, failonfail)
|
||||
execute([['swift-init'], ["#{type}-#{subtype}#{manifest}"], [command]],
|
||||
:failonfail => failonfail)
|
||||
rescue Puppet::ExecutionFailure => detail
|
||||
@resource.fail Puppet::Error,
|
||||
"swift-init #{type}-#{subtype}#{manifest} #{command}
|
||||
failed with: #{@resource.ref}: #{detail}", detail
|
||||
end
|
||||
|
||||
# Wrapper to handle systemctl calls on supported osfamily
|
||||
def systemctl_run(command, unit_file, failonfail)
|
||||
if unit_file
|
||||
execute([['systemctl'], [command], [unit_file]], :failonfail => failonfail)
|
||||
else
|
||||
execute([['systemctl'], [command]], :failonfail => failonfail)
|
||||
end
|
||||
rescue Puppet::ExecutionFailure => detail
|
||||
@resource.fail Puppet::Error,
|
||||
"systemctl #{command} #{unit_file}
|
||||
failed with: #{@resource.ref}: #{detail}", detail
|
||||
end
|
||||
|
||||
# Split the service type off of name
|
||||
# type can be object, account, container.
|
||||
def type
|
||||
resource[:name].split(/-/)[1]
|
||||
end
|
||||
|
||||
# Split the service subtype off of name
|
||||
# subtype can be:
|
||||
# For type account: auditor, reaper, replicator, server.
|
||||
# For type container: auditor, replicator, server, sync, updater.
|
||||
# For type object: auditor, replicator, server, updater, expirer.
|
||||
# For type proxy: server.
|
||||
def subtype
|
||||
resource[:name].split(/-/)[2]
|
||||
end
|
||||
|
||||
# In this provider 'manifest' is the name of the config file that the service
|
||||
# uses to run. If the config file is a default name ex: object-server.conf.
|
||||
# then swift-init can be called without specifying the config file.
|
||||
# TODO add logic to start servers using multiple config files, used to run
|
||||
# swift with a dedicated replication network.
|
||||
def manifest
|
||||
if "#{resource[:manifest]}" == "#{type}-server.conf"
|
||||
return nil
|
||||
elsif "#{resource[:manifest]}" == 'object-expirer.conf'
|
||||
return nil
|
||||
else return ".#{resource[:manifest].split('.conf')[1]}"
|
||||
end
|
||||
end
|
||||
|
||||
# Begin service template boot section.
|
||||
def upstart_template
|
||||
%(# swift-#{type}-#{subtype}
|
||||
#
|
||||
# Starts the swift-#{type}-#{subtype}.
|
||||
|
||||
description "SWIFT #{type} #{subtype}"
|
||||
author "Puppet"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [016]
|
||||
|
||||
pre-start script
|
||||
if [ -f /etc/swift/#{resource[:manifest]} ]; then
|
||||
exec /usr/bin/swift-init #{type}-#{subtype} start
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
end script
|
||||
|
||||
post-stop exec /usr/bin/swift-init #{type}-#{subtype} stop)
|
||||
end
|
||||
|
||||
def systemd_template
|
||||
%([Unit]
|
||||
Description=OpenStack "SWIFT #{type} #{subtype}"
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
Type=forking
|
||||
User=root
|
||||
ExecStart=/usr/bin/swift-init #{type}-#{subtype} start
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target)
|
||||
end
|
||||
end
|
@ -56,7 +56,14 @@
|
||||
# (optional) Report interval, in seconds.
|
||||
# Defaults to 300.
|
||||
#
|
||||
|
||||
# [*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.
|
||||
#
|
||||
class swift::objectexpirer(
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
@ -71,9 +78,8 @@ class swift::objectexpirer(
|
||||
$reclaim_age = 604800,
|
||||
$recon_cache_path = '/var/cache/swift',
|
||||
$report_interval = 300,
|
||||
) {
|
||||
|
||||
include ::swift::params
|
||||
$service_provider = $::swift::params::service_provider
|
||||
) inherits ::swift::params {
|
||||
|
||||
Swift_config<| |> ~> Service['swift-object-expirer']
|
||||
Swift_object_expirer_config<||> ~> Service['swift-object-expirer']
|
||||
@ -109,12 +115,11 @@ class swift::objectexpirer(
|
||||
}
|
||||
}
|
||||
|
||||
service { 'swift-object-expirer':
|
||||
ensure => $service_ensure,
|
||||
name => $::swift::params::object_expirer_service_name,
|
||||
enable => $enabled,
|
||||
provider => $::swift::params::service_provider,
|
||||
tag => 'swift-service',
|
||||
swift::service { 'swift-object-expirer':
|
||||
os_family_service_name => $::swift::params::object_expirer_service_name,
|
||||
service_ensure => $service_ensure,
|
||||
enabled => $enabled,
|
||||
config_file_name => 'object-expirer.conf',
|
||||
service_provider => $service_provider,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,21 +6,22 @@ class swift::params {
|
||||
$package_name = 'swift'
|
||||
$client_package = 'python-swiftclient'
|
||||
$proxy_package_name = 'swift-proxy'
|
||||
$proxy_service_name = 'swift-proxy'
|
||||
$proxy_server_service_name = 'swift-proxy'
|
||||
$object_package_name = 'swift-object'
|
||||
$object_service_name = 'swift-object'
|
||||
$object_server_service_name = 'swift-object'
|
||||
$object_auditor_service_name = 'swift-object-auditor'
|
||||
$object_replicator_service_name = 'swift-object-replicator'
|
||||
$object_updater_service_name = 'swift-object-updater'
|
||||
$object_expirer_package_name = 'swift-object-expirer'
|
||||
$object_expirer_service_name = 'swift-object-expirer'
|
||||
$container_package_name = 'swift-container'
|
||||
$container_service_name = 'swift-container'
|
||||
$container_server_service_name = 'swift-container'
|
||||
$container_auditor_service_name = 'swift-container-auditor'
|
||||
$container_replicator_service_name = 'swift-container-replicator'
|
||||
$container_updater_service_name = 'swift-container-updater'
|
||||
$container_sync_service_name = 'swift-container-sync'
|
||||
$account_package_name = 'swift-account'
|
||||
$account_service_name = 'swift-account'
|
||||
$account_server_service_name = 'swift-account'
|
||||
$account_auditor_service_name = 'swift-account-auditor'
|
||||
$account_reaper_service_name = 'swift-account-reaper'
|
||||
$account_replicator_service_name = 'swift-account-replicator'
|
||||
@ -35,21 +36,22 @@ class swift::params {
|
||||
$package_name = 'openstack-swift'
|
||||
$client_package = 'python-swiftclient'
|
||||
$proxy_package_name = 'openstack-swift-proxy'
|
||||
$proxy_service_name = 'openstack-swift-proxy'
|
||||
$proxy_server_service_name = 'openstack-swift-proxy'
|
||||
$object_package_name = 'openstack-swift-object'
|
||||
$object_service_name = 'openstack-swift-object'
|
||||
$object_server_service_name = 'openstack-swift-object'
|
||||
$object_auditor_service_name = 'openstack-swift-object-auditor'
|
||||
$object_replicator_service_name = 'openstack-swift-object-replicator'
|
||||
$object_updater_service_name = 'openstack-swift-object-updater'
|
||||
$object_expirer_package_name = 'openstack-swift-proxy'
|
||||
$object_expirer_service_name = 'openstack-swift-object-expirer'
|
||||
$container_package_name = 'openstack-swift-container'
|
||||
$container_service_name = 'openstack-swift-container'
|
||||
$container_server_service_name = 'openstack-swift-container'
|
||||
$container_auditor_service_name = 'openstack-swift-container-auditor'
|
||||
$container_replicator_service_name = 'openstack-swift-container-replicator'
|
||||
$container_updater_service_name = 'openstack-swift-container-updater'
|
||||
$container_sync_service_name = 'openstack-swift-container-sync'
|
||||
$account_package_name = 'openstack-swift-account'
|
||||
$account_service_name = 'openstack-swift-account'
|
||||
$account_server_service_name = 'openstack-swift-account'
|
||||
$account_auditor_service_name = 'openstack-swift-account-auditor'
|
||||
$account_reaper_service_name = 'openstack-swift-account-reaper'
|
||||
$account_replicator_service_name = 'openstack-swift-account-replicator'
|
||||
@ -60,4 +62,21 @@ class swift::params {
|
||||
fail("Unsupported osfamily: ${::osfamily} for os ${::operatingsystem}")
|
||||
}
|
||||
}
|
||||
$swift_init_service_names = [
|
||||
'swift-proxy-server',
|
||||
'swift-object-auditor',
|
||||
'swift-object-expirer',
|
||||
'swift-object-replicator',
|
||||
'swift-object-server',
|
||||
'swift-object-updater',
|
||||
'swift-account-auditor',
|
||||
'swift-account-reaper',
|
||||
'swift-account-replicator',
|
||||
'swift-account-server',
|
||||
'swift-container-auditor',
|
||||
'swift-container-replicator',
|
||||
'swift-container-server',
|
||||
'swift-container-sync',
|
||||
'swift-container-updater',
|
||||
]
|
||||
}
|
||||
|
@ -98,6 +98,14 @@
|
||||
# Configures log_name for swift proxy-server.
|
||||
# Optional. Defaults to proxy-server
|
||||
#
|
||||
# [*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.
|
||||
#
|
||||
# == Examples
|
||||
#
|
||||
# == Authors
|
||||
@ -129,13 +137,13 @@ class swift::proxy(
|
||||
$node_timeout = undef,
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$package_ensure = 'present'
|
||||
) {
|
||||
$package_ensure = 'present',
|
||||
$service_provider = $::swift::params::service_provider
|
||||
) inherits ::swift::params {
|
||||
|
||||
include ::swift::params
|
||||
include ::concat::setup
|
||||
|
||||
Swift_config<| |> ~> Service['swift-proxy']
|
||||
Swift_config<| |> ~> Service['swift-proxy-server']
|
||||
|
||||
validate_bool($account_autocreate)
|
||||
validate_bool($allow_account_management)
|
||||
@ -209,13 +217,12 @@ class swift::proxy(
|
||||
}
|
||||
}
|
||||
|
||||
service { 'swift-proxy':
|
||||
ensure => $service_ensure,
|
||||
name => $::swift::params::proxy_service_name,
|
||||
enable => $enabled,
|
||||
provider => $::swift::params::service_provider,
|
||||
hasstatus => true,
|
||||
subscribe => Concat['/etc/swift/proxy-server.conf'],
|
||||
tag => 'swift-service',
|
||||
swift::service { 'swift-proxy-server':
|
||||
os_family_service_name => $::swift::params::proxy_server_service_name,
|
||||
service_ensure => $service_ensure,
|
||||
enabled => $enabled,
|
||||
config_file_name => 'proxy-server.conf',
|
||||
service_provider => $service_provider,
|
||||
subscribe => Concat['/etc/swift/proxy-server.conf'],
|
||||
}
|
||||
}
|
||||
|
71
manifests/service.pp
Normal file
71
manifests/service.pp
Normal file
@ -0,0 +1,71 @@
|
||||
# == Define: swift::service
|
||||
#
|
||||
# Wrapper class to configure swift service providers
|
||||
#
|
||||
# === Parameters:
|
||||
#
|
||||
# [*title*] The name of the swift service to manage
|
||||
# Mandatory. ex: 'swift-object-server' valid names
|
||||
# are listed in swift::params.pp at $swift_init_service_names
|
||||
#
|
||||
# [*os_family_service_name*]
|
||||
# (required) The distribution specific service name.
|
||||
#
|
||||
# [*config_file_name*]
|
||||
# (required) The service configuration file name.
|
||||
# Starting at the path "/etc/swift/" ex:"object-server.conf"
|
||||
#
|
||||
# [*service_ensure*]
|
||||
# (optional) State of service to ensure, running or stopped.
|
||||
# Default: undef
|
||||
#
|
||||
# [*enabled*]
|
||||
# (optional) Should the service be enabled to start
|
||||
# at boot. Default: true
|
||||
#
|
||||
# [*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.
|
||||
#
|
||||
define swift::service(
|
||||
$os_family_service_name,
|
||||
$config_file_name,
|
||||
$service_ensure = undef,
|
||||
$enabled = true,
|
||||
$service_provider = $::swift::params::service_provider,
|
||||
) {
|
||||
|
||||
include ::swift::params
|
||||
|
||||
if(! member($::swift::params::swift_init_service_names, $name)) {
|
||||
fail("swift::service name: ${name} is not a valid swift_init_service_name")
|
||||
}
|
||||
|
||||
if $service_provider != 'swiftinit' {
|
||||
service { $name:
|
||||
ensure => $service_ensure,
|
||||
name => $os_family_service_name,
|
||||
hasstatus => true,
|
||||
enable => $enabled,
|
||||
provider => $service_provider,
|
||||
tag => 'swift-service',
|
||||
subscribe => $subscribe,
|
||||
}
|
||||
} elsif $service_provider == 'swiftinit' {
|
||||
service { $name:
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
provider => 'swiftinit',
|
||||
pattern => $os_family_service_name,
|
||||
manifest => $config_file_name,
|
||||
tag => 'swift-service',
|
||||
subscribe => $subscribe,
|
||||
}
|
||||
}
|
||||
}
|
@ -2,8 +2,8 @@
|
||||
#
|
||||
# == Parameters
|
||||
# [*enabled*]
|
||||
# (optional) Should the service be enabled.
|
||||
# Defaults to true
|
||||
# (optional) Should the service be enabled to start
|
||||
# at boot. Defaults to true
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (optional) Whether the service should be managed by Puppet.
|
||||
@ -13,22 +13,37 @@
|
||||
# (optional) Value of package resource parameter 'ensure'.
|
||||
# Defaults to 'present'.
|
||||
#
|
||||
# [*config_file_name*]
|
||||
# (optional) The configuration file name.
|
||||
# Starting at the path "/etc/swift/"
|
||||
# Defaults to "account-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.
|
||||
#
|
||||
class swift::storage::account(
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$package_ensure = 'present'
|
||||
) {
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$package_ensure = 'present',
|
||||
$config_file_name = 'account-server.conf',
|
||||
$service_provider = $::swift::params::service_provider
|
||||
) inherits ::swift::params {
|
||||
|
||||
Swift_config<| |> ~> Service['swift-account-reaper']
|
||||
Swift_config<| |> ~> Service['swift-account-auditor']
|
||||
|
||||
swift::storage::generic { 'account':
|
||||
manage_service => $manage_service,
|
||||
enabled => $enabled,
|
||||
package_ensure => $package_ensure,
|
||||
}
|
||||
|
||||
include ::swift::params
|
||||
manage_service => $manage_service,
|
||||
enabled => $enabled,
|
||||
package_ensure => $package_ensure,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
@ -38,21 +53,21 @@ class swift::storage::account(
|
||||
}
|
||||
}
|
||||
|
||||
service { 'swift-account-reaper':
|
||||
ensure => $service_ensure,
|
||||
name => $::swift::params::account_reaper_service_name,
|
||||
enable => $enabled,
|
||||
provider => $::swift::params::service_provider,
|
||||
require => Package['swift-account'],
|
||||
tag => 'swift-service',
|
||||
swift::service { 'swift-account-reaper':
|
||||
os_family_service_name => $::swift::params::account_reaper_service_name,
|
||||
service_ensure => $service_ensure,
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
require => Package['swift-account'],
|
||||
}
|
||||
|
||||
service { 'swift-account-auditor':
|
||||
ensure => $service_ensure,
|
||||
name => $::swift::params::account_auditor_service_name,
|
||||
enable => $enabled,
|
||||
provider => $::swift::params::service_provider,
|
||||
require => Package['swift-account'],
|
||||
tag => 'swift-service',
|
||||
swift::service { 'swift-account-auditor':
|
||||
os_family_service_name => $::swift::params::account_auditor_service_name,
|
||||
service_ensure => $service_ensure,
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
require => Package['swift-account'],
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,14 @@
|
||||
# *NOTE*: Recommended parameter: 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r'
|
||||
# This mask translates to 0755 for directories and 0644 for files.
|
||||
#
|
||||
# [*service_provider*]
|
||||
# (optional)
|
||||
# To use the swiftinit service provider to manage swift services, set
|
||||
# service_provider to "swiftinit". When set to 'swiftinit' the
|
||||
# "manage_boot" defined type is used to populate boot files that start
|
||||
# swift using swift-init at boot. See README for more details.
|
||||
# Defaults to $::swift::params::service_provider.
|
||||
#
|
||||
class swift::storage::all(
|
||||
$storage_local_net_ip,
|
||||
$devices = '/srv/node',
|
||||
@ -91,7 +99,8 @@ class swift::storage::all(
|
||||
$log_requests = true,
|
||||
$incoming_chmod = '0644',
|
||||
$outgoing_chmod = '0644',
|
||||
) {
|
||||
$service_provider = $::swift::params::service_provider,
|
||||
) inherits ::swift::params {
|
||||
|
||||
if (!$mount_check) {
|
||||
warning('The default for the mount_check parameter will change from false to true in the next release to match upstream. To disable this warning, set mount_check=false.')
|
||||
@ -112,6 +121,7 @@ class swift::storage::all(
|
||||
log_level => $log_level,
|
||||
log_udp_host => $log_udp_host,
|
||||
log_udp_port => $log_udp_port,
|
||||
service_provider => $service_provider,
|
||||
}
|
||||
|
||||
swift::storage::server { $account_port:
|
||||
|
@ -1,9 +1,10 @@
|
||||
# Class swift::storage::container
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*enabled*]
|
||||
# (optional) Should the service be enabled.
|
||||
# Defaults to true
|
||||
# (optional) Should the service be enabled to start
|
||||
# at boot. Defaults to true
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (optional) Whether the service should be managed by Puppet.
|
||||
@ -17,24 +18,39 @@
|
||||
# (optional) A list of hosts allowed in the X-Container-Sync-To
|
||||
# field for containers. Defaults to one entry list '127.0.0.1'.
|
||||
#
|
||||
# [*config_file_name*]
|
||||
# (optional) The configuration file name.
|
||||
# Starting at the path "/etc/swift/"
|
||||
# Defaults to "object-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.
|
||||
#
|
||||
class swift::storage::container(
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$package_ensure = 'present',
|
||||
$allowed_sync_hosts = ['127.0.0.1'],
|
||||
) {
|
||||
$config_file_name = 'container-server.conf',
|
||||
$service_provider = $::swift::params::service_provider
|
||||
) inherits ::swift::params {
|
||||
|
||||
Swift_config<| |> ~> Service['swift-container-updater']
|
||||
Swift_config<| |> ~> Service['swift-container-auditor']
|
||||
|
||||
swift::storage::generic { 'container':
|
||||
manage_service => $manage_service,
|
||||
enabled => $enabled,
|
||||
package_ensure => $package_ensure,
|
||||
manage_service => $manage_service,
|
||||
enabled => $enabled,
|
||||
package_ensure => $package_ensure,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider
|
||||
}
|
||||
|
||||
include ::swift::params
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
@ -43,35 +59,32 @@ class swift::storage::container(
|
||||
}
|
||||
}
|
||||
|
||||
service { 'swift-container-updater':
|
||||
ensure => $service_ensure,
|
||||
name => $::swift::params::container_updater_service_name,
|
||||
enable => $enabled,
|
||||
provider => $::swift::params::service_provider,
|
||||
require => Package['swift-container'],
|
||||
tag => 'swift-service',
|
||||
swift::service { 'swift-container-updater':
|
||||
os_family_service_name => $::swift::params::container_updater_service_name,
|
||||
service_ensure => $service_ensure,
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
require => Package['swift-container'],
|
||||
}
|
||||
|
||||
service { 'swift-container-auditor':
|
||||
ensure => $service_ensure,
|
||||
name => $::swift::params::container_auditor_service_name,
|
||||
enable => $enabled,
|
||||
provider => $::swift::params::service_provider,
|
||||
require => Package['swift-container'],
|
||||
tag => 'swift-service',
|
||||
swift::service { 'swift-container-auditor':
|
||||
os_family_service_name => $::swift::params::container_auditor_service_name,
|
||||
service_ensure => $service_ensure,
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
require => Package['swift-container'],
|
||||
}
|
||||
|
||||
if $::operatingsystem == 'Ubuntu' {
|
||||
# The following service conf is missing in Ubunty 12.04
|
||||
file { '/etc/init/swift-container-sync.conf':
|
||||
source => 'puppet:///modules/swift/swift-container-sync.conf.upstart',
|
||||
require => Package['swift-container'],
|
||||
}
|
||||
service { 'swift-container-sync':
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
provider => $::swift::params::service_provider,
|
||||
require => File['/etc/init/swift-container-sync.conf'],
|
||||
if $::osfamily == 'Debian' {
|
||||
swift::service { 'swift-container-sync':
|
||||
os_family_service_name => $::swift::params::container_sync_service_name,
|
||||
service_ensure => $service_ensure,
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
require => Package['swift-container'],
|
||||
}
|
||||
Swift_config<| |> ~> Service['swift-container-sync']
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
#
|
||||
# == Parameters
|
||||
# [*enabled*]
|
||||
# (optional) Should the service be enabled.
|
||||
# Defaults to true
|
||||
# (optional) Should the service be enabled to start
|
||||
# at boot. Defaults to true
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (optional) Whether the service should be managed by Puppet.
|
||||
@ -14,45 +14,49 @@
|
||||
# (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) The provider to use for the service
|
||||
# (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]
|
||||
# == Examples
|
||||
#
|
||||
# == Authors
|
||||
#
|
||||
# Dan Bode dan@puppetlabs.com
|
||||
#
|
||||
# == Copyright
|
||||
#
|
||||
# Copyright 2011 Puppetlabs Inc, unless otherwise noted.
|
||||
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}"]
|
||||
Swift_config<| |> ~> Service["swift-${name}-server"]
|
||||
|
||||
validate_re($name, '^object|container|account$')
|
||||
|
||||
package { "swift-${name}":
|
||||
ensure => $package_ensure,
|
||||
# this is a way to dynamically build the variables to lookup
|
||||
# sorry its so ugly :(
|
||||
name => inline_template("<%= scope.lookupvar('::swift::params::${name}_package_name') %>"),
|
||||
name => getvar("::swift::params::${name}_package_name"),
|
||||
tag => ['openstack', 'swift-package'],
|
||||
before => Service["swift-${name}", "swift-${name}-replicator"],
|
||||
before => Service["swift-${name}-server", "swift-${name}-replicator"],
|
||||
}
|
||||
|
||||
file { "/etc/swift/${name}-server/":
|
||||
ensure => directory,
|
||||
ensure => directory,
|
||||
owner => 'swift',
|
||||
group => 'swift',
|
||||
require => Package["swift-${name}"],
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
@ -63,24 +67,21 @@ define swift::storage::generic(
|
||||
}
|
||||
}
|
||||
|
||||
service { "swift-${name}":
|
||||
ensure => $service_ensure,
|
||||
name => inline_template("<%= scope.lookupvar('::swift::params::${name}_service_name') %>"),
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
provider => $service_provider,
|
||||
subscribe => Package["swift-${name}"],
|
||||
tag => 'swift-service',
|
||||
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}"],
|
||||
}
|
||||
|
||||
service { "swift-${name}-replicator":
|
||||
ensure => $service_ensure,
|
||||
name => inline_template("<%= scope.lookupvar('::swift::params::${name}_replicator_service_name') %>"),
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
provider => $service_provider,
|
||||
subscribe => Package["swift-${name}"],
|
||||
tag => 'swift-service',
|
||||
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}"],
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,14 @@
|
||||
# (optional) The IP address of the storage server.
|
||||
# Defaults to '127.0.0.1'.
|
||||
#
|
||||
# [*service_provider*]
|
||||
# (optional)
|
||||
# To use the swiftinit service provider to manage swift services, set
|
||||
# service_provider to "swiftinit". When set to 'swiftinit' the
|
||||
# "manage_boot" defined type is used to populate boot files that start
|
||||
# swift using swift-init at boot. See README for more details.
|
||||
# Defaults to $::swift::params::service_provider.
|
||||
#
|
||||
# ==== DEPRECATED PARAMETERS
|
||||
#
|
||||
# [*manage_ring*]
|
||||
@ -51,6 +59,7 @@ define swift::storage::node(
|
||||
$group = 'swift',
|
||||
$max_connections = 25,
|
||||
$storage_local_net_ip = '127.0.0.1',
|
||||
$service_provider = $::swift::params::service_provider,
|
||||
# DEPRECATED PARAMETERS
|
||||
$manage_ring = true
|
||||
) {
|
||||
@ -63,6 +72,7 @@ define swift::storage::node(
|
||||
max_connections => $max_connections,
|
||||
owner => $owner,
|
||||
group => $group,
|
||||
service_provider => $service_provider
|
||||
}
|
||||
|
||||
swift::storage::server { "60${name}0":
|
||||
|
@ -2,8 +2,8 @@
|
||||
#
|
||||
# == Parameters
|
||||
# [*enabled*]
|
||||
# (optional) Should the service be enabled.
|
||||
# Defaults to true
|
||||
# (optional) Should the service be enabled to start
|
||||
# at boot. Defaults to true
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (optional) Whether the service should be managed by Puppet.
|
||||
@ -13,23 +13,38 @@
|
||||
# (optional) Value of package resource parameter 'ensure'.
|
||||
# Defaults to 'present'.
|
||||
#
|
||||
# [*config_file_name*]
|
||||
# (optional) The configuration file name.
|
||||
# Starting at the path "/etc/swift/"
|
||||
# Defaults to "object-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.
|
||||
#
|
||||
class swift::storage::object(
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$package_ensure = 'present'
|
||||
) {
|
||||
$manage_service = true,
|
||||
$enabled = true,
|
||||
$package_ensure = 'present',
|
||||
$config_file_name = 'object-server.conf',
|
||||
$service_provider = $::swift::params::service_provider
|
||||
) inherits ::swift::params {
|
||||
|
||||
Swift_config<| |> ~> Service['swift-object-updater']
|
||||
Swift_config<| |> ~> Service['swift-object-auditor']
|
||||
|
||||
swift::storage::generic { 'object':
|
||||
manage_service => $manage_service,
|
||||
enabled => $enabled,
|
||||
package_ensure => $package_ensure,
|
||||
manage_service => $manage_service,
|
||||
enabled => $enabled,
|
||||
package_ensure => $package_ensure,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider
|
||||
}
|
||||
|
||||
include ::swift::params
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
@ -38,21 +53,21 @@ class swift::storage::object(
|
||||
}
|
||||
}
|
||||
|
||||
service { 'swift-object-updater':
|
||||
ensure => $service_ensure,
|
||||
name => $::swift::params::object_updater_service_name,
|
||||
enable => $enabled,
|
||||
provider => $::swift::params::service_provider,
|
||||
require => Package['swift-object'],
|
||||
tag => 'swift-service',
|
||||
swift::service { 'swift-object-updater':
|
||||
os_family_service_name => $::swift::params::object_updater_service_name,
|
||||
service_ensure => $service_ensure,
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
require => Package['swift-object'],
|
||||
}
|
||||
|
||||
service { 'swift-object-auditor':
|
||||
ensure => $service_ensure,
|
||||
name => $::swift::params::object_auditor_service_name,
|
||||
enable => $enabled,
|
||||
provider => $::swift::params::service_provider,
|
||||
require => Package['swift-object'],
|
||||
tag => 'swift-service',
|
||||
swift::service { 'swift-object-auditor':
|
||||
os_family_service_name => $::swift::params::object_auditor_service_name,
|
||||
service_ensure => $service_ensure,
|
||||
enabled => $enabled,
|
||||
config_file_name => $config_file_name,
|
||||
service_provider => $service_provider,
|
||||
require => Package['swift-object'],
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,6 @@
|
||||
# *NOTE*: Recommended parameter: 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r'
|
||||
# This mask translates to 0755 for directories and 0644 for files.
|
||||
#
|
||||
|
||||
# [*pipeline*]
|
||||
# (optional) Pipeline of applications.
|
||||
# Defaults to ["${type}-server"].
|
||||
@ -93,7 +92,7 @@
|
||||
# [*log_name*]
|
||||
# (optional) Label used when logging.
|
||||
# Defaults to "${type}-server".
|
||||
|
||||
#
|
||||
# [*log_udp_host*]
|
||||
# (optional) If not set, the UDP receiver for syslog is disabled.
|
||||
# Defaults to undef.
|
||||
@ -107,9 +106,18 @@
|
||||
# good for seeing errors if true
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*config_file_path*]
|
||||
# (optional) The configuration file name.
|
||||
# Defaults to "${type}-server/${name}.conf".
|
||||
# [*config_file_path*]
|
||||
# (optional) The configuration file name.
|
||||
# Starting at the path "/etc/swift/"
|
||||
# Defaults to "${type}-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.
|
||||
#
|
||||
define swift::storage::server(
|
||||
$type,
|
||||
@ -136,7 +144,8 @@ define swift::storage::server(
|
||||
$log_udp_port = undef,
|
||||
$log_requests = true,
|
||||
# this parameters needs to be specified after type and name
|
||||
$config_file_path = "${type}-server/${name}.conf"
|
||||
$config_file_path = "${type}-server.conf",
|
||||
$service_provider = $::swift::params::service_provider
|
||||
) {
|
||||
|
||||
if ($incoming_chmod == '0644') {
|
||||
@ -168,8 +177,12 @@ define swift::storage::server(
|
||||
fail ('log_udp_port requires log_udp_host to be set')
|
||||
}
|
||||
|
||||
include "::swift::storage::${type}"
|
||||
class { "::swift::storage::${type}" :
|
||||
service_provider => $service_provider
|
||||
}
|
||||
|
||||
include ::concat::setup
|
||||
include ::swift::params
|
||||
|
||||
validate_re($name, '^\d+$')
|
||||
validate_re($type, '^object|container|account$')
|
||||
@ -193,7 +206,7 @@ define swift::storage::server(
|
||||
concat { "/etc/swift/${config_file_path}":
|
||||
owner => $owner,
|
||||
group => $group,
|
||||
notify => Service["swift-${type}", "swift-${type}-replicator"],
|
||||
notify => Service["swift-${type}-server", "swift-${type}-replicator"],
|
||||
require => Package['swift'],
|
||||
}
|
||||
|
||||
|
@ -82,4 +82,83 @@ describe 'basic swift' do
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'Using swiftinit service provider' do
|
||||
|
||||
it 'should work with no errors' do
|
||||
swiftinit_pp= <<-EOS
|
||||
include ::openstack_integration
|
||||
include ::openstack_integration::repos
|
||||
include ::openstack_integration::rabbitmq
|
||||
include ::openstack_integration::mysql
|
||||
include ::openstack_integration::keystone
|
||||
|
||||
package { 'curl': ensure => present }
|
||||
|
||||
class { '::memcached':
|
||||
listen_ip => '127.0.0.1',
|
||||
}
|
||||
|
||||
# Swift resources
|
||||
class { '::swift':
|
||||
# not sure how I want to deal with this shared secret
|
||||
swift_hash_suffix => 'secrete',
|
||||
package_ensure => latest,
|
||||
}
|
||||
class { '::swift::keystone::auth':
|
||||
password => 'a_big_secret',
|
||||
}
|
||||
# === Configure Storage
|
||||
class { '::swift::storage':
|
||||
storage_local_net_ip => '127.0.0.1',
|
||||
}
|
||||
# create xfs partitions on a loopback device and mounts them
|
||||
swift::storage::loopback { '2':
|
||||
require => Class['swift'],
|
||||
}
|
||||
# sets up storage nodes which is composed of a single
|
||||
# device that contains an endpoint for an object, account, and container
|
||||
swift::storage::node { '2':
|
||||
mnt_base_dir => '/srv/node',
|
||||
weight => 1,
|
||||
manage_ring => true,
|
||||
zone => '2',
|
||||
storage_local_net_ip => '127.0.0.1',
|
||||
require => Swift::Storage::Loopback[2] ,
|
||||
service_provider => 'swiftinit',
|
||||
}
|
||||
class { '::swift::ringbuilder':
|
||||
part_power => '18',
|
||||
replicas => '1',
|
||||
min_part_hours => 1,
|
||||
require => Class['swift'],
|
||||
}
|
||||
class { '::swift::proxy':
|
||||
proxy_local_net_ip => '127.0.0.1',
|
||||
pipeline => ['healthcheck', 'cache', 'tempauth', 'proxy-server'],
|
||||
account_autocreate => true,
|
||||
require => Class['swift::ringbuilder'],
|
||||
service_provider => 'swiftinit',
|
||||
}
|
||||
class { '::swift::proxy::authtoken':
|
||||
admin_password => 'a_big_secret',
|
||||
}
|
||||
class {'::swift::objectexpirer':
|
||||
interval => 600,
|
||||
service_provider => 'swiftinit',
|
||||
}
|
||||
class { ['::swift::proxy::healthcheck', '::swift::proxy::cache', '::swift::proxy::tempauth']: }
|
||||
EOS
|
||||
|
||||
# Run one time to catch any errors upgrading to swiftinit service provider
|
||||
apply_manifest(swiftinit_pp, :catch_failures => true)
|
||||
# The second run tests idempotency
|
||||
apply_manifest(swiftinit_pp, :catch_changes => true)
|
||||
|
||||
end
|
||||
|
||||
describe port(8080) do
|
||||
it { is_expected.to be_listening.with('tcp') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -85,6 +85,18 @@ describe 'swift::objectexpirer' do
|
||||
|
||||
it_configures 'swift-object-expirer'
|
||||
end
|
||||
|
||||
context 'on debian using swiftinit service provider' do
|
||||
before do
|
||||
params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
before do
|
||||
platform_params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
it_configures 'swift-object-expirer'
|
||||
end
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
@ -111,5 +123,19 @@ describe 'swift::objectexpirer' do
|
||||
|
||||
it_configures 'swift-object-expirer'
|
||||
end
|
||||
|
||||
context 'on redhat using swiftinit service provider' do
|
||||
before do
|
||||
params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :object_expirer_package_name => 'openstack-swift-proxy',
|
||||
:service_name => 'swift-object-expirer',
|
||||
:service_provider => 'swiftinit' }
|
||||
end
|
||||
|
||||
it_configures 'swift-object-expirer'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -37,13 +37,13 @@ describe 'swift::proxy' do
|
||||
{:proxy_local_net_ip => '127.0.0.1'}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_service('swift-proxy').with(
|
||||
{:ensure => 'running',
|
||||
:provider => 'upstart',
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
:subscribe => 'Concat[/etc/swift/proxy-server.conf]',
|
||||
:tag => 'swift-service',
|
||||
it { is_expected.to contain_service('swift-proxy-server').with(
|
||||
{:ensure => 'running',
|
||||
:provider => 'upstart',
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
:subscribe => 'Concat[/etc/swift/proxy-server.conf]',
|
||||
:tag => 'swift-service',
|
||||
}
|
||||
)}
|
||||
it { is_expected.to contain_file('/etc/swift/proxy-server.conf').with(
|
||||
@ -232,7 +232,7 @@ describe 'swift::proxy' do
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'swift-proxy' do
|
||||
shared_examples_for 'swift-proxy-server' do
|
||||
let :params do
|
||||
{ :proxy_local_net_ip => '127.0.0.1' }
|
||||
end
|
||||
@ -244,14 +244,13 @@ describe 'swift::proxy' do
|
||||
params.merge!(param_hash)
|
||||
end
|
||||
|
||||
it 'configures swift-proxy service' do
|
||||
is_expected.to contain_service('swift-proxy').with(
|
||||
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
|
||||
:name => platform_params[:service_name],
|
||||
:provider => platform_params[:service_provider],
|
||||
:enable => param_hash[:enabled],
|
||||
:hasstatus => true,
|
||||
:subscribe => 'Concat[/etc/swift/proxy-server.conf]'
|
||||
it 'configures swift-proxy-server service' do
|
||||
is_expected.to contain_service('swift-proxy-server').with(
|
||||
:name => platform_params['swift-proxy-server'],
|
||||
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
|
||||
:enable => param_hash[:enabled],
|
||||
:provider => platform_params['service_provider'],
|
||||
:tag => 'swift-service',
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -264,14 +263,15 @@ describe 'swift::proxy' do
|
||||
:enabled => false })
|
||||
end
|
||||
|
||||
it 'configures swift-proxy service' do
|
||||
is_expected.to contain_service('swift-proxy').with(
|
||||
:ensure => nil,
|
||||
:name => platform_params[:service_name],
|
||||
:provider => platform_params[:service_provider],
|
||||
:enable => false,
|
||||
:hasstatus => true,
|
||||
:subscribe => 'Concat[/etc/swift/proxy-server.conf]'
|
||||
it 'configures swift-proxy-server service' do
|
||||
|
||||
is_expected.to contain_service('swift-proxy-server').with(
|
||||
:ensure => nil,
|
||||
:name => platform_params['swift-proxy-server'],
|
||||
:provider => platform_params['service_provider'],
|
||||
:enable => false,
|
||||
:hasstatus => true,
|
||||
:subscribe => 'Concat[/etc/swift/proxy-server.conf]'
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -285,11 +285,24 @@ describe 'swift::proxy' do
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :service_name => 'swift-proxy',
|
||||
:service_provider => 'upstart' }
|
||||
{ 'swift-proxy-server' => 'swift-proxy',
|
||||
'service_provider' => 'upstart'
|
||||
}
|
||||
end
|
||||
it_configures 'swift-proxy-server'
|
||||
|
||||
it_configures 'swift-proxy'
|
||||
context 'on Debian platforms using swiftinit service provider' do
|
||||
before do
|
||||
params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ 'swift-proxy-server' => 'swift-proxy-server',
|
||||
'service_provider' => 'swiftinit'
|
||||
}
|
||||
end
|
||||
it_configures 'swift-proxy-server'
|
||||
end
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
@ -300,10 +313,23 @@ describe 'swift::proxy' do
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :service_name => 'openstack-swift-proxy',
|
||||
:service_provider => nil }
|
||||
{
|
||||
'swift-proxy-server' => 'openstack-swift-proxy',
|
||||
}
|
||||
end
|
||||
it_configures 'swift-proxy-server'
|
||||
|
||||
it_configures 'swift-proxy'
|
||||
context 'on Redhat platforms using swiftinit service provider' do
|
||||
before do
|
||||
params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ 'swift-proxy-server' => 'swift-proxy-server',
|
||||
'service_provider' => 'swiftinit'
|
||||
}
|
||||
end
|
||||
it_configures 'swift-proxy-server'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -39,6 +39,7 @@ describe 'swift::storage::account' do
|
||||
:name => service_name,
|
||||
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
|
||||
:enable => param_hash[:enabled],
|
||||
:provider => platform_params[:service_provider],
|
||||
:tag => 'swift-service',
|
||||
)
|
||||
end
|
||||
@ -75,15 +76,35 @@ describe 'swift::storage::account' do
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-account' => 'swift-account',
|
||||
'swift-account-server' => 'swift-account',
|
||||
'swift-account-replicator' => 'swift-account-replicator',
|
||||
'swift-account-reaper' => 'swift-account-reaper',
|
||||
'swift-account-auditor' => 'swift-account-auditor'
|
||||
}
|
||||
},
|
||||
:service_provider => 'upstart'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-account'
|
||||
context 'on Debian platforms using swiftinit service provider' do
|
||||
|
||||
before do
|
||||
params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-account-server' => 'swift-account-server',
|
||||
'swift-account-replicator' => 'swift-account-replicator',
|
||||
'swift-account-reaper' => 'swift-account-reaper',
|
||||
'swift-account-auditor' => 'swift-account-auditor',
|
||||
},
|
||||
:service_provider => 'swiftinit'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-account'
|
||||
end
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
@ -94,14 +115,34 @@ describe 'swift::storage::account' do
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-account' => 'openstack-swift-account',
|
||||
'swift-account-server' => 'openstack-swift-account',
|
||||
'swift-account-replicator' => 'openstack-swift-account-replicator',
|
||||
'swift-account-reaper' => 'openstack-swift-account-reaper',
|
||||
'swift-account-auditor' => 'openstack-swift-account-auditor'
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-account'
|
||||
context 'on redhat using swiftinit service provider' do
|
||||
|
||||
before do
|
||||
params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-account-server' => 'swift-account-server',
|
||||
'swift-account-replicator' => 'swift-account-replicator',
|
||||
'swift-account-reaper' => 'swift-account-reaper',
|
||||
'swift-account-auditor' => 'swift-account-auditor',
|
||||
},
|
||||
:service_provider => 'swiftinit'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-account'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -60,7 +60,7 @@ describe 'swift::storage::all' do
|
||||
|
||||
['object', 'container', 'account'].each do |type|
|
||||
it { is_expected.to contain_package("swift-#{type}").with_ensure('present') }
|
||||
it { is_expected.to contain_service("swift-#{type}").with(
|
||||
it { is_expected.to contain_service("swift-#{type}-server").with(
|
||||
{:provider => 'upstart',
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
@ -147,7 +147,7 @@ describe 'swift::storage::all' do
|
||||
end
|
||||
['object', 'container', 'account'].each do |type|
|
||||
it { is_expected.to contain_package("swift-#{type}").with_ensure('present') }
|
||||
it { is_expected.to contain_service("swift-#{type}").with(
|
||||
it { is_expected.to contain_service("swift-#{type}-server").with(
|
||||
{:provider => nil,
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
|
@ -36,10 +36,11 @@ describe 'swift::storage::container' do
|
||||
it 'configures services' do
|
||||
platform_params[:service_names].each do |service_alias, service_name|
|
||||
is_expected.to contain_service(service_alias).with(
|
||||
:name => service_name,
|
||||
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
|
||||
:enable => param_hash[:enabled],
|
||||
:tag => 'swift-service',
|
||||
:name => service_name,
|
||||
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
|
||||
:enable => param_hash[:enabled],
|
||||
:provider => platform_params[:service_provider],
|
||||
:tag => 'swift-service',
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -75,29 +76,36 @@ describe 'swift::storage::container' do
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-container' => 'swift-container',
|
||||
'swift-container-server' => 'swift-container',
|
||||
'swift-container-replicator' => 'swift-container-replicator',
|
||||
'swift-container-updater' => 'swift-container-updater',
|
||||
'swift-container-auditor' => 'swift-container-auditor'
|
||||
}
|
||||
},
|
||||
:service_provider => 'upstart'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-container'
|
||||
|
||||
context 'Ubuntu specific resources' do
|
||||
it 'configures sync' do
|
||||
is_expected.to contain_service('swift-container-sync').with(
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
:provider => 'upstart',
|
||||
:require => 'File[/etc/init/swift-container-sync.conf]',
|
||||
)
|
||||
is_expected.to contain_file('/etc/init/swift-container-sync.conf').with(
|
||||
:source => 'puppet:///modules/swift/swift-container-sync.conf.upstart',
|
||||
:require => 'Package[swift-container]'
|
||||
)
|
||||
context 'on debian using swiftinit service provider' do
|
||||
|
||||
before do
|
||||
params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-container-server' => 'swift-container-server',
|
||||
'swift-container-replicator' => 'swift-container-replicator',
|
||||
'swift-container-updater' => 'swift-container-updater',
|
||||
'swift-container-auditor' => 'swift-container-auditor',
|
||||
'swift-container-sync' => 'swift-container-sync'
|
||||
},
|
||||
:service_provider => 'swiftinit'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-container'
|
||||
end
|
||||
end
|
||||
|
||||
@ -109,7 +117,7 @@ describe 'swift::storage::container' do
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-container' => 'openstack-swift-container',
|
||||
'swift-container-server' => 'openstack-swift-container',
|
||||
'swift-container-replicator' => 'openstack-swift-container-replicator',
|
||||
'swift-container-updater' => 'openstack-swift-container-updater',
|
||||
'swift-container-auditor' => 'openstack-swift-container-auditor'
|
||||
@ -119,23 +127,24 @@ describe 'swift::storage::container' do
|
||||
|
||||
it_configures 'swift-storage-container'
|
||||
|
||||
context 'RedHat specific resources' do
|
||||
context 'on redhat using swiftinit service provider' do
|
||||
|
||||
before do
|
||||
params.merge!({ :allowed_sync_hosts => ['127.0.0.1', '10.1.0.1', '10.1.0.2'] })
|
||||
params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"class { 'swift': swift_hash_suffix => 'foo' }
|
||||
class { 'swift::storage::all': storage_local_net_ip => '10.0.0.1' }"
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-container-server' => 'swift-container-server',
|
||||
'swift-container-replicator' => 'swift-container-replicator',
|
||||
'swift-container-updater' => 'swift-container-updater',
|
||||
'swift-container-auditor' => 'swift-container-auditor',
|
||||
},
|
||||
:service_provider => 'swiftinit'
|
||||
}
|
||||
end
|
||||
|
||||
let :fragment_file do
|
||||
"/var/lib/puppet/concat/_etc_swift_container-server.conf/fragments/00_swift-container-6001"
|
||||
end
|
||||
|
||||
it {
|
||||
is_expected.to contain_file(fragment_file).with_content(/^allowed_sync_hosts = 127.0.0.1,10.1.0.1,10.1.0.2$/)
|
||||
}
|
||||
it_configures 'swift-storage-container'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -37,10 +37,11 @@ describe 'swift::storage::object' do
|
||||
it 'configures services' do
|
||||
platform_params[:service_names].each do |service_alias, service_name|
|
||||
is_expected.to contain_service(service_alias).with(
|
||||
:name => service_name,
|
||||
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
|
||||
:enable => param_hash[:enabled],
|
||||
:tag => 'swift-service',
|
||||
:name => service_name,
|
||||
:ensure => (param_hash[:manage_service] && param_hash[:enabled]) ? 'running' : 'stopped',
|
||||
:enable => param_hash[:enabled],
|
||||
:provider => platform_params[:service_provider],
|
||||
:tag => 'swift-service',
|
||||
)
|
||||
end
|
||||
end
|
||||
@ -76,15 +77,37 @@ describe 'swift::storage::object' do
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-object' => 'swift-object',
|
||||
'swift-object-server' => 'swift-object',
|
||||
'swift-object-replicator' => 'swift-object-replicator',
|
||||
'swift-object-updater' => 'swift-object-updater',
|
||||
'swift-object-auditor' => 'swift-object-auditor'
|
||||
}
|
||||
},
|
||||
:service_provider => 'upstart'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-object'
|
||||
context 'on debian using swiftinit service provider' do
|
||||
|
||||
before do
|
||||
params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-object-server' => 'swift-object-server',
|
||||
'swift-object-replicator' => 'swift-object-replicator',
|
||||
'swift-object-updater' => 'swift-object-updater',
|
||||
'swift-object-auditor' => 'swift-object-auditor',
|
||||
},
|
||||
:service_provider => 'swiftinit'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-object'
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
@ -95,7 +118,7 @@ describe 'swift::storage::object' do
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-object' => 'openstack-swift-object',
|
||||
'swift-object-server' => 'openstack-swift-object',
|
||||
'swift-object-replicator' => 'openstack-swift-object-replicator',
|
||||
'swift-object-updater' => 'openstack-swift-object-updater',
|
||||
'swift-object-auditor' => 'openstack-swift-object-auditor'
|
||||
@ -104,5 +127,24 @@ describe 'swift::storage::object' do
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-object'
|
||||
context 'on redhat using swiftinit service provider' do
|
||||
|
||||
before do
|
||||
params.merge!({ :service_provider => 'swiftinit' })
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ :service_names => {
|
||||
'swift-object-server' => 'swift-object-server',
|
||||
'swift-object-replicator' => 'swift-object-replicator',
|
||||
'swift-object-updater' => 'swift-object-updater',
|
||||
'swift-object-auditor' => 'swift-object-auditor',
|
||||
},
|
||||
:service_provider => 'swiftinit'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-object'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -18,9 +18,10 @@ describe 'swift::storage::generic' do
|
||||
class { 'swift::storage': storage_local_net_ip => '10.0.0.1' }"
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
{:package_ensure => 'present',
|
||||
:service_provider => 'upstart'}
|
||||
let :params do
|
||||
{ :package_ensure => 'present',
|
||||
:enabled => true,
|
||||
:manage_service => true }
|
||||
end
|
||||
|
||||
describe 'with an invalid title' do
|
||||
@ -30,45 +31,137 @@ describe 'swift::storage::generic' do
|
||||
it_raises 'a Puppet::Error', /does not match/
|
||||
end
|
||||
|
||||
['account', 'object', 'container'].each do |t|
|
||||
[{},
|
||||
{:package_ensure => 'latest',
|
||||
:service_provider => 'init'}
|
||||
].each do |param_set|
|
||||
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
|
||||
let :title do
|
||||
t
|
||||
shared_examples_for 'swift-storage-generic' do
|
||||
%w(account object container).each do |t|
|
||||
[{},
|
||||
{ :package_ensure => 'latest' }
|
||||
].each do |param_set|
|
||||
describe "when #{param_set == {} ? 'using default' : 'specifying'} class parameters" do
|
||||
before do
|
||||
params.merge!(param_set)
|
||||
end
|
||||
|
||||
let :title do
|
||||
t
|
||||
end
|
||||
|
||||
[{ :enabled => true, :manage_service => true },
|
||||
{ :enabled => false, :manage_service => true }].each do |param_hash_manage|
|
||||
context "when service is_expected.to be #{param_hash_manage[:enabled] ? 'enabled' : 'disabled'}" do
|
||||
before do
|
||||
params.merge!(param_hash_manage)
|
||||
end
|
||||
|
||||
it do
|
||||
is_expected.to contain_package("swift-#{t}").with(
|
||||
:ensure => params[:package_ensure],
|
||||
:tag => ['openstack', 'swift-package']
|
||||
)
|
||||
end
|
||||
it do
|
||||
is_expected.to contain_service("swift-#{t}-server").with(
|
||||
:name => platform_params["swift-#{t}-server"],
|
||||
:ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped',
|
||||
:enable => param_hash_manage[:enabled],
|
||||
:provider => platform_params['service_provider'],
|
||||
:tag => 'swift-service'
|
||||
)
|
||||
end
|
||||
it do
|
||||
is_expected.to contain_service("swift-#{t}-replicator").with(
|
||||
:name => platform_params["swift-#{t}-replicator"],
|
||||
:ensure => (param_hash_manage[:manage_service] && param_hash_manage[:enabled]) ? 'running' : 'stopped',
|
||||
:enable => param_hash_manage[:enabled],
|
||||
:provider => platform_params['service_provider'],
|
||||
:tag => 'swift-service'
|
||||
)
|
||||
end
|
||||
it do
|
||||
is_expected.to contain_file("/etc/swift/#{t}-server/").with(
|
||||
:ensure => 'directory',
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
let :param_hash do
|
||||
default_params.merge(param_set)
|
||||
end
|
||||
let :params do
|
||||
param_set
|
||||
end
|
||||
it { is_expected.to contain_package("swift-#{t}").with(
|
||||
:ensure => param_hash[:package_ensure],
|
||||
:tag => ['openstack', 'swift-package'],
|
||||
)}
|
||||
it { is_expected.to contain_service("swift-#{t}").with(
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
:provider => param_hash[:service_provider],
|
||||
:tag => 'swift-service',
|
||||
)}
|
||||
it { is_expected.to contain_service("swift-#{t}-replicator").with(
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
:provider => param_hash[:service_provider],
|
||||
:tag => 'swift-service',
|
||||
)}
|
||||
it { is_expected.to contain_file("/etc/swift/#{t}-server/").with(
|
||||
:ensure => 'directory',
|
||||
)}
|
||||
end
|
||||
# TODO - I do not want to add tests for the upstart stuff
|
||||
# I need to check the tickets and see if this stuff is fixed
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :operatingsystem => 'Ubuntu',
|
||||
:osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ 'swift-account-server' => 'swift-account',
|
||||
'swift-account-replicator' => 'swift-account-replicator',
|
||||
'swift-container-server' => 'swift-container',
|
||||
'swift-container-replicator' => 'swift-container-replicator',
|
||||
'swift-object-server' => 'swift-object',
|
||||
'swift-object-replicator' => 'swift-object-replicator',
|
||||
'service_provider' => 'upstart'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-generic'
|
||||
|
||||
context 'on Debian platforms using swiftinit service provider' do
|
||||
before do
|
||||
params.merge!(:service_provider => 'swiftinit')
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ 'swift-account-server' => 'swift-account-server',
|
||||
'swift-account-replicator' => 'swift-account-replicator',
|
||||
'swift-container-server' => 'swift-container-server',
|
||||
'swift-container-replicator' => 'swift-container-replicator',
|
||||
'swift-object-server' => 'swift-object-server',
|
||||
'swift-object-replicator' => 'swift-object-replicator',
|
||||
'service_provider' => 'swiftinit'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-generic'
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Redhat platforms' do
|
||||
let :facts do
|
||||
{ :operatingsystem => 'Redhat',
|
||||
:osfamily => 'Redhat' }
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ 'swift-account-server' => 'openstack-swift-account',
|
||||
'swift-account-replicator' => 'openstack-swift-account-replicator',
|
||||
'swift-container-server' => 'openstack-swift-container',
|
||||
'swift-container-replicator' => 'openstack-swift-container-replicator',
|
||||
'swift-object-server' => 'openstack-swift-object',
|
||||
'swift-object-replicator' => 'openstack-swift-object-replicator'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-generic'
|
||||
|
||||
context 'on Redhat platforms using swiftinit service provider' do
|
||||
before do
|
||||
params.merge!(:service_provider => 'swiftinit')
|
||||
end
|
||||
|
||||
let :platform_params do
|
||||
{ 'swift-account-server' => 'swift-account-server',
|
||||
'swift-account-replicator' => 'swift-account-replicator',
|
||||
'swift-container-server' => 'swift-container-server',
|
||||
'swift-container-replicator' => 'swift-container-replicator',
|
||||
'swift-object-server' => 'swift-object-server',
|
||||
'swift-object-replicator' => 'swift-object-replicator',
|
||||
'service_provider' => 'swiftinit'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'swift-storage-generic'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -53,13 +53,13 @@ describe 'swift::storage::server' do
|
||||
end
|
||||
|
||||
it { is_expected.to contain_package("swift-#{t}").with_ensure('present') }
|
||||
it { is_expected.to contain_service("swift-#{t}").with(
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
:hasstatus => true
|
||||
it { is_expected.to contain_service("swift-#{t}-server").with(
|
||||
:ensure => 'running',
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
)}
|
||||
let :fragment_file do
|
||||
"/var/lib/puppet/concat/_etc_swift_#{t}-server_#{title}.conf/fragments/00_swift-#{t}-#{title}"
|
||||
"/var/lib/puppet/concat/_etc_swift_#{t}-server.conf/fragments/00_swift-#{t}-#{title}"
|
||||
end
|
||||
|
||||
describe 'when parameters are overridden' do
|
||||
@ -141,7 +141,7 @@ describe 'swift::storage::server' do
|
||||
swift_#{t}_config { 'foo/bar': value => 'foo' }
|
||||
"
|
||||
end
|
||||
it { is_expected.to contain_concat("/etc/swift/#{t}-server/#{title}.conf").that_comes_before("Swift_#{t}_config[foo/bar]") }
|
||||
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
|
||||
|
71
spec/unit/puppet/provider/service/swiftinit_spec.rb
Normal file
71
spec/unit/puppet/provider/service/swiftinit_spec.rb
Normal file
@ -0,0 +1,71 @@
|
||||
#! /usr/bin/env ruby
|
||||
##
|
||||
## Unit testing for the swiftinit service provider
|
||||
##
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
provider_class = Puppet::Type.type(:service).provider(:swiftinit)
|
||||
|
||||
describe provider_class do
|
||||
|
||||
|
||||
before(:each) do
|
||||
# Create a mock resource
|
||||
@resource = stub 'resource'
|
||||
|
||||
@provider = provider_class.new
|
||||
|
||||
# A catch all; no parameters set
|
||||
@resource.stubs(:[]).returns(nil)
|
||||
|
||||
# But set name, source and path
|
||||
@resource.stubs(:[]).with(:name).returns "swift-object-server"
|
||||
@resource.stubs(:[]).with(:ensure).returns :enable
|
||||
@resource.stubs(:[]).with(:pattern).returns "swift-object"
|
||||
@resource.stubs(:[]).with(:manifest).returns "object-server"
|
||||
@resource.stubs(:ref).returns "Service[myservice]"
|
||||
|
||||
@provider.resource = @resource
|
||||
|
||||
@provider.stubs(:command).with(:systemctl_run).returns "systemctl_run"
|
||||
|
||||
@provider.stubs(:systemctl_run)
|
||||
|
||||
end
|
||||
|
||||
it "should have an status method" do
|
||||
expect(@provider).to respond_to(:status)
|
||||
end
|
||||
|
||||
it "should have an start method" do
|
||||
expect(@provider).to respond_to(:start)
|
||||
end
|
||||
|
||||
it "should have an stop method" do
|
||||
expect(@provider).to respond_to(:stop)
|
||||
end
|
||||
|
||||
it "should have an restart method" do
|
||||
expect(@provider).to respond_to(:restart)
|
||||
end
|
||||
|
||||
it "should have an refresh method" do
|
||||
expect(@provider).to respond_to(:refresh)
|
||||
end
|
||||
|
||||
it "should have an enabled? method" do
|
||||
expect(@provider).to respond_to(:enabled?)
|
||||
end
|
||||
|
||||
it "should have an enable method" do
|
||||
expect(@provider).to respond_to(:enable)
|
||||
end
|
||||
|
||||
it "should have a disable method" do
|
||||
expect(@provider).to respond_to(:disable)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
##### TODO figure out how to stub out files and test each method more.
|
Loading…
x
Reference in New Issue
Block a user