Add hooks for external install & svc management

This adds defined anchor points for external modules to hook into the
software install, config and service dependency chain.  This allows
external modules to manage software installation (virtualenv,
containers, etc) and service management (pacemaker) without needing rely
on resources that may change or be renamed.

Change-Id: I00cf4846bb933291469be94c9debed425eddf798
This commit is contained in:
Adam Vinsh 2016-05-17 15:28:00 -04:00
parent 00193204a7
commit c659733d39
63 changed files with 237 additions and 36 deletions

View File

@ -25,11 +25,14 @@ class swift::auth_file (
$auth_url = 'http://127.0.0.1:5000/v2.0/' $auth_url = 'http://127.0.0.1:5000/v2.0/'
) { ) {
include ::swift::deps
file { '/root/swiftrc': file { '/root/swiftrc':
ensure => file, ensure => file,
owner => 'root', owner => 'root',
group => 'root', group => 'root',
mode => '0600', mode => '0600',
tag => 'swift-file',
content => content =>
" "
export ST_USER=${admin_tenant}:${admin_user} export ST_USER=${admin_tenant}:${admin_user}

View File

@ -84,6 +84,8 @@ class swift::bench (
$delete = 'yes', $delete = 'yes',
){ ){
include ::swift::deps
swift_bench_config { swift_bench_config {
'bench/auth': value => $auth_url; 'bench/auth': value => $auth_url;
'bench/user': value => $swift_user; 'bench/user': value => $swift_user;

View File

@ -12,12 +12,13 @@ class swift::client (
$ensure = 'present' $ensure = 'present'
) { ) {
include ::swift::deps
include ::swift::params include ::swift::params
package { 'swiftclient': package { 'swiftclient':
ensure => $ensure, ensure => $ensure,
name => $::swift::params::client_package, name => $::swift::params::client_package,
tag => 'openstack', tag => ['openstack','swift-support-package']
} }
} }

View File

@ -24,6 +24,7 @@ class swift::config (
$swift_config = {}, $swift_config = {},
) { ) {
include ::swift::deps
validate_hash($swift_config) validate_hash($swift_config)
create_resources('swift_config', $swift_config) create_resources('swift_config', $swift_config)

59
manifests/deps.pp Normal file
View File

@ -0,0 +1,59 @@
# == Class: swift::deps
#
# swift anchors and dependency management
#
class swift::deps {
# Setup anchors for install, config and service phases of the module. These
# anchors allow external modules to hook the begin and end of any of these
# phases. Package or service management can also be replaced by ensuring the
# package is absent or turning off service management and having the
# replacement depend on the appropriate anchors. When applicable, end tags
# should be notified so that subscribers can determine if installation,
# config or service state changed and act on that if needed.
anchor { 'swift::install::begin': }
-> Package<| tag == 'swift-package'|>
~> anchor { 'swift::install::end': }
-> anchor { 'swift::config::begin': }
-> Swift_config<||>
~> anchor { 'swift::config::end': }
~> anchor { 'swift::service::begin': }
~> Service<| tag == 'swift-service' |>
~> anchor { 'swift::service::end': }
~> Swift_dispersion_config<||>
Anchor['swift::config::begin']
-> Swift_proxy_config<||>
~> Anchor['swift::config::end']
Anchor['swift::config::begin']
-> Swift_object_config<||>
~> Anchor['swift::config::end']
Anchor['swift::config::begin']
-> Swift_container_config<||>
~> Anchor['swift::config::end']
Anchor['swift::config::begin']
-> Swift_account_config<||>
~> Anchor['swift::config::end']
Anchor['swift::config::begin']
-> File<| tag == 'swift-file' |>
~> Anchor['swift::config::end']
# Support packages need to be installed in the install phase, but we don't
# put them in the chain above because we don't want any false dependencies
# between packages with the swift-package tag and the swift-support-package
# tag. Note: the package resources here will have a 'before' relationshop on
# the swift::install::end anchor. The line between swift-support-package and
# swift-package should be whether or not swift services would need to be
# restarted if the package state was changed.
Anchor['swift::install::begin']
-> Package<| tag == 'swift-support-package'|>
-> Anchor['swift::install::end']
# Installation or config changes will always restart services.
Anchor['swift::install::end'] ~> Anchor['swift::service::begin']
Anchor['swift::config::end'] ~> Anchor['swift::service::begin']
}

View File

@ -80,15 +80,15 @@ class swift::dispersion (
$dump_json = 'no' $dump_json = 'no'
) { ) {
include ::swift::deps
include ::swift::params include ::swift::params
Swift_dispersion_config<||> ~> Exec['swift-dispersion-populate'] Swift_dispersion_config<||> ~> Exec['swift-dispersion-populate']
file { '/etc/swift/dispersion.conf': file { '/etc/swift/dispersion.conf':
ensure => file, ensure => file,
owner => 'swift', owner => 'swift',
group => 'swift', group => 'swift',
require => Package['swift'],
} }
swift_dispersion_config { swift_dispersion_config {

View File

@ -62,6 +62,7 @@ class swift(
$swift_hash_suffix = undef, $swift_hash_suffix = undef,
) { ) {
include ::swift::deps
include ::swift::params include ::swift::params
if ($swift_hash_suffix == undef and $swift_hash_path_suffix == undef) { if ($swift_hash_suffix == undef and $swift_hash_path_suffix == undef) {
@ -85,7 +86,11 @@ class swift(
ensure => $client_package_ensure; ensure => $client_package_ensure;
} }
File { owner => 'swift', group => 'swift', require => Package['swift'] } File {
owner => 'swift',
group => 'swift',
tag => 'swift-file',
}
file { '/etc/swift': file { '/etc/swift':
ensure => directory, ensure => directory,

View File

@ -183,6 +183,8 @@ class swift::keystone::auth(
$admin_address = undef, $admin_address = undef,
) { ) {
include ::swift::deps
if $endpoint_prefix { if $endpoint_prefix {
warning('The endpoint_prefix parameter is deprecated, use public_url, internal_url and admin_url instead.') warning('The endpoint_prefix parameter is deprecated, use public_url, internal_url and admin_url instead.')
} }

View File

@ -36,6 +36,8 @@ class swift::keystone::dispersion(
$tenant = 'services' $tenant = 'services'
) { ) {
include ::swift::deps
keystone_user { $auth_user: keystone_user { $auth_user:
ensure => present, ensure => present,
password => $auth_pass, password => $auth_pass,

View File

@ -81,6 +81,7 @@ class swift::objectexpirer(
$service_provider = $::swift::params::service_provider $service_provider = $::swift::params::service_provider
) inherits ::swift::params { ) inherits ::swift::params {
include ::swift::deps
Swift_config<| |> ~> Service['swift-object-expirer'] Swift_config<| |> ~> Service['swift-object-expirer']
Swift_object_expirer_config<||> ~> Service['swift-object-expirer'] Swift_object_expirer_config<||> ~> Service['swift-object-expirer']

View File

@ -141,6 +141,7 @@ class swift::proxy(
$service_provider = $::swift::params::service_provider $service_provider = $::swift::params::service_provider
) inherits ::swift::params { ) inherits ::swift::params {
include ::swift::deps
Swift_config<| |> ~> Service['swift-proxy-server'] Swift_config<| |> ~> Service['swift-proxy-server']
validate_bool($account_autocreate) validate_bool($account_autocreate)

View File

@ -18,6 +18,9 @@
# Configure Swift Account Quotas # Configure Swift Account Quotas
# #
class swift::proxy::account_quotas() { class swift::proxy::account_quotas() {
include ::swift::deps
concat::fragment { 'swift_account_quotas': concat::fragment { 'swift_account_quotas':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/account_quotas.conf.erb'), content => template('swift/proxy/account_quotas.conf.erb'),

View File

@ -87,6 +87,8 @@ class swift::proxy::authtoken(
$auth_admin_prefix = false, $auth_admin_prefix = false,
) { ) {
include ::swift::deps
if $auth_uri { if $auth_uri {
$auth_uri_real = $auth_uri $auth_uri_real = $auth_uri
} else { } else {
@ -116,6 +118,8 @@ class swift::proxy::authtoken(
owner => 'swift', owner => 'swift',
group => 'swift', group => 'swift',
selinux_ignore_defaults => true, selinux_ignore_defaults => true,
require => Anchor['swift::config::begin'],
before => Anchor['swift::config::end'],
} }
concat::fragment { 'swift_authtoken': concat::fragment { 'swift_authtoken':

View File

@ -43,6 +43,9 @@ class swift::proxy::bulk(
$max_deletes_per_request = '10000', $max_deletes_per_request = '10000',
$yield_frequency = '60', $yield_frequency = '60',
) { ) {
include ::swift::deps
concat::fragment { 'swift_bulk': concat::fragment { 'swift_bulk':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/bulk.conf.erb'), content => template('swift/proxy/bulk.conf.erb'),

View File

@ -22,6 +22,8 @@ class swift::proxy::cache(
$memcache_servers = ['127.0.0.1:11211'] $memcache_servers = ['127.0.0.1:11211']
) { ) {
include ::swift::deps
# require the memcached class if its on the same machine # require the memcached class if its on the same machine
if grep(any2array($memcache_servers), '^127\.0\.0\.1') { if grep(any2array($memcache_servers), '^127\.0\.0\.1') {
Class['memcached'] -> Class['swift::proxy::cache'] Class['memcached'] -> Class['swift::proxy::cache']

View File

@ -17,6 +17,8 @@
# #
class swift::proxy::catch_errors() { class swift::proxy::catch_errors() {
include ::swift::deps
concat::fragment { 'swift_catch_errors': concat::fragment { 'swift_catch_errors':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/catch_errors.conf.erb'), content => template('swift/proxy/catch_errors.conf.erb'),

View File

@ -78,6 +78,8 @@ class swift::proxy::ceilometer(
$group = 'ceilometer', $group = 'ceilometer',
) inherits swift { ) inherits swift {
include ::swift::deps
if(is_array($rabbit_hosts)) { if(is_array($rabbit_hosts)) {
$rabbit_hosts_with_creds = prefix($rabbit_hosts, "${rabbit_user}:${rabbit_password}@") $rabbit_hosts_with_creds = prefix($rabbit_hosts, "${rabbit_user}:${rabbit_password}@")
} }
@ -106,7 +108,7 @@ class swift::proxy::ceilometer(
package { 'python-ceilometermiddleware': package { 'python-ceilometermiddleware':
ensure => $ensure, ensure => $ensure,
tag => 'openstack', tag => ['openstack', 'swift-support-package'],
} }
} }

View File

@ -18,6 +18,9 @@
# Configure Swift Container Quotas # Configure Swift Container Quotas
# #
class swift::proxy::container_quotas() { class swift::proxy::container_quotas() {
include ::swift::deps
concat::fragment { 'swift_container_quotas': concat::fragment { 'swift_container_quotas':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/container_quotas.conf.erb'), content => template('swift/proxy/container_quotas.conf.erb'),

View File

@ -15,6 +15,8 @@ class swift::proxy::crossdomain (
$cross_domain_policy = '<allow-access-from domain="*" secure="false" />', $cross_domain_policy = '<allow-access-from domain="*" secure="false" />',
) { ) {
include ::swift::deps
concat::fragment { 'swift_crossdomain': concat::fragment { 'swift_crossdomain':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/crossdomain.conf.erb'), content => template('swift/proxy/crossdomain.conf.erb'),

View File

@ -34,6 +34,8 @@ class swift::proxy::dlo (
$max_get_time = '86400' $max_get_time = '86400'
) { ) {
include ::swift::deps
concat::fragment { 'swift_dlo': concat::fragment { 'swift_dlo':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/dlo.conf.erb'), content => template('swift/proxy/dlo.conf.erb'),

View File

@ -17,6 +17,8 @@
# #
class swift::proxy::formpost() { class swift::proxy::formpost() {
include ::swift::deps
concat::fragment { 'swift-proxy-formpost': concat::fragment { 'swift-proxy-formpost':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/formpost.conf.erb'), content => template('swift/proxy/formpost.conf.erb'),

View File

@ -43,6 +43,8 @@ class swift::proxy::gatekeeper(
$log_address = '/dev/log' $log_address = '/dev/log'
) { ) {
include ::swift::deps
concat::fragment { 'swift_gatekeeper': concat::fragment { 'swift_gatekeeper':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/gatekeeper.conf.erb'), content => template('swift/proxy/gatekeeper.conf.erb'),

View File

@ -15,6 +15,8 @@
# #
class swift::proxy::healthcheck() { class swift::proxy::healthcheck() {
include ::swift::deps
concat::fragment { 'swift_healthcheck': concat::fragment { 'swift_healthcheck':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/healthcheck.conf.erb'), content => template('swift/proxy/healthcheck.conf.erb'),

View File

@ -29,6 +29,8 @@ class swift::proxy::keystone(
$reseller_prefix = 'AUTH_' $reseller_prefix = 'AUTH_'
) { ) {
include ::swift::deps
concat::fragment { 'swift_keystone': concat::fragment { 'swift_keystone':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/keystone.conf.erb'), content => template('swift/proxy/keystone.conf.erb'),

View File

@ -7,6 +7,8 @@
# #
class swift::proxy::proxy_logging { class swift::proxy::proxy_logging {
include ::swift::deps
concat::fragment { 'swift_proxy-logging': concat::fragment { 'swift_proxy-logging':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/proxy-logging.conf.erb'), content => template('swift/proxy/proxy-logging.conf.erb'),

View File

@ -48,6 +48,8 @@ class swift::proxy::ratelimit(
$account_ratelimit = 0 $account_ratelimit = 0
) { ) {
include ::swift::deps
concat::fragment { 'swift_ratelimit': concat::fragment { 'swift_ratelimit':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/ratelimit.conf.erb'), content => template('swift/proxy/ratelimit.conf.erb'),

View File

@ -34,6 +34,8 @@ class swift::proxy::s3token(
$auth_protocol = 'http' $auth_protocol = 'http'
) { ) {
include ::swift::deps
concat::fragment { 'swift_s3token': concat::fragment { 'swift_s3token':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/s3token.conf.erb'), content => template('swift/proxy/s3token.conf.erb'),

View File

@ -49,6 +49,8 @@ class swift::proxy::slo (
$max_get_time = '86400' $max_get_time = '86400'
) { ) {
include ::swift::deps
concat::fragment { 'swift_slo': concat::fragment { 'swift_slo':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/slo.conf.erb'), content => template('swift/proxy/slo.conf.erb'),

View File

@ -18,6 +18,8 @@
# #
class swift::proxy::staticweb() { class swift::proxy::staticweb() {
include ::swift::deps
concat::fragment { 'swift-proxy-staticweb': concat::fragment { 'swift-proxy-staticweb':
target => '/etc/swift/proxy-server.conf', target => '/etc/swift/proxy-server.conf',
content => template('swift/proxy/staticweb.conf.erb'), content => template('swift/proxy/staticweb.conf.erb'),

View File

@ -21,9 +21,12 @@ class swift::proxy::swauth(
$package_ensure = 'present' $package_ensure = 'present'
) { ) {
include ::swift::deps
package { 'python-swauth': package { 'python-swauth':
ensure => $package_ensure, ensure => $package_ensure,
before => Package['swift-proxy'], before => Package['swift-proxy'],
tag => 'swift-package',
} }
concat::fragment { 'swift_proxy_swauth': concat::fragment { 'swift_proxy_swauth':

View File

@ -24,12 +24,13 @@ class swift::proxy::swift3(
$ensure = 'present' $ensure = 'present'
) { ) {
include ::swift::deps
include ::swift::params include ::swift::params
package { 'swift-plugin-s3': package { 'swift-plugin-s3':
ensure => $ensure, ensure => $ensure,
name => $::swift::params::swift3, name => $::swift::params::swift3,
tag => 'openstack', tag => ['openstack','swift-package']
} }
concat::fragment { 'swift_swift3': concat::fragment { 'swift_swift3':

View File

@ -81,6 +81,8 @@ class swift::proxy::tempauth (
$storage_url_scheme = undef, $storage_url_scheme = undef,
) { ) {
include ::swift::deps
validate_array($account_user_list) validate_array($account_user_list)
if ($reseller_prefix) { if ($reseller_prefix) {

View File

@ -52,6 +52,8 @@ class swift::proxy::tempurl (
$outgoing_allow_headers = undef, $outgoing_allow_headers = undef,
) { ) {
include ::swift::deps
if($methods) { if($methods) {
if is_array($methods) { if is_array($methods) {
$methods_real = join($methods,' ') $methods_real = join($methods,' ')

View File

@ -30,6 +30,7 @@ class swift::ringbuilder(
$min_part_hours = undef $min_part_hours = undef
) { ) {
include ::swift::deps
Class['swift'] -> Class['swift::ringbuilder'] Class['swift'] -> Class['swift::ringbuilder']
swift::ringbuilder::create{ ['object', 'account', 'container']: swift::ringbuilder::create{ ['object', 'account', 'container']:

View File

@ -39,6 +39,8 @@ define swift::ringbuilder::create(
$user = 'swift' $user = 'swift'
) { ) {
include ::swift::deps
validate_re($name, '^object|container|account$') validate_re($name, '^object|container|account$')
exec { "create_${name}": exec { "create_${name}":
@ -46,6 +48,7 @@ define swift::ringbuilder::create(
path => ['/usr/bin'], path => ['/usr/bin'],
user => $user, user => $user,
creates => "/etc/swift/${name}.builder", creates => "/etc/swift/${name}.builder",
before => Anchor['swift::config::end'],
} }
} }

View File

@ -12,6 +12,8 @@ define swift::ringbuilder::rebalance(
$seed = undef $seed = undef
) { ) {
include ::swift::deps
validate_re($name, '^object|container|account$') validate_re($name, '^object|container|account$')
if $seed { if $seed {
validate_re($seed, '^\d+$') validate_re($seed, '^\d+$')
@ -21,5 +23,6 @@ define swift::ringbuilder::rebalance(
command => strip("swift-ring-builder /etc/swift/${name}.builder rebalance ${seed}"), command => strip("swift-ring-builder /etc/swift/${name}.builder rebalance ${seed}"),
path => ['/usr/bin'], path => ['/usr/bin'],
refreshonly => true, refreshonly => true,
before => Anchor['swift::config::end'],
} }
} }

View File

@ -30,6 +30,7 @@ class swift::ringserver(
$max_connections = 5 $max_connections = 5
) { ) {
include ::swift::deps
Class['swift::ringbuilder'] -> Class['swift::ringserver'] Class['swift::ringbuilder'] -> Class['swift::ringserver']
if !defined(Class['rsync::server']) { if !defined(Class['rsync::server']) {

View File

@ -7,6 +7,8 @@ define swift::ringsync(
$ring_server $ring_server
) { ) {
include ::swift::deps
Exec { path => '/usr/bin' } Exec { path => '/usr/bin' }
rsync::get { "/etc/swift/${name}.ring.gz": rsync::get { "/etc/swift/${name}.ring.gz":

View File

@ -39,6 +39,7 @@ define swift::service(
$service_provider = $::swift::params::service_provider, $service_provider = $::swift::params::service_provider,
) { ) {
include ::swift::deps
include ::swift::params include ::swift::params
if(! member($::swift::params::swift_init_service_names, $name)) { if(! member($::swift::params::swift_init_service_names, $name)) {

View File

@ -23,6 +23,8 @@ class swift::storage(
$storage_local_net_ip $storage_local_net_ip
) { ) {
include ::swift::deps
if !defined(Class['rsync::server']){ if !defined(Class['rsync::server']){
class{ '::rsync::server': class{ '::rsync::server':
use_xinetd => true, use_xinetd => true,

View File

@ -34,6 +34,7 @@ class swift::storage::account(
$service_provider = $::swift::params::service_provider $service_provider = $::swift::params::service_provider
) inherits ::swift::params { ) inherits ::swift::params {
include ::swift::deps
Swift_config<| |> ~> Service['swift-account-reaper'] Swift_config<| |> ~> Service['swift-account-reaper']
swift::storage::generic { 'account': swift::storage::generic { 'account':

View File

@ -91,6 +91,8 @@ class swift::storage::all(
$outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r', $outgoing_chmod = 'Du=rwx,g=rx,o=rx,Fu=rw,g=r,o=r',
) { ) {
include ::swift::deps
class { '::swift::storage': class { '::swift::storage':
storage_local_net_ip => $storage_local_net_ip, storage_local_net_ip => $storage_local_net_ip,
} }

View File

@ -40,6 +40,8 @@ class swift::storage::container(
$service_provider = $::swift::params::service_provider $service_provider = $::swift::params::service_provider
) inherits ::swift::params { ) inherits ::swift::params {
include ::swift::deps
Swift_config<| |> ~> Service['swift-container-updater'] Swift_config<| |> ~> Service['swift-container-updater']
swift::storage::generic { 'container': swift::storage::generic { 'container':

View File

@ -49,11 +49,15 @@ define swift::storage::disk(
$byte_size = '1024', $byte_size = '1024',
) { ) {
include ::swift::deps
if(!defined(File[$mnt_base_dir])) { if(!defined(File[$mnt_base_dir])) {
file { $mnt_base_dir: file { $mnt_base_dir:
ensure => directory, ensure => directory,
owner => 'swift', owner => 'swift',
group => 'swift', group => 'swift',
require => Anchor['swift::config::begin'],
before => Anchor['swift::config::end'],
} }
} }
@ -61,6 +65,7 @@ define swift::storage::disk(
command => "parted -s ${base_dir}/${name} mklabel gpt", command => "parted -s ${base_dir}/${name} mklabel gpt",
path => ['/usr/bin/', '/sbin','/bin'], path => ['/usr/bin/', '/sbin','/bin'],
onlyif => ["test -b ${base_dir}/${name}","parted ${base_dir}/${name} print|tail -1|grep 'Error'"], onlyif => ["test -b ${base_dir}/${name}","parted ${base_dir}/${name} print|tail -1|grep 'Error'"],
before => Anchor['swift::config::end'],
} }
swift::storage::xfs { $name: swift::storage::xfs { $name:

View File

@ -29,12 +29,14 @@ define swift::storage::ext4(
$loopback = false $loopback = false
) { ) {
include ::swift::deps
# does this have to be refreshonly? # does this have to be refreshonly?
# how can I know if this drive has been formatted? # how can I know if this drive has been formatted?
exec { "mkfs-${name}": exec { "mkfs-${name}":
command => "mkfs.ext4 -I ${byte_size} -F ${device}", command => "mkfs.ext4 -I ${byte_size} -F ${device}",
path => ['/sbin/'], path => ['/sbin/'],
refreshonly => true, refreshonly => true,
before => Anchor['swift::config::end'],
} }
swift::storage::mount { $name: swift::storage::mount { $name:

View File

@ -17,6 +17,8 @@
define swift::storage::filter::healthcheck( define swift::storage::filter::healthcheck(
) { ) {
include ::swift::deps
concat::fragment { "swift_healthcheck_${name}": concat::fragment { "swift_healthcheck_${name}":
target => "/etc/swift/${name}-server.conf", target => "/etc/swift/${name}-server.conf",
content => template('swift/proxy/healthcheck.conf.erb'), content => template('swift/proxy/healthcheck.conf.erb'),

View File

@ -22,6 +22,8 @@ define swift::storage::filter::recon(
$cache_path = '/var/cache/swift' $cache_path = '/var/cache/swift'
) { ) {
include ::swift::deps
concat::fragment { "swift_recon_${name}": concat::fragment { "swift_recon_${name}":
target => "/etc/swift/${name}-server.conf", target => "/etc/swift/${name}-server.conf",
content => template('swift/recon.conf.erb'), content => template('swift/recon.conf.erb'),

View File

@ -38,6 +38,7 @@ define swift::storage::generic(
$service_provider = $::swift::params::service_provider $service_provider = $::swift::params::service_provider
) { ) {
include ::swift::deps
include ::swift::params include ::swift::params
Class['swift::storage'] -> Swift::Storage::Generic[$name] Class['swift::storage'] -> Swift::Storage::Generic[$name]
@ -55,10 +56,10 @@ define swift::storage::generic(
} }
file { "/etc/swift/${name}-server/": file { "/etc/swift/${name}-server/":
ensure => directory, ensure => directory,
owner => 'swift', owner => 'swift',
group => 'swift', group => 'swift',
require => Package["swift-${name}"], tag => 'swift-file',
} }
if $manage_service { if $manage_service {

View File

@ -38,17 +38,23 @@ define swift::storage::loopback(
$fstype = 'xfs' $fstype = 'xfs'
) { ) {
include ::swift::deps
if(!defined(File[$base_dir])) { if(!defined(File[$base_dir])) {
file { $base_dir: file { $base_dir:
ensure => directory, ensure => directory,
require => Anchor['swift::config::begin'],
before => Anchor['swift::config::end'],
} }
} }
if(!defined(File[$mnt_base_dir])) { if(!defined(File[$mnt_base_dir])) {
file { $mnt_base_dir: file { $mnt_base_dir:
ensure => directory, ensure => directory,
owner => 'swift', owner => 'swift',
group => 'swift', group => 'swift',
require => Anchor['swift::config::begin'],
before => Anchor['swift::config::end'],
} }
} }
@ -57,6 +63,7 @@ define swift::storage::loopback(
path => ['/usr/bin/', '/bin'], path => ['/usr/bin/', '/bin'],
unless => "test -f ${base_dir}/${name}", unless => "test -f ${base_dir}/${name}",
require => File[$base_dir], require => File[$base_dir],
before => Anchor['swift::config::end'],
} }
$storage_params = { $storage_params = {

View File

@ -28,6 +28,8 @@ define swift::storage::mount(
$fstype = 'xfs' $fstype = 'xfs'
) { ) {
include ::swift::deps
if($loopback){ if($loopback){
$options = 'noatime,nodiratime,nobarrier,loop' $options = 'noatime,nodiratime,nobarrier,loop'
} else { } else {
@ -43,9 +45,11 @@ define swift::storage::mount(
# the directory that represents the mount point # the directory that represents the mount point
# needs to exist # needs to exist
file { "${mnt_base_dir}/${name}": file { "${mnt_base_dir}/${name}":
ensure => directory, ensure => directory,
owner => 'swift', owner => 'swift',
group => 'swift', group => 'swift',
require => Anchor['swift::config::begin'],
before => Anchor['swift::config::end'],
} }
mount { "${mnt_base_dir}/${name}": mount { "${mnt_base_dir}/${name}":
@ -64,6 +68,7 @@ define swift::storage::mount(
unless => "grep ${mnt_base_dir}/${name} /etc/mtab", unless => "grep ${mnt_base_dir}/${name} /etc/mtab",
# TODO - this needs to be removed when I am done testing # TODO - this needs to be removed when I am done testing
logoutput => true, logoutput => true,
before => Anchor['swift::config::end'],
} }
exec { "fix_mount_permissions_${name}": exec { "fix_mount_permissions_${name}":
@ -71,6 +76,7 @@ define swift::storage::mount(
path => ['/usr/sbin', '/bin'], path => ['/usr/sbin', '/bin'],
subscribe => Exec["mount_${name}"], subscribe => Exec["mount_${name}"],
refreshonly => true, refreshonly => true,
before => Anchor['swift::config::end'],
} }
# mounting in linux and puppet is broken and non-atomic # mounting in linux and puppet is broken and non-atomic
@ -85,7 +91,7 @@ define swift::storage::mount(
command => "restorecon ${mnt_base_dir}/${name}", command => "restorecon ${mnt_base_dir}/${name}",
path => ['/usr/sbin', '/sbin'], path => ['/usr/sbin', '/sbin'],
subscribe => Exec["mount_${name}"], subscribe => Exec["mount_${name}"],
before => Exec["fix_mount_permissions_${name}"], before => [Exec["fix_mount_permissions_${name}"],Anchor['swift::config::end']],
refreshonly => true, refreshonly => true,
} }
} }

View File

@ -55,6 +55,8 @@ define swift::storage::node(
$manage_ring = true $manage_ring = true
) { ) {
include ::swift::deps
validate_re($zone, '^\d+$', 'The zone parameter must be an integer') validate_re($zone, '^\d+$', 'The zone parameter must be an integer')
Swift::Storage::Server { Swift::Storage::Server {

View File

@ -34,6 +34,7 @@ class swift::storage::object(
$service_provider = $::swift::params::service_provider $service_provider = $::swift::params::service_provider
) inherits ::swift::params { ) inherits ::swift::params {
include ::swift::deps
Swift_config<| |> ~> Service['swift-object-updater'] Swift_config<| |> ~> Service['swift-object-updater']
swift::storage::generic { 'object': swift::storage::generic { 'object':

View File

@ -137,6 +137,8 @@ define swift::storage::server(
$config_file_path = "${type}-server.conf", $config_file_path = "${type}-server.conf",
) { ) {
include ::swift::deps
if ($incoming_chmod == '0644') { if ($incoming_chmod == '0644') {
warning('The default incoming_chmod set to 0644 may yield in error prone directories and will be changed in a later release.') warning('The default incoming_chmod set to 0644 may yield in error prone directories and will be changed in a later release.')
} }

View File

@ -35,6 +35,7 @@ define swift::storage::xfs(
$loopback = false $loopback = false
) { ) {
include ::swift::deps
include ::swift::xfs include ::swift::xfs
if $device == '' { if $device == '' {
@ -45,9 +46,11 @@ define swift::storage::xfs(
if(!defined(File[$mnt_base_dir])) { if(!defined(File[$mnt_base_dir])) {
file { $mnt_base_dir: file { $mnt_base_dir:
ensure => directory, ensure => directory,
owner => 'swift', owner => 'swift',
group => 'swift', group => 'swift',
require => Anchor['swift::config::begin'],
before => Anchor['swift::config::end'],
} }
} }
@ -60,6 +63,7 @@ define swift::storage::xfs(
path => ['/sbin/', '/usr/sbin/'], path => ['/sbin/', '/usr/sbin/'],
require => Package['xfsprogs'], require => Package['xfsprogs'],
unless => "xfs_admin -l ${target_device}", unless => "xfs_admin -l ${target_device}",
before => Anchor['swift::config::end'],
} }
swift::storage::mount { $name: swift::storage::mount { $name:

View File

@ -36,8 +36,12 @@ class swift::test_file (
$tenant = 'openstack', $tenant = 'openstack',
$user = 'admin' $user = 'admin'
) { ) {
include ::swift::deps
file { '/tmp/swift_test_file.rb': file { '/tmp/swift_test_file.rb':
mode => '0755', mode => '0755',
content => template('swift/swift_keystone_test.erb'), content => template('swift/swift_keystone_test.erb'),
tag => 'swift-file',
} }
} }

View File

@ -3,6 +3,8 @@
# xfs partitions # xfs partitions
class swift::xfs { class swift::xfs {
include ::swift::deps
$packages = ['xfsprogs', 'parted'] $packages = ['xfsprogs', 'parted']
ensure_packages($packages) ensure_packages($packages)

View File

@ -0,0 +1,10 @@
---
prelude: >
Add hooks for external install & svc management.
features:
- This adds defined anchor points for external modules to
hook into the software install, config and service dependency
chain. This allows external modules to manage software
installation (virtualenv, containers, etc) and service management
(pacemaker) without needing rely on resources that may change or
be renamed.

View File

@ -50,13 +50,11 @@ describe 'basic swift' do
part_power => '18', part_power => '18',
replicas => '1', replicas => '1',
min_part_hours => 1, min_part_hours => 1,
require => Class['swift'],
} }
class { '::swift::proxy': class { '::swift::proxy':
proxy_local_net_ip => '127.0.0.1', proxy_local_net_ip => '127.0.0.1',
pipeline => ['healthcheck', 'proxy-logging', 'cache', 'authtoken', 'keystone', 'dlo', 'proxy-server'], pipeline => ['healthcheck', 'proxy-logging', 'cache', 'authtoken', 'keystone', 'dlo', 'proxy-server'],
account_autocreate => true, account_autocreate => true,
require => Class['swift::ringbuilder'],
} }
class { '::swift::proxy::authtoken': class { '::swift::proxy::authtoken':
admin_password => 'a_big_secret', admin_password => 'a_big_secret',
@ -142,13 +140,11 @@ describe 'basic swift' do
part_power => '18', part_power => '18',
replicas => '1', replicas => '1',
min_part_hours => 1, min_part_hours => 1,
require => Class['swift'],
} }
class { '::swift::proxy': class { '::swift::proxy':
proxy_local_net_ip => '127.0.0.1', proxy_local_net_ip => '127.0.0.1',
pipeline => ['healthcheck', 'proxy-logging', 'cache', 'authtoken', 'keystone', 'dlo', 'proxy-server'], pipeline => ['healthcheck', 'proxy-logging', 'cache', 'authtoken', 'keystone', 'dlo', 'proxy-server'],
account_autocreate => true, account_autocreate => true,
require => Class['swift::ringbuilder'],
service_provider => 'swiftinit', service_provider => 'swiftinit',
} }
class { '::swift::proxy::authtoken': class { '::swift::proxy::authtoken':

View File

@ -21,7 +21,7 @@ describe 'swift::client' do
is_expected.to contain_package('swiftclient').with( is_expected.to contain_package('swiftclient').with(
:name => 'python-swiftclient', :name => 'python-swiftclient',
:ensure => p[:package_ensure], :ensure => p[:package_ensure],
:tag => 'openstack' :tag => ['openstack','swift-support-package'],
) )
end end

View File

@ -31,8 +31,7 @@ describe 'swift::dispersion' do
it { is_expected.to contain_file('/etc/swift/dispersion.conf').with( it { is_expected.to contain_file('/etc/swift/dispersion.conf').with(
:ensure => 'file', :ensure => 'file',
:owner => 'swift', :owner => 'swift',
:group => 'swift', :group => 'swift',)
:require => 'Package[swift]')
} }
shared_examples 'swift::dispersion' do shared_examples 'swift::dispersion' do

View File

@ -37,6 +37,9 @@ describe 'swift::proxy' do
{:proxy_local_net_ip => '127.0.0.1'} {:proxy_local_net_ip => '127.0.0.1'}
end end
it { is_expected.to contain_package('swift-proxy').that_requires('Anchor[swift::install::begin]')
is_expected.to contain_package('swift-proxy').that_notifies('Anchor[swift::install::end]') }
it { is_expected.to contain_service('swift-proxy-server').with( it { is_expected.to contain_service('swift-proxy-server').with(
{:ensure => 'running', {:ensure => 'running',
:provider => nil, :provider => nil,
@ -46,6 +49,12 @@ describe 'swift::proxy' do
:tag => 'swift-service', :tag => 'swift-service',
} }
)} )}
it { is_expected.to contain_concat('/etc/swift/proxy-server.conf').with(
{:ensure => 'present',
:owner => 'swift',
:group => 'swift',
}
)}
it 'should build the header file with all of the default contents' do it 'should build the header file with all of the default contents' do
is_expected.to contain_concat_fragment('swift_proxy').with_content('# This file is managed by puppet. Do not edit is_expected.to contain_concat_fragment('swift_proxy').with_content('# This file is managed by puppet. Do not edit

View File

@ -30,7 +30,7 @@ describe 'swift' do
{ {
:owner => 'swift', :owner => 'swift',
:group => 'swift', :group => 'swift',
:require => 'Package[swift]' :tag => 'swift-file',
} }
end end
it {is_expected.to contain_user('swift')} it {is_expected.to contain_user('swift')}
@ -55,7 +55,9 @@ describe 'swift' do
is_expected.to contain_swift_config( is_expected.to contain_swift_config(
'swift-constraints/max_header_size').with_value('16384') 'swift-constraints/max_header_size').with_value('16384')
end end
it { is_expected.to contain_package('swift').with_ensure('present') } it { is_expected.to contain_package('swift').with_ensure('present')
is_expected.to contain_package('swift').that_requires('Anchor[swift::install::begin]')
is_expected.to contain_package('swift').that_notifies('Anchor[swift::install::end]')}
it { is_expected.to contain_file('/etc/swift/swift.conf').with_before(/Swift_config\[.+\]/) } it { is_expected.to contain_file('/etc/swift/swift.conf').with_before(/Swift_config\[.+\]/) }
end end

View File

@ -55,7 +55,8 @@ describe 'swift::storage::generic' do
it do it do
is_expected.to contain_package("swift-#{t}").with( is_expected.to contain_package("swift-#{t}").with(
:ensure => params[:package_ensure], :ensure => params[:package_ensure],
:tag => ['openstack', 'swift-package'] :tag => ['openstack', 'swift-package'],
:notify => ['Anchor[swift::install::end]']
) )
end end
it do it do