Skip to content

Commit

Permalink
Add manage_service feature
Browse files Browse the repository at this point in the history
puppet-swift lacks of disabling service managing. This patch adds
$manage_service and $enabled parameter to all relevant classes.

Closes-bug: #1359823
Change-Id: I3d632e3a26e9394d03d94089ae704904bf77aa51
  • Loading branch information
paramite authored and xbezdick committed Dec 5, 2014
1 parent f530a78 commit 8987b09
Show file tree
Hide file tree
Showing 9 changed files with 551 additions and 188 deletions.
136 changes: 87 additions & 49 deletions swift/manifests/proxy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,65 @@
#
# Installs and configures the swift proxy node.
#
# [*Parameters*]
#
# [*proxy_local_net_ip*] The address that the proxy will bind to.
# Required.
# [*port*] The port to which the proxy server will bind.
# Optional. Defaults to 8080.
# [*pipeline*] The list of elements of the swift proxy pipeline.
# Currently supports healthcheck, cache, proxy-server, and
# one of the following auth_types: tempauth, swauth, keystone.
# Each of the specified elements also need to be declared externally
# as a puppet class with the exception of proxy-server.
# Optional. Defaults to ['healthcheck', 'cache', 'tempauth', 'proxy-server']
# [*workers*] Number of threads to process requests.
# Optional. Defaults to the number of processors.
# [*allow_account_management*]
# Rather or not requests through this proxy can create and
# delete accounts. Optional. Defaults to true.
# [*account_autocreate*] Rather accounts should automatically be created.
# Has to be set to true for tempauth. Optional. Defaults to true.
# [*read_affinity*]
# Configures the read affinity of proxy-server. Optional. Defaults to undef.
# [*write_affinity*]
# Configures the write affinity of proxy-server. Optional. Defaults to undef.
# [*write_affinity_node_count*]
# Configures write_affinity_node_count for proxy-server.
# Optional but requires write_affinity to be set. Defaults to undef.
# [*package_ensure*] Ensure state of the swift proxy package.
# Optional. Defaults to present.
# [*log_name*]
# Configures log_name for swift proxy-server.
# Optional. Defaults to proxy-server
# == Parameters
#
# [*proxy_local_net_ip*]
# The address that the proxy will bind to.
#
# [*port*]
# (optional) The port to which the proxy server will bind.
# Defaults to 8080.
#
# [*pipeline*]
# (optional) The list of elements of the swift proxy pipeline.
# Currently supports healthcheck, cache, proxy-server, and
# one of the following auth_types: tempauth, swauth, keystone.
# Each of the specified elements also need to be declared externally
# as a puppet class with the exception of proxy-server.
# Defaults to ['healthcheck', 'cache', 'tempauth', 'proxy-server']
#
# [*workers*]
# (optional) Number of threads to process requests.
# Defaults to the number of processors.
#
# [*allow_account_management*]
# (optional) Rather or not requests through this proxy can create and
# delete accounts.
# Defaults to true.
#
# [*account_autocreate*]
# (optional) Rather accounts should automatically be created.
# Has to be set to true for tempauth.
# Defaults to true.
#
# [*read_affinity*]
# (optional) Configures the read affinity of proxy-server.
# Defaults to undef.
#
# [*write_affinity*]
# (optional) Configures the write affinity of proxy-server.
# Defaults to undef.
#
# [*write_affinity_node_count*]
# (optional) Configures write_affinity_node_count for proxy-server.
# Optional but requires write_affinity to be set.
# Defaults to undef.
#
# [*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) Ensure state of the swift proxy package.
# Defaults to present.
#
# [*log_name*]
# Configures log_name for swift proxy-server.
# Optional. Defaults to proxy-server
#
# == Examples
#
Expand All @@ -50,23 +78,25 @@
#
class swift::proxy(
$proxy_local_net_ip,
$port = '8080',
$pipeline = ['healthcheck', 'cache', 'tempauth', 'proxy-server'],
$workers = $::processorcount,
$allow_account_management = true,
$account_autocreate = true,
$log_headers = 'False',
$log_udp_host = '',
$log_udp_port = '',
$log_address = '/dev/log',
$log_level = 'INFO',
$log_facility = 'LOG_LOCAL1',
$log_handoffs = true,
$log_name = 'proxy-server',
$read_affinity = undef,
$write_affinity = undef,
$port = '8080',
$pipeline = ['healthcheck', 'cache', 'tempauth', 'proxy-server'],
$workers = $::processorcount,
$allow_account_management = true,
$account_autocreate = true,
$log_headers = 'False',
$log_udp_host = '',
$log_udp_port = '',
$log_address = '/dev/log',
$log_level = 'INFO',
$log_facility = 'LOG_LOCAL1',
$log_handoffs = true,
$log_name = 'proxy-server',
$read_affinity = undef,
$write_affinity = undef,
$write_affinity_node_count = undef,
$package_ensure = 'present'
$manage_service = true,
$enabled = true,
$package_ensure = 'present'
) {
include swift::params
Expand Down Expand Up @@ -130,10 +160,18 @@
before => Class[$required_classes],
}

