Pass subscribe and require into service resource

Before this update, subscribe and require could be passed
into the service class and work due to some default puppet
behaviors. This resulted in unknown variable warnings.  Removal
of these parameters would remove the required resource dependencies.

Adding new parameters 'service_subscribe' and 'service_require'
to pass in these dependencies. The 'service_' prefix is used
here because use of 'subscribe' or 'require' as parameter names
would also print a meta parameter warning.

Change-Id: I33d2d6028347bbe50dc9b3f36b3f86b217db7c0c
This commit is contained in:
Emilien Macchi 2016-11-21 09:26:37 -05:00 committed by Adam Vinsh
parent 8b1f4f3acb
commit 1b8869e6ae
6 changed files with 27 additions and 18 deletions

View File

@ -275,6 +275,6 @@ class swift::proxy(
enabled => $enabled,
config_file_name => 'proxy-server.conf',
service_provider => $service_provider,
require => Class[$required_classes]
service_require => Class[$required_classes]
}
}

View File

@ -31,12 +31,21 @@
# See README for more details.
# Defaults to $::swift::params::service_provider.
#
# [*service_subscribe*]
# (optional) Parameter used to pass in resources that this service should
# subscribe to.
#
# [*service_require*]
# (optional) Parameter used to pass in resources that this service requires.
#
define swift::service(
$os_family_service_name,
$config_file_name,
$service_ensure = undef,
$enabled = true,
$service_provider = $::swift::params::service_provider,
$service_ensure = undef,
$enabled = true,
$service_provider = $::swift::params::service_provider,
$service_subscribe = undef,
$service_require = undef,
) {
include ::swift::deps
@ -54,8 +63,8 @@ define swift::service(
enable => $enabled,
provider => $service_provider,
tag => 'swift-service',
subscribe => $subscribe,
require => $require,
subscribe => $service_subscribe,
require => $service_require,
}
} elsif $service_provider == 'swiftinit' {
service { $name:
@ -67,8 +76,8 @@ define swift::service(
pattern => $os_family_service_name,
manifest => $config_file_name,
tag => 'swift-service',
subscribe => $subscribe,
require => $require,
subscribe => $service_subscribe,
require => $service_require,
}
}
}

View File

@ -59,7 +59,7 @@ class swift::storage::account(
enabled => $enabled,
config_file_name => $config_file_name,
service_provider => $service_provider,
require => Package['swift-account'],
subscribe => Concat["/etc/swift/${config_file_name}"],
service_require => Package['swift-account'],
service_subscribe => Concat["/etc/swift/${config_file_name}"],
}
}

View File

@ -66,8 +66,8 @@ class swift::storage::container(
enabled => $enabled,
config_file_name => $config_file_name,
service_provider => $service_provider,
require => Package['swift-container'],
subscribe => Concat["/etc/swift/${config_file_name}"],
service_require => Package['swift-container'],
service_subscribe => Concat["/etc/swift/${config_file_name}"],
}
if $::osfamily == 'Debian' {
@ -77,8 +77,8 @@ class swift::storage::container(
enabled => $enabled,
config_file_name => $config_file_name,
service_provider => $service_provider,
require => Package['swift-container'],
subscribe => Concat["/etc/swift/${config_file_name}"],
service_require => Package['swift-container'],
service_subscribe => Concat["/etc/swift/${config_file_name}"],
}
Swift_config<| |> ~> Service['swift-container-sync']
}

View File

@ -76,7 +76,7 @@ define swift::storage::generic(
enabled => $enabled,
config_file_name => $config_file_name,
service_provider => $service_provider,
subscribe => Package["swift-${name}"],
service_subscribe => Package["swift-${name}"],
}
swift::service { "swift-${name}-replicator":
@ -85,7 +85,7 @@ define swift::storage::generic(
enabled => $enabled,
config_file_name => $config_file_name,
service_provider => $service_provider,
subscribe => Package["swift-${name}"],
service_subscribe => Package["swift-${name}"],
}
swift::service { "swift-${name}-auditor":
@ -94,6 +94,6 @@ define swift::storage::generic(
enabled => $enabled,
config_file_name => $config_file_name,
service_provider => $service_provider,
subscribe => Package["swift-${name}"],
service_subscribe => Package["swift-${name}"],
}
}

View File

@ -60,6 +60,6 @@ class swift::storage::object(
config_file_name => $config_file_name,
service_provider => $service_provider,
require => Package['swift-object'],
subscribe => Concat["/etc/swift/${config_file_name}"],
service_subscribe => Concat["/etc/swift/${config_file_name}"],
}
}