Initial classes/tests for a roles/profiles pattern
This is a first step to providing roles/profiles manifests according to the roles/profiles pattern. The roles/profiles pattern is a way to combine ceph manifests into functional units: Profiles combine multiple manifest to provide a single service. For example a ceph monitor server needs the repository, packages, configuration and finally the monitor service. Roles define sets of profiles to configure a specific server. For example an allinone role would install the monitor as well as an osd profile. The learn more have a look at: http://www.slideshare.net/PuppetLabs/roles-talk To start with the basic configuration this provides: * params: extracts the configuration from hiera * base: installs ceph and configures ceph.conf All configuration happens via hiera. Example hiera files are provided. NB: this uses hiera autoloading and will only work with Puppet >=3.0 Change-Id: Iba9aca7f124bd3a719dc18292b18fc0f4f386d5c
This commit is contained in:
parent
56e5ad2c2d
commit
4ea286a15b
29
examples/common.yaml
Normal file
29
examples/common.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
######## Ceph
|
||||
ceph::profile::params::release: 'firefly'
|
||||
|
||||
######## Ceph.conf
|
||||
ceph::profile::params::fsid: '4b5c8c0a-ff60-454b-a1b4-9747aa737d19'
|
||||
ceph::profile::params::authentication_type: 'cephx'
|
||||
ceph::profile::params::mon_initial_members: 'first, second'
|
||||
ceph::profile::params::mon_host: '10.11.12.2:6789, 10.11.12.3:6789'
|
||||
ceph::profile::params::osd_pool_default_pg_num: '200'
|
||||
ceph::profile::params::osd_pool_default_pgp_num: '200'
|
||||
ceph::profile::params::osd_pool_default_size: '2'
|
||||
ceph::profile::params::osd_pool_default_min_size: '1'
|
||||
ceph::profile::params::cluster_network: '10.12.13.0/24'
|
||||
ceph::profile::params::public_network: '10.11.12.0/24'
|
||||
|
||||
######## Keys
|
||||
ceph::profiles::params::mon_key: 'AQATGHJTUCBqIBAA7M2yafV1xctn1pgr3GcKPg=='
|
||||
ceph::profiles::params::mon_keyring: '/tmp/keyring'
|
||||
ceph::profiles::params::admin_key: 'AQBMGHJTkC8HKhAAJ7NH255wYypgm1oVuV41MA=='
|
||||
ceph::profiles::params::admin_key_mode: '0600'
|
||||
ceph::profiles::params::bootstrap_osd_key: 'AQARG3JTsDDEHhAAVinHPiqvJkUi5Mww/URupw=='
|
||||
ceph::profiles::params::bootstrap_mds_key: 'AQCztJdSyNb0NBAASA2yPZPuwXeIQnDJ9O8gVw=='
|
||||
ceph::profiles::params::osds:
|
||||
'/dev/sdc':
|
||||
journal: '/dev/sdb1'
|
||||
'/dev/sdd':
|
||||
journal: '/dev/sdb2'
|
||||
|
8
examples/hiera.yaml
Normal file
8
examples/hiera.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
:backends:
|
||||
- yaml
|
||||
:yaml:
|
||||
:datadir: /var/lib/hiera
|
||||
:hierarchy:
|
||||
- "nodes/%{::hostname}"
|
||||
- common
|
39
manifests/profile/base.pp
Normal file
39
manifests/profile/base.pp
Normal file
@ -0,0 +1,39 @@
|
||||
#
|
||||
# Copyright (C) 2014 Nine Internet Solutions AG
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Author: David Gurtner <david@nine.ch>
|
||||
#
|
||||
# Base profile to install ceph and configure /etc/ceph/ceph.conf
|
||||
#
|
||||
class ceph::profile::base {
|
||||
class { 'ceph::profile::params': } ->
|
||||
|
||||
class { 'ceph::repo':
|
||||
release => $ceph::profile::params::release,
|
||||
} ->
|
||||
|
||||
class { 'ceph':
|
||||
fsid => $ceph::profile::params::fsid,
|
||||
authentication_type => $ceph::profile::params::authentication_type,
|
||||
osd_pool_default_pg_num => $ceph::profile::params::osd_pool_default_pg_num,
|
||||
osd_pool_default_pgp_num => $ceph::profile::params::osd_pool_default_pgp_num,
|
||||
osd_pool_default_size => $ceph::profile::params::osd_pool_default_size,
|
||||
osd_pool_default_min_size => $ceph::profile::params::osd_pool_default_min_size,
|
||||
mon_initial_members => $ceph::profile::params::mon_initial_members,
|
||||
mon_host => $ceph::profile::params::mon_host,
|
||||
cluster_network => $ceph::profile::params::cluster_network,
|
||||
public_network => $ceph::profile::params::public_network,
|
||||
}
|
||||
}
|
41
manifests/profile/params.pp
Normal file
41
manifests/profile/params.pp
Normal file
@ -0,0 +1,41 @@
|
||||
#
|
||||
# Copyright (C) 2014 Nine Internet Solutions AG
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Author: David Gurtner <david@nine.ch>
|
||||
#
|
||||
# Extract the data from hiera where available
|
||||
#
|
||||
class ceph::profile::params (
|
||||
# puppet 2.7 compatibiliy hack. TODO: change to undef once 2.7 is deprecated
|
||||
$fsid = '4b5c8c0a-ff60-454b-a1b4-9747aa737d19',
|
||||
$release = undef,
|
||||
$authentication_type = undef,
|
||||
$mon_initial_members = undef,
|
||||
$mon_host = undef,
|
||||
$osd_pool_default_pg_num = undef,
|
||||
$osd_pool_default_pgp_num = undef,
|
||||
$osd_pool_default_size = undef,
|
||||
$osd_pool_default_min_size = undef,
|
||||
$cluster_network = undef,
|
||||
$public_network = undef,
|
||||
$admin_key = undef,
|
||||
$admin_key_mode = undef,
|
||||
$mon_key = undef,
|
||||
$mon_keyring = undef,
|
||||
$bootstrap_osd_key = undef,
|
||||
$bootstrap_mds_key = undef,
|
||||
$osds = undef,
|
||||
) {
|
||||
}
|
66
spec/classes/ceph_profile_base_spec.rb
Normal file
66
spec/classes/ceph_profile_base_spec.rb
Normal file
@ -0,0 +1,66 @@
|
||||
#
|
||||
# Copyright (C) 2014 Nine Internet Solutions AG
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# Author: David Gurtner <david@nine.ch>
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'ceph::profile::base' do
|
||||
|
||||
shared_examples_for 'ceph profile base' do
|
||||
it { should contain_class('ceph::profile::params') }
|
||||
it { should contain_class('ceph::repo') }
|
||||
it { should contain_class('ceph') }
|
||||
end
|
||||
|
||||
context 'on Debian' do
|
||||
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:lsbdistcodename => 'wheezy'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'ceph profile base'
|
||||
end
|
||||
|
||||
context 'on Ubuntu' do
|
||||
|
||||
let :facts do
|
||||
{
|
||||
:osfamily => 'Debian',
|
||||
:lsbdistcodename => 'Precise'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'ceph profile base'
|
||||
end
|
||||
|
||||
context 'on RHEL6' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat', }
|
||||
end
|
||||
|
||||
it_configures 'ceph profile base'
|
||||
end
|
||||
end
|
||||
# Local Variables:
|
||||
# compile-command: "cd ../.. ;
|
||||
# BUNDLE_PATH=/tmp/vendor bundle install ;
|
||||
# BUNDLE_PATH=/tmp/vendor bundle exec rake spec
|
||||
# "
|
||||
# End:
|
8
spec/fixtures/hieradata/hiera.yaml
vendored
Normal file
8
spec/fixtures/hieradata/hiera.yaml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
:backends:
|
||||
- yaml
|
||||
:yaml:
|
||||
:datadir: /var/lib/hiera
|
||||
:hierarchy:
|
||||
- "nodes/%{::hostname}"
|
||||
- common
|
@ -44,6 +44,9 @@ RSpec.configure do |c|
|
||||
:node => vm)
|
||||
shell(:command => 'puppet module install --version 1.4.0 puppetlabs/apt',
|
||||
:node => vm)
|
||||
rcp(:sp => File.join(proj_root, 'spec/fixtures/hieradata/hiera.yaml'),
|
||||
:dp => '/etc/puppet/hiera.yaml',
|
||||
:d => node(:name => vm))
|
||||
# Flush the firewall
|
||||
flushfw = <<-EOS
|
||||
iptables -F
|
||||
|
133
spec/system/ceph_profile_base_spec.rb
Normal file
133
spec/system/ceph_profile_base_spec.rb
Normal file
@ -0,0 +1,133 @@
|
||||
#
|
||||
# Copyright (C) 2014 Nine Internet Solutions AG
|
||||
#
|
||||
# Author: David Gurtner <david@nine.ch>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
require 'spec_helper_system'
|
||||
|
||||
describe 'ceph::profile::base' do
|
||||
|
||||
release2version = {
|
||||
'dumpling' => '0.67',
|
||||
'emperor' => '0.72',
|
||||
'firefly' => '0.80',
|
||||
}
|
||||
|
||||
releases = ENV['RELEASES'] ? ENV['RELEASES'].split : release2version.keys
|
||||
machines = ENV['MACHINES'] ? ENV['MACHINES'].split : [ 'first', 'second' ]
|
||||
# passing it directly as unqoted array is not supported everywhere
|
||||
packages = "[ 'python-ceph', 'ceph-common', 'librados2', 'librbd1', 'libcephfs1' ]"
|
||||
fsid = 'a4807c9a-e76f-4666-a297-6d6cbc922e3a'
|
||||
hieradata_common = '/var/lib/hiera/common.yaml'
|
||||
hiera_shared = <<-EOS
|
||||
---
|
||||
ceph::profile::params::fsid: '#{fsid}'
|
||||
EOS
|
||||
|
||||
releases.each do |release|
|
||||
describe release do
|
||||
|
||||
version = release2version[release]
|
||||
|
||||
after(:all) do
|
||||
pp = <<-EOS
|
||||
package { #{packages}:
|
||||
ensure => purged
|
||||
}
|
||||
class { 'ceph::repo':
|
||||
release => '#{release}',
|
||||
ensure => absent,
|
||||
}
|
||||
EOS
|
||||
|
||||
machines.each do |vm|
|
||||
puppet_apply(:node => vm, :code => pp) do |r|
|
||||
r.exit_code.should_not == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'on one host' do
|
||||
it 'should install ceph' do
|
||||
osfamily = facter.facts['osfamily']
|
||||
|
||||
osfamily2querycommand = {
|
||||
'Debian' => 'apt-cache policy ceph',
|
||||
'RedHat' => 'yum info ceph',
|
||||
}
|
||||
osfamily2queryresult = {
|
||||
'Debian' => "Candidate: #{version}" ,
|
||||
'RedHat' => "Version : #{version}",
|
||||
}
|
||||
|
||||
querycommand = osfamily2querycommand[osfamily]
|
||||
queryresult = osfamily2queryresult[osfamily]
|
||||
|
||||
hiera = <<-EOS
|
||||
ceph::profile::params::release: '#{release}'
|
||||
EOS
|
||||
|
||||
file = Tempfile.new('hieradata')
|
||||
begin
|
||||
file.write(hiera_shared + hiera)
|
||||
file.close
|
||||
rcp(:sp => file.path, :dp => hieradata_common, :d => node)
|
||||
ensure
|
||||
file.unlink
|
||||
end
|
||||
|
||||
pp = <<-EOS
|
||||
include ::ceph::profile::base
|
||||
EOS
|
||||
|
||||
puppet_apply(pp) do |r|
|
||||
r.exit_code.should_not == 1
|
||||
r.refresh
|
||||
r.exit_code.should_not == 1
|
||||
end
|
||||
|
||||
shell 'cat /etc/ceph/ceph.conf' do |r|
|
||||
r.stdout.should =~ /#{fsid}/
|
||||
r.stderr.should be_empty
|
||||
r.exit_code.should be_zero
|
||||
end
|
||||
|
||||
shell querycommand do |r|
|
||||
r.stdout.should =~ /#{queryresult}/
|
||||
r.stderr.should be_empty
|
||||
r.exit_code.should be_zero
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# Local Variables:
|
||||
# compile-command: "cd ../..
|
||||
# (
|
||||
# cd .rspec_system/vagrant_projects/one-ubuntu-server-12042-x64
|
||||
# vagrant destroy --force
|
||||
# )
|
||||
# cp -a Gemfile-rspec-system Gemfile
|
||||
# BUNDLE_PATH=/tmp/vendor bundle install --no-deployment
|
||||
# MACHINES=first \
|
||||
# RELEASES=dumpling \
|
||||
# RS_DESTROY=no \
|
||||
# RS_SET=one-ubuntu-server-12042-x64 \
|
||||
# BUNDLE_PATH=/tmp/vendor \
|
||||
# bundle exec rake spec:system SPEC=spec/system/ceph_profile_base_spec.rb &&
|
||||
# git checkout Gemfile
|
||||
# "
|
||||
# End:
|
Loading…
Reference in New Issue
Block a user