if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}

service { 'swift-proxy':
ensure => running,
ensure => $service_ensure,
name => $::swift::params::proxy_service_name,
enable => true,
enable => $enabled,
provider => $::swift::params::service_provider,
hasstatus => true,
subscribe => Concat['/etc/swift/proxy-server.conf'],
Expand Down
35 changes: 31 additions & 4 deletions swift/manifests/storage/account.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
# Class swift::storage::account
#
# == 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'.
#
class swift::storage::account(
$manage_service = true,
$enabled = true,
$package_ensure = 'present'
) {
swift::storage::generic { 'account':
manage_service => $manage_service,
enabled => $enabled,
package_ensure => $package_ensure,
}

include swift::params

if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}

service { 'swift-account-reaper':
ensure => running,
ensure => $service_ensure,
name => $::swift::params::account_reaper_service_name,
enable => true,
enable => $enabled,
provider => $::swift::params::service_provider,
require => Package['swift-account'],
}

service { 'swift-account-auditor':
ensure => running,
ensure => $service_ensure,
name => $::swift::params::account_auditor_service_name,
enable => true,
enable => $enabled,
provider => $::swift::params::service_provider,
require => Package['swift-account'],
}
Expand Down
42 changes: 33 additions & 9 deletions swift/manifests/storage/container.pp
Original file line number Diff line number Diff line change
@@ -1,31 +1,55 @@
#
# === Parameters
# [*enabled*]
# (optional) Should the service be enabled.
# Defaults to true
#
# [*allowed_sync_hosts*] A list of hosts allowed in the X-Container-Sync-To
# field for containers. Defaults to one entry list '127.0.0.1'.
# [*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'.
#
# [*allowed_sync_hosts*]
# (optional) A list of hosts allowed in the X-Container-Sync-To
# field for containers. Defaults to one entry list '127.0.0.1'.
#
class swift::storage::container(
$package_ensure = 'present',
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$allowed_sync_hosts = ['127.0.0.1'],
) {
swift::storage::generic { 'container':
manage_service => $manage_service,
enabled => $enabled,
package_ensure => $package_ensure
}

include swift::params

if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}

service { 'swift-container-updater':
ensure => running,
ensure => $service_ensure,
name => $::swift::params::container_updater_service_name,
enable => true,
enable => $enabled,
provider => $::swift::params::service_provider,
require => Package['swift-container'],
}

service { 'swift-container-auditor':
ensure => running,
ensure => $service_ensure,
name => $::swift::params::container_auditor_service_name,
enable => true,
enable => $enabled,
provider => $::swift::params::service_provider,
require => Package['swift-container'],
}
Expand All @@ -41,8 +65,8 @@
target => '/lib/init/upstart-job',
}
service { 'swift-container-sync':
ensure => running,
enable => true,
ensure => $service_ensure,
enable => $enabled,
provider => $::swift::params::service_provider,
require => File['/etc/init/swift-container-sync.conf', '/etc/init.d/swift-container-sync']
}
Expand Down
35 changes: 28 additions & 7 deletions swift/manifests/storage/generic.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
# needed to deploy each type of storage server.
#
# == Parameters
# [*package_ensure*] The desired ensure state of the swift storage packages.
# Optional. Defaults to present.
# [*service_provider*] The provider to use for the service
# [*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) The desired ensure state of the swift storage packages.
# Defaults to present.
#
# [*service_provider*]
# (optional) The provider to use for the service
#
# == Dependencies
# Requires Class[swift::storage]
Expand All @@ -18,6 +29,8 @@
#
# Copyright 2011 Puppetlabs Inc, unless otherwise noted.
define swift::storage::generic(
$manage_service = true,
$enabled = true,
$package_ensure = 'present',
$service_provider = $::swift::params::service_provider
) {
Expand All @@ -42,19 +55,27 @@
group => 'swift',
}

if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}

service { "swift-${name}":
ensure => running,
ensure => $service_ensure,
name => inline_template("<%= scope.lookupvar('::swift::params::${name}_service_name') %>"),
enable => true,
enable => $enabled,
hasstatus => true,
provider => $service_provider,
subscribe => Package["swift-${name}"],
}

service { "swift-${name}-replicator":
ensure => running,
ensure => $service_ensure,
name => inline_template("<%= scope.lookupvar('::swift::params::${name}_replicator_service_name') %>"),
enable => true,
enable => $enabled,
hasstatus => true,
provider => $service_provider,
subscribe => Package["swift-${name}"],
Expand Down
Loading

0 comments on commit 8987b09

Please sign in to comment.