Add client_package_ensure parameter and swift::client class

In the actual state of the manifest we can only setup package_ensure to
absent|present|latest. This commit allow end users to pin swift* and
swift-client to a specific version. (note that swift* and
python-swiftclient version are not the same).

A new class (swift::client) manage now client packages, and we keep the
retro-compatibility of commit 020b7723cb.

Change-Id: I9bcc5a0f9d0a93a812fb574c4571fb9584077e4a
This commit is contained in:
Sebastien Badia 2014-03-05 23:57:26 +01:00
parent 2cce66ef44
commit 21f9eff35c
4 changed files with 57 additions and 9 deletions

20
manifests/client.pp Normal file
View File

@ -0,0 +1,20 @@
# == Class: swift::client
#
# Installs swift client.
#
# === Parameters
#
# [*ensure*]
# (optional) Ensure state of the package.
# Defaults to 'present'.
#
class swift::client (
$ensure = 'present'
) {
package { 'swiftclient':
ensure => $ensure,
name => $::swift::params::client_package,
}
}

View File

@ -4,8 +4,12 @@
# [*swift_hash_suffix*] string of text to be used
# as a salt when hashing to determine mappings in the ring.
# This file should be the same on every node in the cluster.
#
# [*package_ensure*] The ensure state for the swift package.
# Optional. Defaults to present.
# (Optional) Defaults to present.
#
# [*client_package_ensure*] The ensure state for the swift client package.
# (Optional) Defaults to present.
#
# == Dependencies
#
@ -21,7 +25,8 @@
#
class swift(
$swift_hash_suffix,
$package_ensure = 'present'
$package_ensure = 'present',
$client_package_ensure = 'present',
) {
include swift::params
@ -36,9 +41,8 @@ class swift(
}
}
package { 'swiftclient':
ensure => $package_ensure,
name => $::swift::params::client_package,
class { 'swift::client':
ensure => $client_package_ensure;
}
File { owner => 'swift', group => 'swift', require => Package['swift'] }

View File

@ -0,0 +1,16 @@
require 'spec_helper'
describe 'swift::client' do
describe "with default parameters" do
it { should contain_package('swiftclient').with_ensure('present') }
end
describe "with specified version" do
let :params do
{:ensure => '2.0.2-1'}
end
it { should contain_package('swiftclient').with_ensure(params[:ensure]) }
end
end

View File

@ -60,9 +60,17 @@ describe 'swift' do
describe 'when overriding package_ensure parameter' do
it 'should effect ensure state of swift package' do
params[:package_ensure] = 'latest'
subject.should contain_package('swift').with_ensure('latest')
params[:package_ensure] = '1.12.0-1'
subject.should contain_package('swift').with_ensure(params[:package_ensure])
end
end
describe 'when overriding client_package_ensure parameter' do
it 'should effect ensure state of swift package' do
params[:client_package_ensure] = '2.0.2-1'
subject.should contain_package('swiftclient').with_ensure(params[:client_package_ensure])
end
end
end