diff options
Diffstat (limited to 'manifests/profile/base/swift')
-rw-r--r-- | manifests/profile/base/swift/add_devices.pp | 58 | ||||
-rw-r--r-- | manifests/profile/base/swift/proxy.pp | 15 | ||||
-rw-r--r-- | manifests/profile/base/swift/ringbuilder.pp | 80 | ||||
-rw-r--r-- | manifests/profile/base/swift/storage.pp | 12 |
4 files changed, 157 insertions, 8 deletions
diff --git a/manifests/profile/base/swift/add_devices.pp b/manifests/profile/base/swift/add_devices.pp new file mode 100644 index 0000000..bd4c91c --- /dev/null +++ b/manifests/profile/base/swift/add_devices.pp @@ -0,0 +1,58 @@ +# Copyright 2015 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# == Function: tripleo::profile::base::swift::add_devices +# +# Swift add_devices helper function +# +# === Parameters +# +# [*swift_zones*] +# (Optional) The number of swift zones. +# +define tripleo::profile::base::swift::add_devices( + $swift_zones = '1' +){ + # NOTE(dprince): Swift zones is not yet properly wired into the Heat + # templates. See: https://review.openstack.org/#/c/97758/3 + # For now our regex supports the r1z1-192.0.2.6:%PORT%/d1 syntax or the + # newer r1z%<controller or SwiftStorage><N>%-192.0.2.6:%PORT%/d1 syntax. + $server_num_or_device = regsubst($name,'^r1z%+[A-Za-z]*([0-9]+)%+-(.*)$','\1') + if (is_integer($server_num_or_device)) { + $server_num = $server_num_or_device + } else { + $server_num = '1' + } + # Function to place server in its zone. Zone is calculated by + # server number in heat template modulo the number of zones + 1. + $zone = (($server_num%$swift_zones) + 1) + + # add the rings + $base = regsubst($name,'^r1.*-(.*)$','\1') + $object = regsubst($base, '%PORT%', '6000') + ring_object_device { $object: + zone => '1', + weight => 100, + } + $container = regsubst($base, '%PORT%', '6001') + ring_container_device { $container: + zone => '1', + weight => 100, + } + $account = regsubst($base, '%PORT%', '6002') + ring_account_device { $account: + zone => '1', + weight => 100, + } +} diff --git a/manifests/profile/base/swift/proxy.pp b/manifests/profile/base/swift/proxy.pp index 40e61ae..a95d05f 100644 --- a/manifests/profile/base/swift/proxy.pp +++ b/manifests/profile/base/swift/proxy.pp @@ -23,16 +23,27 @@ # for more details. # Defaults to hiera('step') # +# [*memcache_servers*] +# (Optional) List of memcache servers +# Defaults to hiera('memcached_node_ips') +# +# [*memcache_port*] +# (Optional) memcache port +# Defaults to 11211 # class tripleo::profile::base::swift::proxy ( $step = hiera('step'), + $memcache_servers = hiera('memcached_node_ips'), + $memcache_port = 11211, ) { - if $step >= 4 { + $swift_memcache_servers = suffix($memcache_servers, ":${memcache_port}") include ::swift::proxy include ::swift::proxy::proxy_logging include ::swift::proxy::healthcheck - include ::swift::proxy::cache + class { '::swift::proxy::cache': + memcache_servers => $swift_memcache_servers + } include ::swift::proxy::keystone include ::swift::proxy::authtoken include ::swift::proxy::staticweb diff --git a/manifests/profile/base/swift/ringbuilder.pp b/manifests/profile/base/swift/ringbuilder.pp new file mode 100644 index 0000000..e0f67cd --- /dev/null +++ b/manifests/profile/base/swift/ringbuilder.pp @@ -0,0 +1,80 @@ +# Copyright 2015 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# == Class: tripleo::profile::base::swift::ringbuilder +# +# Swift ringbuilder profile for tripleo +# +# === Parameters +# +# [*replicas*] +# replicas +# +# [*build_ring*] = true, +# (Optional) Whether to build the ring +# Defaults to true +# +# [*devices*] +# (Optional) The swift devices +# Defaults to '' +# +# [*step*] +# (Optional) The current step in deployment. See tripleo-heat-templates +# for more details. +# Defaults to hiera('step') +# +# [*swift_zones*] +# (Optional) The swift zones +# Defaults to 1 +# +class tripleo::profile::base::swift::ringbuilder ( + $replicas, + $build_ring = true, + $devices = '', + $step = hiera('step'), + $swift_zones = '1', +) { + if $step >= 2 { + # pre-install swift here so we can build rings + include ::swift + } + + if $step >= 3 { + validate_bool($build_ring) + + if $build_ring { + + $device_array = strip(split(rstrip($devices), ',')) + + # create local rings + swift::ringbuilder::create{ ['object', 'account', 'container']: + replicas => min(count($device_array), $replicas), + } -> + + # add all other devices + tripleo::profile::base::swift::add_devices {$device_array: + swift_zones => $swift_zones, + } -> + + # rebalance + swift::ringbuilder::rebalance{ ['object', 'account', 'container']: + seed => 999, + } + + Ring_object_device<| |> ~> Exec['rebalance_object'] + Ring_object_device<| |> ~> Exec['rebalance_account'] + Ring_object_device<| |> ~> Exec['rebalance_container'] + } + } +} diff --git a/manifests/profile/base/swift/storage.pp b/manifests/profile/base/swift/storage.pp index 371cb0d..0b09ea6 100644 --- a/manifests/profile/base/swift/storage.pp +++ b/manifests/profile/base/swift/storage.pp @@ -18,23 +18,23 @@ # # === Parameters # +# [*enable_swift_storage*] +# (Optional) enable_swift_storage +# Deprecated: defaults to true +# # [*step*] # (Optional) The current step in deployment. See tripleo-heat-templates # for more details. # Defaults to hiera('step') # -# [*enable_swift_storage*] -# (Optional) enable_swift_storage -# Deprecated: defaults to true -# class tripleo::profile::base::swift::storage ( - $step = hiera('step'), # Deprecated conditional to support ControllerEnableSwiftStorage parameter $enable_swift_storage = true, + $step = hiera('step'), ) { - if $step >= 4 { if $enable_swift_storage { + include ::swift::storage::disks include ::swift::storage::all if(!defined(File['/srv/node'])) { file { '/srv/node': |