Page MenuHomeSoftware Heritage

No OneTemporary

diff --git a/examples/nodes/first.yaml b/examples/nodes/first.yaml
new file mode 100644
index 0000000..a573120
--- /dev/null
+++ b/examples/nodes/first.yaml
@@ -0,0 +1,6 @@
+---
+######## OSD
+ceph::profile::params::osds:
+ '/dev/sdb':
+ journal: '/tmp/journal'
+
diff --git a/examples/nodes/second.yaml b/examples/nodes/second.yaml
new file mode 100644
index 0000000..a573120
--- /dev/null
+++ b/examples/nodes/second.yaml
@@ -0,0 +1,6 @@
+---
+######## OSD
+ceph::profile::params::osds:
+ '/dev/sdb':
+ journal: '/tmp/journal'
+
diff --git a/manifests/profile/osd.pp b/manifests/profile/osd.pp
new file mode 100644
index 0000000..8d46ea9
--- /dev/null
+++ b/manifests/profile/osd.pp
@@ -0,0 +1,34 @@
+#
+# 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>
+#
+# Profile for a Ceph osd
+#
+class ceph::profile::osd inherits ceph::profile::base {
+ # this supports providing the key manually
+ if $ceph::profile::params::bootstrap_osd_key {
+ if ! defined(Ceph::Key['client.bootstrap-osd']) {
+ ceph::key { 'client.bootstrap-osd':
+ keyring_path => '/var/lib/ceph/bootstrap-osd/ceph.keyring',
+ secret => $ceph::profile::params::bootstrap_osd_key,
+ }
+ }
+ }
+
+ class { 'ceph::osds':
+ args => $ceph::profile::params::osds,
+ }
+}
diff --git a/spec/classes/ceph_profile_osd_spec.rb b/spec/classes/ceph_profile_osd_spec.rb
new file mode 100644
index 0000000..1ee303f
--- /dev/null
+++ b/spec/classes/ceph_profile_osd_spec.rb
@@ -0,0 +1,100 @@
+#
+# 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::osd' do
+
+ shared_examples_for 'ceph profile osd' do
+ context 'with the default osd defined in common.yaml' do
+
+ before :each do
+ facts.merge!( :hostname => 'osd')
+ end
+
+ it { should contain_ceph__key('client.bootstrap-osd').with(
+ :keyring_path => '/var/lib/ceph/bootstrap-osd/ceph.keyring',
+ :secret => 'AQARG3JTsDDEHhAAVinHPiqvJkUi5Mww/URupw==')
+ }
+ it { should contain_ceph__osd('/dev/sdc').with(:journal => '/dev/sdb1') }
+ it { should contain_ceph__osd('/dev/sdd').with(:journal => '/dev/sdb2') }
+ end
+
+ context 'with the host specific first.yaml' do
+
+ before :each do
+ facts.merge!( :hostname => 'first')
+ end
+
+ it { should contain_ceph__key('client.bootstrap-osd').with(
+ :keyring_path => '/var/lib/ceph/bootstrap-osd/ceph.keyring',
+ :secret => 'AQARG3JTsDDEHhAAVinHPiqvJkUi5Mww/URupw==')
+ }
+ it { should contain_ceph__osd('/dev/sdb').with( :journal => '/tmp/journal') }
+ end
+ end
+
+ describe 'on Debian' do
+
+ let :facts do
+ {
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'wheezy',
+ :operatingsystem => 'Debian',
+ }
+ end
+
+ # dont actually run any tests. these cannot run under puppet 2.7
+ # TODO: uncomment once 2.7 is deprecated
+ #it_configures 'ceph profile osd'
+ end
+
+ describe 'on Ubuntu' do
+
+ let :facts do
+ {
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'precise',
+ :operatingsystem => 'Ubuntu',
+ }
+ end
+
+ # dont actually run any tests. these cannot run under puppet 2.7
+ # TODO: uncomment once 2.7 is deprecated
+ #it_configures 'ceph profile osd'
+ end
+
+ describe 'on RedHat' do
+
+ let :facts do
+ {
+ :osfamily => 'RedHat',
+ :operatingsystem => 'RHEL6',
+ }
+ end
+
+ # dont actually run any tests. these cannot run under puppet 2.7
+ # TODO: uncomment once 2.7 is deprecated
+ #it_configures 'ceph profile osd'
+ end
+end
+# Local Variables:
+# compile-command: "cd ../.. ;
+# BUNDLE_PATH=/tmp/vendor bundle install ;
+# BUNDLE_PATH=/tmp/vendor bundle exec rake spec
+# "
+# End:
diff --git a/spec/fixtures/hieradata/nodes/first.yaml b/spec/fixtures/hieradata/nodes/first.yaml
new file mode 100644
index 0000000..a573120
--- /dev/null
+++ b/spec/fixtures/hieradata/nodes/first.yaml
@@ -0,0 +1,6 @@
+---
+######## OSD
+ceph::profile::params::osds:
+ '/dev/sdb':
+ journal: '/tmp/journal'
+
diff --git a/spec/system/ceph_profile_osd_spec.rb b/spec/system/ceph_profile_osd_spec.rb
new file mode 100644
index 0000000..95db2db
--- /dev/null
+++ b/spec/system/ceph_profile_osd_spec.rb
@@ -0,0 +1,443 @@
+#
+# Copyright 2014 (C) 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_system'
+
+describe 'ceph::profile::osd' do
+
+ releases = ENV['RELEASES'] ? ENV['RELEASES'].split : [ 'dumpling', 'emperor', 'firefly' ]
+ 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'
+ admin_key = 'AQA0TVRTsP/aHxAAFBvntu1dSEJHxtJeFFrRsg=='
+ mon_key = 'AQATGHJTUCBqIBAA7M2yafV1xctn1pgr3GcKPg=='
+ bootstrap_osd_key = 'AQARG3JTsDDEHhAAVinHPiqvJkUi5Mww/URupw=='
+ hieradata_common = '/var/lib/hiera/common.yaml'
+ hiera_shared = <<-EOS
+---
+ceph::profile::params::fsid: '#{fsid}'
+ceph::profile::params::mon_initial_members: 'first'
+ceph::profile::params::mon_host: '10.11.12.2:6789'
+ EOS
+
+ purge = <<-EOS
+ ceph::mon { 'first': ensure => absent }
+ ->
+ file { [
+ '/var/lib/ceph/bootstrap-osd/ceph.keyring',
+ '/etc/ceph/ceph.client.admin.keyring',
+ ]:
+ ensure => absent
+ }
+ EOS
+
+ releases.each do |release|
+ describe release do
+ 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 one monitor and one osd' do
+ hiera = <<-EOS
+ceph::profile::params::release: '#{release}'
+ceph::profile::params::authentication_type: 'none'
+ceph::profile::params::osds:
+ '/dev/sdb': {}
+ 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::mon
+ include ::ceph::profile::osd
+ EOS
+
+ puppet_apply(pp) do |r|
+ r.exit_code.should_not == 1
+ r.refresh
+ r.exit_code.should_not == 1
+ end
+
+ shell 'ceph osd tree' do |r|
+ r.stdout.should =~ /osd.0/
+ r.stderr.should be_empty
+ r.exit_code.should be_zero
+ end
+ end
+
+ it 'should uninstall one osd' do
+ shell 'ceph osd tree | grep DNE' do |r|
+ r.exit_code.should_not be_zero
+ end
+
+ pp = <<-EOS
+ ceph::osd { '/dev/sdb':
+ ensure => absent,
+ }
+ EOS
+
+ puppet_apply(pp) do |r|
+ r.exit_code.should_not == 1
+ end
+
+ shell 'ceph osd tree | grep DNE' do |r|
+ r.exit_code.should be_zero
+ end
+ shell 'ceph-disk zap /dev/sdb'
+ end
+
+ it 'should uninstall one monitor' do
+ puppet_apply(purge) do |r|
+ r.exit_code.should_not == 1
+ end
+ end
+
+ it 'should install one monitor and one osd with external journal' do
+ hiera = <<-EOS
+ceph::profile::params::release: '#{release}'
+ceph::profile::params::authentication_type: 'none'
+ceph::profile::params::osds:
+ '/dev/sdb':
+ journal: '/tmp/journal'
+ 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::mon
+ include ::ceph::profile::osd
+ EOS
+
+ puppet_apply(pp) do |r|
+ r.exit_code.should_not == 1
+ r.refresh
+ r.exit_code.should_not == 1
+ end
+
+ shell 'ceph osd tree' do |r|
+ r.stdout.should =~ /osd.0/
+ r.stderr.should be_empty
+ r.exit_code.should be_zero
+ end
+ end
+
+ it 'should uninstall one osd' do
+ shell 'ceph osd tree | grep DNE' do |r|
+ r.exit_code.should_not be_zero
+ end
+
+ pp = <<-EOS
+ ceph::osd { '/dev/sdb': ensure => absent, }
+ EOS
+
+ puppet_apply(pp) do |r|
+ r.exit_code.should_not == 1
+ end
+
+ shell 'ceph osd tree | grep DNE' do |r|
+ r.exit_code.should be_zero
+ end
+ shell 'ceph-disk zap /dev/sdb'
+ end
+
+ it 'should uninstall one monitor' do
+ puppet_apply(purge) do |r|
+ r.exit_code.should_not == 1
+ end
+ end
+
+ it 'should install one monitor and one osd', :cephx do
+ hiera = <<-EOS
+ceph::profile::params::release: '#{release}'
+ceph::profile::params::authentication_type: 'cephx'
+ceph::profile::params::admin_key: '#{admin_key}'
+ceph::profile::params::bootstrap_osd_key: '#{bootstrap_osd_key}'
+ceph::profile::params::mon_key: '#{mon_key}'
+ceph::profile::params::osds:
+ '/dev/sdb': {}
+ 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::mon
+ include ::ceph::profile::osd
+ EOS
+
+ puppet_apply(pp) do |r|
+ r.exit_code.should_not == 1
+ r.refresh
+ r.exit_code.should_not == 1
+ end
+
+ shell 'ceph osd tree' do |r|
+ r.stdout.should =~ /osd.0/
+ r.stderr.should be_empty
+ r.exit_code.should be_zero
+ end
+ end
+
+ it 'should uninstall one osd' do
+ shell 'ceph osd tree | grep DNE' do |r|
+ r.exit_code.should_not be_zero
+ end
+
+ pp = <<-EOS
+ ceph::osd { '/dev/sdb': ensure => absent, }
+ EOS
+
+ puppet_apply(pp) do |r|
+ r.exit_code.should_not == 1
+ end
+
+ shell 'ceph osd tree | grep DNE' do |r|
+ r.exit_code.should be_zero
+ end
+
+ shell 'ceph-disk zap /dev/sdb'
+ end
+
+ it 'should uninstall one monitor and all packages' do
+ puppet_apply(purge) do |r|
+ r.exit_code.should_not == 1
+ end
+ end
+ end
+
+ describe 'on two hosts' do
+ it 'should install one monitor on first host, one osd on second host' do
+ [ 'first', 'second' ].each do |vm|
+ hiera = <<-EOS
+ceph::profile::params::release: '#{release}'
+ceph::profile::params::authentication_type: 'none'
+ceph::profile::params::osds:
+ '/dev/sdb': {}
+ EOS
+
+ file = Tempfile.new('hieradata')
+ begin
+ file.write(hiera_shared + hiera)
+ file.close
+ rcp(:sp => file.path, :dp => hieradata_common, :d => node(:name => vm))
+ ensure
+ file.unlink
+ end
+
+ if vm == "first"
+ pp = <<-EOS
+ include ::ceph::profile::mon
+ EOS
+ end
+
+ if vm == "second"
+ pp = <<-EOS
+ include ::ceph::profile::osd
+ EOS
+ end
+
+ puppet_apply(:node => vm, :code => pp) do |r|
+ r.exit_code.should_not == 1
+ r.refresh
+ r.exit_code.should_not == 1
+ end
+ end
+
+ shell 'ceph -s' do |r|
+ r.stdout.should =~ /1 mons .* quorum 0 first/
+ r.stderr.should be_empty
+ r.exit_code.should be_zero
+ end
+
+ shell 'ceph osd tree' do |r|
+ r.stdout.should =~ /osd.0/
+ r.stderr.should be_empty
+ r.exit_code.should be_zero
+ end
+ end
+
+ it 'should uninstall one osd on second host' do
+ shell 'ceph osd tree | grep DNE' do |r|
+ r.exit_code.should_not be_zero
+ end
+
+ pp = <<-EOS
+ ceph::osd { '/dev/sdb': ensure => absent, }
+ EOS
+
+ puppet_apply(:node => 'second', :code => pp) do |r|
+ r.exit_code.should_not == 1
+ end
+
+ shell 'ceph osd tree | grep DNE' do |r|
+ r.exit_code.should be_zero
+ end
+
+ shell(:node => 'second', :command => 'ceph-disk zap /dev/sdb')
+
+ puppet_apply(:node => 'second', :code => purge) do |r|
+ r.exit_code.should_not == 1
+ end
+ end
+
+ it 'should uninstall one monitor on first host' do
+ puppet_apply(purge) do |r|
+ r.exit_code.should_not == 1
+ end
+ end
+
+ it 'should install one monitor on first host, one osd on second host', :cephx do
+ [ 'first', 'second' ].each do |vm|
+ hiera = <<-EOS
+ceph::profile::params::release: '#{release}'
+ceph::profile::params::authentication_type: 'cephx'
+ceph::profile::params::admin_key: '#{admin_key}'
+ceph::profile::params::bootstrap_osd_key: '#{bootstrap_osd_key}'
+ceph::profile::params::mon_key: '#{mon_key}'
+ceph::profile::params::osds:
+ '/dev/sdb': {}
+ EOS
+
+ file = Tempfile.new('hieradata')
+ begin
+ file.write(hiera_shared + hiera)
+ file.close
+ rcp(:sp => file.path, :dp => hieradata_common, :d => node(:name => vm))
+ ensure
+ file.unlink
+ end
+
+ if vm == "first"
+ pp = <<-EOS
+ include ::ceph::profile::mon
+ EOS
+ end
+
+ if vm == "second"
+ pp = <<-EOS
+ include ::ceph::profile::osd
+ EOS
+ end
+
+ puppet_apply(:node => vm, :code => pp) do |r|
+ r.exit_code.should_not == 1
+ r.refresh
+ r.exit_code.should_not == 1
+ end
+ end
+
+ shell 'ceph -s' do |r|
+ r.stdout.should =~ /1 mons .* quorum 0 first/
+ r.stderr.should be_empty
+ r.exit_code.should be_zero
+ end
+
+ shell 'ceph osd tree' do |r|
+ r.stdout.should =~ /osd.0/
+ r.stderr.should be_empty
+ r.exit_code.should be_zero
+ end
+ end
+
+ it 'should uninstall one osd on second host' do
+ shell 'ceph osd tree | grep DNE' do |r|
+ r.exit_code.should_not be_zero
+ end
+
+ pp = <<-EOS
+ # for osd removal we need additional credentials
+ # not included in the bootstrap-osd keyring
+ class { '::ceph::profile::client': } ->
+ ceph::osd { '/dev/sdb': ensure => absent, }
+ EOS
+
+ puppet_apply(:node => 'second', :code => pp) do |r|
+ r.exit_code.should_not == 1
+ end
+
+ shell 'ceph osd tree | grep DNE' do |r|
+ r.exit_code.should be_zero
+ end
+
+ shell(:node => 'second', :command => 'ceph-disk zap /dev/sdb')
+
+ puppet_apply(:node => 'second', :code => purge) do |r|
+ r.exit_code.should_not == 1
+ end
+ end
+
+ it 'should uninstall one monitor' do
+ puppet_apply(purge) do |r|
+ r.exit_code.should_not == 1
+ end
+ end
+ end
+ end
+ end
+end
+# Local Variables:
+# compile-command: "cd ../..
+# (
+# cd .rspec_system/vagrant_projects/two-ubuntu-server-12042-x64
+# vagrant destroy --force
+# )
+# cp -a Gemfile-rspec-system Gemfile
+# BUNDLE_PATH=/tmp/vendor bundle install --no-deployment
+# RELEASES=dumpling \
+# RS_SET=two-ubuntu-server-12042-x64 \
+# RS_DESTROY=no \
+# BUNDLE_PATH=/tmp/vendor \
+# bundle exec rake spec:system SPEC=spec/system/ceph_profile_osd_spec.rb &&
+# git checkout Gemfile
+# "
+# End:

File Metadata

Mime Type
text/x-diff
Expires
Mon, Aug 18, 7:45 PM (6 d, 4 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3339374

Event Timeline