diff --git a/.zuul.yaml b/.zuul.yaml index 04692c1..9143f5d 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,7 +1,15 @@ - project: templates: - puppet-openstack-check-jobs - puppet-openstack-module-unit-jobs - - puppet-openstack-integration-jobs-scenario001 - - puppet-openstack-integration-jobs-scenario004 - release-notes-jobs-python3 + check: + jobs: + - puppet-openstack-integration-5-scenario001-tempest-ubuntu-bionic-mimic: + voting: false + - puppet-openstack-integration-5-scenario001-tempest-centos-7-luminous: + voting: false + - puppet-openstack-integration-5-scenario004-tempest-ubuntu-bionic-mimic: + voting: false + - puppet-openstack-integration-5-scenario004-tempest-centos-7-mimic: + voting: false diff --git a/manifests/osd.pp b/manifests/osd.pp index 1540b58..80ca723 100644 --- a/manifests/osd.pp +++ b/manifests/osd.pp @@ -1,283 +1,254 @@ # # Copyright (C) 2014 Cloudwatt # 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: Loic Dachary # Author: David Gurtner # # == Define: ceph::osd # # Install and configure a ceph OSD # # === Parameters: # # [*title*] The OSD data path. -# Mandatory. A path in which the OSD data is to be stored. +# Mandatory. The path for a disk or vg/lv used for the OSD # # [*ensure*] Installs ( present ) or remove ( absent ) an OSD # Optional. Defaults to present. # If set to absent, it will stop the OSD service and remove # the associated data directory. # # [*journal*] The OSD filestore journal path. # Optional. Defaults to co-locating the journal with the data # defined by *title*. # # [*bluestore_wal*] The OSD bluestore WAL path. # Optional. Defaults to co-locating the WAL with the data # defined by *title*. # # [*bluestore_db*] The OSD bluestore WAL path. # Optional. Defaults to co-locating the DB with the data # defined by *title*. # # [*store_type*] The OSD backing store type. # Optional. Defaults undef and will follow the ceph version default. # should be either filestore or bluestore. # # [*cluster*] The ceph cluster # Optional. Same default as ceph. # # [*exec_timeout*] The default exec resource timeout, in seconds # Optional. Defaults to $::ceph::params::exec_timeout # # [*selinux_file_context*] The SELinux file context to apply # on the directory backing the OSD service. # Optional. Defaults to 'ceph_var_lib_t' # # [*fsid*] The ceph cluster FSID # Optional. Defaults to $::ceph::profile::params::fsid # # [*dmcrypt*] Encrypt [data-path] and/or journal devices with dm-crypt. # Optional. Defaults to false. # # [*dmcrypt_key_dir*] Directory where dm-crypt keys are stored. # Optional. Defaults to '/etc/ceph/dmcrypt-keys'. # define ceph::osd ( $ensure = present, - $journal = "''", + $journal = undef, $cluster = undef, $bluestore_wal = undef, $bluestore_db = undef, $store_type = undef, $exec_timeout = $::ceph::params::exec_timeout, $selinux_file_context = 'ceph_var_lib_t', $fsid = $::ceph::profile::params::fsid, $dmcrypt = false, $dmcrypt_key_dir = '/etc/ceph/dmcrypt-keys', ) { include ::ceph::params $data = $name if $cluster { $cluster_name = $cluster } else { $cluster_name = 'ceph' } $cluster_option = "--cluster ${cluster_name}" if $store_type { $osd_type = "--${store_type}" } if ($bluestore_wal) or ($bluestore_db) { if $bluestore_wal { - $wal_opts = "--block.wal $(readlink -f ${bluestore_wal})" + $wal_opts = "--block.wal ${bluestore_wal}" } if $bluestore_db { - $block_opts = "--block.db $(readlink -f ${bluestore_db})" + $block_opts = "--block.db ${bluestore_db}" } $journal_opts = "${wal_opts} ${block_opts}" + } elsif $journal { + $journal_opts = "--journal ${journal}" } else { - $journal_opts = "$(readlink -f ${journal})" + $journal_opts = '' } if $dmcrypt { $dmcrypt_options = " --dmcrypt --dmcrypt-key-dir '${dmcrypt_key_dir}'" } else { $dmcrypt_options = '' } if $ensure == present { - $ceph_check_udev = "ceph-osd-check-udev-${name}" $ceph_prepare = "ceph-osd-prepare-${name}" $ceph_activate = "ceph-osd-activate-${name}" - Package<| tag == 'ceph' |> -> Exec[$ceph_check_udev] Ceph_config<||> -> Exec[$ceph_prepare] Ceph::Mon<||> -> Exec[$ceph_prepare] Ceph::Key<||> -> Exec[$ceph_prepare] # Ensure none is activated before prepare is finished for all Exec<| tag == 'prepare' |> -> Exec<| tag == 'activate' |> - $udev_rules_file = '/usr/lib/udev/rules.d/95-ceph-osd.rules' - exec { $ceph_check_udev: - command => "/bin/true # comment to satisfy puppet syntax requirements -# Before Infernalis the udev rules race causing the activation to fail so we -# disable them. More at: http://www.spinics.net/lists/ceph-devel/msg28436.html -mv -f ${udev_rules_file} ${udev_rules_file}.disabled && udevadm control --reload || true -", - onlyif => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -DISABLE_UDEV=$(ceph --version | awk 'match(\$3, /[0-9]+\\.[0-9]+/) {if (substr(\$3, RSTART, RLENGTH) <= 0.94) {print 1} else { print 0 } }') -test -f ${udev_rules_file} && test \$DISABLE_UDEV -eq 1 -", - logoutput => true, - } - if $fsid { - $fsid_option = "--cluster-uuid ${fsid}" + $fsid_option = "--cluster-fsid ${fsid}" $ceph_check_fsid_mismatch = "ceph-osd-check-fsid-mismatch-${name}" - Exec[$ceph_check_udev] -> Exec[$ceph_check_fsid_mismatch] Exec[$ceph_check_fsid_mismatch] -> Exec[$ceph_prepare] # return error if $(readlink -f ${data}) has fsid differing from ${fsid}, unless there is no fsid exec { $ceph_check_fsid_mismatch: command => "/bin/true # comment to satisfy puppet syntax requirements set -ex -test ${fsid} = $(ceph-disk list $(readlink -f ${data}) | egrep -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}') +exit 1 ", unless => "/bin/true # comment to satisfy puppet syntax requirements set -ex -test -z $(ceph-disk list $(readlink -f ${data}) | egrep -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}') +if [ -z $(ceph-volume lvm list ${data} |grep 'cluster fsid' | awk -F'fsid' '{print \$2}'|tr -d ' ') ]; then + exit 0 +fi +test ${fsid} = $(ceph-volume lvm list ${data} |grep 'cluster fsid' | awk -F'fsid' '{print \$2}'|tr -d ' ') ", logoutput => true, timeout => $exec_timeout, } } - Exec[$ceph_check_udev] -> Exec[$ceph_prepare] - # ceph-disk: prepare should be idempotent http://tracker.ceph.com/issues/7475 exec { $ceph_prepare: command => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f ${data}) + +if [ $(echo ${data}|cut -c 1) = '/' ]; then + disk=${data} +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev/${data} +fi if ! test -b \$disk ; then - echo \$disk | egrep -e '^/dev' -q -v - mkdir -p \$disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph \$disk - fi + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi -ceph-disk prepare ${osd_type} ${cluster_option}${dmcrypt_options} ${fsid_option} $(readlink -f ${data}) ${journal_opts} -udevadm settle +ceph-volume lvm prepare ${osd_type} ${cluster_option}${dmcrypt_options} ${fsid_option} --data ${data} ${journal_opts} ", unless => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f ${data}) -ceph-disk list | egrep \" *((\${disk}1?|\${disk}p1?) .*ceph data, (prepared|active)|\\ -(\${disk}5?|\${disk}p5?) .*ceph lockbox, (prepared|active), for (\${disk}1?|\${disk}p1?))\" || -{ test -f \$disk/fsid && test -f \$disk/ceph_fsid && test -f \$disk/magic ;} +ceph-volume lvm list ${data} ", logoutput => true, timeout => $exec_timeout, tag => 'prepare', } if (str2bool($::selinux) == true) { ensure_packages($::ceph::params::pkg_policycoreutils, {'ensure' => 'present'}) exec { "fcontext_${name}": command => "/bin/true # comment to satisfy puppet syntax requirements set -ex semanage fcontext -a -t ${selinux_file_context} \"$(readlink -f ${data})(/.*)?\" restorecon -R $(readlink -f ${data}) ", require => [Package[$::ceph::params::pkg_policycoreutils],Exec[$ceph_prepare]], before => Exec[$ceph_activate], unless => "/usr/bin/test -b $(readlink -f ${data}) || (semanage fcontext -l | grep $(readlink -f ${data}))", } } Exec[$ceph_prepare] -> Exec[$ceph_activate] exec { $ceph_activate: command => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f ${data}) -if ! test -b \$disk ; then - echo \$disk | egrep -e '^/dev' -q -v - mkdir -p \$disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph \$disk - fi -fi -# activate happens via udev when using the entire device -if ! test -b \$disk && ! ( test -b \${disk}1 || test -b \${disk}p1 ); then - ceph-disk activate \$disk || true +if [ $(echo ${data}|cut -c 1) = '/' ]; then + disk=${data} +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev/${data} fi -if test -f ${udev_rules_file}.disabled && ( test -b \${disk}1 || test -b \${disk}p1 ); then - ceph-disk activate \${disk}1 || true +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi +id=$(ceph-volume lvm list ${data} | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +fsid=$(ceph-volume lvm list ${data} | grep 'osd fsid'|awk -F 'osd fsid' '{print \$2}'|tr -d ' ') +ceph-volume lvm activate \$id \$fsid ", unless => "/bin/true # comment to satisfy puppet syntax requirements set -ex -ceph-disk list | egrep \" *((\${disk}1?|\${disk}p1?) .*ceph data, active|\\ -(\${disk}5?|\${disk}p5?) .*ceph lockbox, active, for (\${disk}1?|\${disk}p1?))\" || -ls -ld /var/lib/ceph/osd/${cluster_name}-* | grep \" $(readlink -f ${data})\$\" +id=$(ceph-volume lvm list ${data} | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +ps -fCceph-osd|grep \"\\--id \$id \" ", logoutput => true, tag => 'activate', } } elsif $ensure == absent { # ceph-disk: support osd removal http://tracker.ceph.com/issues/7454 exec { "remove-osd-${name}": command => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f ${data}) -if [ -z \"\$id\" ] ; then - id=$(ceph-disk list | sed -nEe \"s:^ *\${disk}1? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\") -fi -if [ -z \"\$id\" ] ; then - id=$(ls -ld /var/lib/ceph/osd/${cluster_name}-* | sed -nEe \"s:.*/${cluster_name}-([0-9]+) *-> *\${disk}\$:\\1:p\" || true) -fi +id=$(ceph-volume lvm list ${data} | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') if [ \"\$id\" ] ; then + ceph ${cluster_option} osd out osd.\$id stop ceph-osd cluster=${cluster_name} id=\$id || true service ceph stop osd.\$id || true systemctl stop ceph-osd@\$id || true ceph ${cluster_option} osd crush remove osd.\$id ceph ${cluster_option} auth del osd.\$id ceph ${cluster_option} osd rm \$id rm -fr /var/lib/ceph/osd/${cluster_name}-\$id/* umount /var/lib/ceph/osd/${cluster_name}-\$id || true rm -fr /var/lib/ceph/osd/${cluster_name}-\$id + ceph-volume lvm zap ${data} fi ", unless => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -disk=$(readlink -f ${data}) -if [ -z \"\$id\" ] ; then - id=$(ceph-disk list | sed -nEe \"s:^ *\${disk}1? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\") -fi -if [ -z \"\$id\" ] ; then - id=$(ls -ld /var/lib/ceph/osd/${cluster_name}-* | sed -nEe \"s:.*/${cluster_name}-([0-9]+) *-> *\${disk}\$:\\1:p\" || true) -fi -if [ \"\$id\" ] ; then - test ! -d /var/lib/ceph/osd/${cluster_name}-\$id +set -x +ceph-volume lvm list ${data} +if [ \$? -eq 0 ]; then + exit 1 else - true # if there is no id we do nothing + exit 0 fi ", logoutput => true, timeout => $exec_timeout, } -> Ceph::Mon<| ensure == absent |> } else { fail('Ensure on OSD must be either present or absent') } } diff --git a/spec/defines/ceph_osd_spec.rb b/spec/defines/ceph_osd_spec.rb index 2cb33fa..16544e8 100644 --- a/spec/defines/ceph_osd_spec.rb +++ b/spec/defines/ceph_osd_spec.rb @@ -1,652 +1,529 @@ # # Copyright (C) 2014 Cloudwatt # # 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: Loic Dachary # Author: David Gurtner # require 'spec_helper' describe 'ceph::osd' do shared_examples 'ceph osd' do describe "with default params" do let :title do - '/srv' + 'vg_test/lv_test' end - it { should contain_exec('ceph-osd-check-udev-/srv').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements -# Before Infernalis the udev rules race causing the activation to fail so we -# disable them. More at: http://www.spinics.net/lists/ceph-devel/msg28436.html -mv -f /usr/lib/udev/rules.d/95-ceph-osd.rules /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && udevadm control --reload || true -", - 'onlyif' => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -DISABLE_UDEV=$(ceph --version | awk 'match(\$3, /[0-9]+\\.[0-9]+/) {if (substr(\$3, RSTART, RLENGTH) <= 0.94) {print 1} else { print 0 } }') -test -f /usr/lib/udev/rules.d/95-ceph-osd.rules && test \$DISABLE_UDEV -eq 1 -", - 'logoutput' => true, - ) } - it { should contain_exec('ceph-osd-prepare-/srv').with( + it { should contain_exec('ceph-osd-prepare-vg_test/lv_test').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /srv) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi + +if [ $(echo vg_test/lv_test|cut -c 1) = '/' ]; then + disk=vg_test/lv_test +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev/vg_test/lv_test fi -ceph-disk prepare --cluster ceph $(readlink -f /srv) $(readlink -f '') -udevadm settle +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 +fi +ceph-volume lvm prepare --cluster ceph --data vg_test/lv_test ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /srv) -ceph-disk list | egrep \" *((${disk}1?|${disk}p1?) .*ceph data, (prepared|active)|\\ -(${disk}5?|${disk}p5?) .*ceph lockbox, (prepared|active), for (${disk}1?|${disk}p1?))\" || -{ test -f $disk/fsid && test -f $disk/ceph_fsid && test -f $disk/magic ;} +ceph-volume lvm list vg_test/lv_test ", 'logoutput' => true ) } - it { should contain_exec('ceph-osd-activate-/srv').with( + it { should contain_exec('ceph-osd-activate-vg_test/lv_test').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /srv) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi -fi -# activate happens via udev when using the entire device -if ! test -b \$disk && ! ( test -b \${disk}1 || test -b \${disk}p1 ); then - ceph-disk activate $disk || true +if [ $(echo vg_test/lv_test|cut -c 1) = '/' ]; then + disk=vg_test/lv_test +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev/vg_test/lv_test fi -if test -f /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && ( test -b ${disk}1 || test -b ${disk}p1 ); then - ceph-disk activate ${disk}1 || true +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi +id=$(ceph-volume lvm list vg_test/lv_test | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +fsid=$(ceph-volume lvm list vg_test/lv_test | grep 'osd fsid'|awk -F 'osd fsid' '{print \$2}'|tr -d ' ') +ceph-volume lvm activate \$id \$fsid ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -ceph-disk list | egrep \" *((\${disk}1?|\${disk}p1?) .*ceph data, active|\\ -(\${disk}5?|\${disk}p5?) .*ceph lockbox, active, for (\${disk}1?|\${disk}p1?))\" || -ls -ld /var/lib/ceph/osd/ceph-* | grep \" $(readlink -f /srv)\$\" +id=$(ceph-volume lvm list vg_test/lv_test | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +ps -fCceph-osd|grep \"\\--id \$id \" ", 'logoutput' => true ) } end describe "with bluestore params" do let :title do - '/srv/data' + 'vg_test/lv_test' end let :params do { :cluster => 'testcluster', :journal => '/srv/journal', :fsid => 'f39ace04-f967-4c3d-9fd2-32af2d2d2cd5', :store_type => 'bluestore', - :bluestore_wal => '/srv/wal', - :bluestore_db => '/srv/db', + :bluestore_wal => 'vg_test/lv_wal', + :bluestore_db => 'vg_test/lv_db', } end - it { should contain_exec('ceph-osd-check-udev-/srv/data').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements -# Before Infernalis the udev rules race causing the activation to fail so we -# disable them. More at: http://www.spinics.net/lists/ceph-devel/msg28436.html -mv -f /usr/lib/udev/rules.d/95-ceph-osd.rules /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && udevadm control --reload || true -", - 'onlyif' => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -DISABLE_UDEV=$(ceph --version | awk 'match(\$3, /[0-9]+\\.[0-9]+/) {if (substr(\$3, RSTART, RLENGTH) <= 0.94) {print 1} else { print 0 } }') -test -f /usr/lib/udev/rules.d/95-ceph-osd.rules && test \$DISABLE_UDEV -eq 1 -", - 'logoutput' => true, - ) } - it { should contain_exec('ceph-osd-check-fsid-mismatch-/srv/data').with( + it { should contain_exec('ceph-osd-check-fsid-mismatch-vg_test/lv_test').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -test f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 = $(ceph-disk list $(readlink -f /srv/data) | egrep -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}') +exit 1 ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -test -z $(ceph-disk list $(readlink -f /srv/data) | egrep -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}') +if [ -z $(ceph-volume lvm list vg_test/lv_test |grep 'cluster fsid' | awk -F'fsid' '{print \$2}'|tr -d ' ') ]; then + exit 0 +fi +test f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 = $(ceph-volume lvm list vg_test/lv_test |grep 'cluster fsid' | awk -F'fsid' '{print \$2}'|tr -d ' ') ", 'logoutput' => true ) } - it { should contain_exec('ceph-osd-prepare-/srv/data').with( + it { should contain_exec('ceph-osd-prepare-vg_test/lv_test').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /srv/data) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi + +if [ $(echo vg_test/lv_test|cut -c 1) = '/' ]; then + disk=vg_test/lv_test +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev/vg_test/lv_test +fi +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi -ceph-disk prepare --bluestore --cluster testcluster --cluster-uuid f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 $(readlink -f /srv/data) --block.wal $(readlink -f /srv/wal) --block.db $(readlink -f /srv/db) -udevadm settle +ceph-volume lvm prepare --bluestore --cluster testcluster --cluster-fsid f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 --data vg_test/lv_test --block.wal vg_test/lv_wal --block.db vg_test/lv_db ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /srv/data) -ceph-disk list | egrep \" *((${disk}1?|${disk}p1?) .*ceph data, (prepared|active)|\\ -(${disk}5?|${disk}p5?) .*ceph lockbox, (prepared|active), for (${disk}1?|${disk}p1?))\" || -{ test -f $disk/fsid && test -f $disk/ceph_fsid && test -f $disk/magic ;} +ceph-volume lvm list vg_test/lv_test ", 'logoutput' => true ) } - it { should contain_exec('ceph-osd-activate-/srv/data').with( + it { should contain_exec('ceph-osd-activate-vg_test/lv_test').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /srv/data) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi -fi -# activate happens via udev when using the entire device -if ! test -b \$disk && ! ( test -b \${disk}1 || test -b \${disk}p1 ); then - ceph-disk activate $disk || true +if [ $(echo vg_test/lv_test|cut -c 1) = '/' ]; then + disk=vg_test/lv_test +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev/vg_test/lv_test fi -if test -f /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && ( test -b ${disk}1 || test -b ${disk}p1 ); then - ceph-disk activate ${disk}1 || true +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi +id=$(ceph-volume lvm list vg_test/lv_test | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +fsid=$(ceph-volume lvm list vg_test/lv_test | grep 'osd fsid'|awk -F 'osd fsid' '{print \$2}'|tr -d ' ') +ceph-volume lvm activate \$id \$fsid ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -ceph-disk list | egrep \" *((\${disk}1?|\${disk}p1?) .*ceph data, active|\\ -(\${disk}5?|\${disk}p5?) .*ceph lockbox, active, for (\${disk}1?|\${disk}p1?))\" || -ls -ld /var/lib/ceph/osd/testcluster-* | grep \" $(readlink -f /srv/data)\$\" +id=$(ceph-volume lvm list vg_test/lv_test | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +ps -fCceph-osd|grep \"\\--id \$id \" ", 'logoutput' => true ) } end describe "with dmcrypt enabled" do let :title do '/dev/sdc' end let :params do { :dmcrypt => true, } end - it { is_expected.to contain_exec('ceph-osd-check-udev-/dev/sdc').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements -# Before Infernalis the udev rules race causing the activation to fail so we -# disable them. More at: http://www.spinics.net/lists/ceph-devel/msg28436.html -mv -f /usr/lib/udev/rules.d/95-ceph-osd.rules /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && udevadm control --reload || true -", - 'onlyif' => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -DISABLE_UDEV=$(ceph --version | awk 'match(\$3, /[0-9]+\\.[0-9]+/) {if (substr(\$3, RSTART, RLENGTH) <= 0.94) {print 1} else { print 0 } }') -test -f /usr/lib/udev/rules.d/95-ceph-osd.rules && test \$DISABLE_UDEV -eq 1 -", - 'logoutput' => true, - ) } it { is_expected.to contain_exec('ceph-osd-prepare-/dev/sdc').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/sdc) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi + +if [ $(echo /dev/sdc|cut -c 1) = '/' ]; then + disk=/dev/sdc +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev//dev/sdc +fi +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi -ceph-disk prepare --cluster ceph --dmcrypt --dmcrypt-key-dir '/etc/ceph/dmcrypt-keys' $(readlink -f /dev/sdc) $(readlink -f '') -udevadm settle +ceph-volume lvm prepare --cluster ceph --dmcrypt --dmcrypt-key-dir '/etc/ceph/dmcrypt-keys' --data /dev/sdc ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/sdc) -ceph-disk list | egrep \" *((${disk}1?|${disk}p1?) .*ceph data, (prepared|active)|\\ -(${disk}5?|${disk}p5?) .*ceph lockbox, (prepared|active), for (${disk}1?|${disk}p1?))\" || -{ test -f $disk/fsid && test -f $disk/ceph_fsid && test -f $disk/magic ;} +ceph-volume lvm list /dev/sdc ", 'logoutput' => true ) } it { is_expected.to contain_exec('ceph-osd-activate-/dev/sdc').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/sdc) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi -fi -# activate happens via udev when using the entire device -if ! test -b \$disk && ! ( test -b \${disk}1 || test -b \${disk}p1 ); then - ceph-disk activate $disk || true +if [ $(echo /dev/sdc|cut -c 1) = '/' ]; then + disk=/dev/sdc +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev//dev/sdc fi -if test -f /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && ( test -b ${disk}1 || test -b ${disk}p1 ); then - ceph-disk activate ${disk}1 || true +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi +id=$(ceph-volume lvm list /dev/sdc | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +fsid=$(ceph-volume lvm list /dev/sdc | grep 'osd fsid'|awk -F 'osd fsid' '{print \$2}'|tr -d ' ') +ceph-volume lvm activate \$id \$fsid ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -ceph-disk list | egrep \" *((\${disk}1?|\${disk}p1?) .*ceph data, active|\\ -(\${disk}5?|\${disk}p5?) .*ceph lockbox, active, for (\${disk}1?|\${disk}p1?))\" || -ls -ld /var/lib/ceph/osd/ceph-* | grep \" $(readlink -f /dev/sdc)\$\" +id=$(ceph-volume lvm list /dev/sdc | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +ps -fCceph-osd|grep \"\\--id \$id \" ", 'logoutput' => true ) } end describe "with dmcrypt custom keydir" do let :title do '/dev/sdc' end let :params do { :dmcrypt => true, :dmcrypt_key_dir => '/srv/ceph/keys', } end - it { is_expected.to contain_exec('ceph-osd-check-udev-/dev/sdc').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements -# Before Infernalis the udev rules race causing the activation to fail so we -# disable them. More at: http://www.spinics.net/lists/ceph-devel/msg28436.html -mv -f /usr/lib/udev/rules.d/95-ceph-osd.rules /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && udevadm control --reload || true -", - 'onlyif' => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -DISABLE_UDEV=$(ceph --version | awk 'match(\$3, /[0-9]+\\.[0-9]+/) {if (substr(\$3, RSTART, RLENGTH) <= 0.94) {print 1} else { print 0 } }') -test -f /usr/lib/udev/rules.d/95-ceph-osd.rules && test \$DISABLE_UDEV -eq 1 -", - 'logoutput' => true, - ) } it { is_expected.to contain_exec('ceph-osd-prepare-/dev/sdc').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/sdc) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi + +if [ $(echo /dev/sdc|cut -c 1) = '/' ]; then + disk=/dev/sdc +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev//dev/sdc +fi +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi -ceph-disk prepare --cluster ceph --dmcrypt --dmcrypt-key-dir '/srv/ceph/keys' $(readlink -f /dev/sdc) $(readlink -f '') -udevadm settle +ceph-volume lvm prepare --cluster ceph --dmcrypt --dmcrypt-key-dir '/srv/ceph/keys' --data /dev/sdc ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/sdc) -ceph-disk list | egrep \" *((${disk}1?|${disk}p1?) .*ceph data, (prepared|active)|\\ -(${disk}5?|${disk}p5?) .*ceph lockbox, (prepared|active), for (${disk}1?|${disk}p1?))\" || -{ test -f $disk/fsid && test -f $disk/ceph_fsid && test -f $disk/magic ;} +ceph-volume lvm list /dev/sdc ", 'logoutput' => true ) } it { is_expected.to contain_exec('ceph-osd-activate-/dev/sdc').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/sdc) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi -fi -# activate happens via udev when using the entire device -if ! test -b \$disk && ! ( test -b \${disk}1 || test -b \${disk}p1 ); then - ceph-disk activate $disk || true +if [ $(echo /dev/sdc|cut -c 1) = '/' ]; then + disk=/dev/sdc +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev//dev/sdc fi -if test -f /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && ( test -b ${disk}1 || test -b ${disk}p1 ); then - ceph-disk activate ${disk}1 || true +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi +id=$(ceph-volume lvm list /dev/sdc | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +fsid=$(ceph-volume lvm list /dev/sdc | grep 'osd fsid'|awk -F 'osd fsid' '{print \$2}'|tr -d ' ') +ceph-volume lvm activate \$id \$fsid ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -ceph-disk list | egrep \" *((\${disk}1?|\${disk}p1?) .*ceph data, active|\\ -(\${disk}5?|\${disk}p5?) .*ceph lockbox, active, for (\${disk}1?|\${disk}p1?))\" || -ls -ld /var/lib/ceph/osd/ceph-* | grep \" $(readlink -f /dev/sdc)\$\" +id=$(ceph-volume lvm list /dev/sdc | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +ps -fCceph-osd|grep \"\\--id \$id \" ", 'logoutput' => true ) } end describe "with custom params" do let :title do - '/srv/data' + 'vg_test/lv_test' end let :params do { :cluster => 'testcluster', - :journal => '/srv/journal', + :journal => 'vg_test/lv_journal', :fsid => 'f39ace04-f967-4c3d-9fd2-32af2d2d2cd5', :store_type => 'filestore' } end - it { should contain_exec('ceph-osd-check-udev-/srv/data').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements -# Before Infernalis the udev rules race causing the activation to fail so we -# disable them. More at: http://www.spinics.net/lists/ceph-devel/msg28436.html -mv -f /usr/lib/udev/rules.d/95-ceph-osd.rules /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && udevadm control --reload || true -", - 'onlyif' => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -DISABLE_UDEV=$(ceph --version | awk 'match(\$3, /[0-9]+\\.[0-9]+/) {if (substr(\$3, RSTART, RLENGTH) <= 0.94) {print 1} else { print 0 } }') -test -f /usr/lib/udev/rules.d/95-ceph-osd.rules && test \$DISABLE_UDEV -eq 1 -", - 'logoutput' => true, - ) } - it { should contain_exec('ceph-osd-check-fsid-mismatch-/srv/data').with( + it { should contain_exec('ceph-osd-check-fsid-mismatch-vg_test/lv_test').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -test f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 = $(ceph-disk list $(readlink -f /srv/data) | egrep -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}') +exit 1 ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -test -z $(ceph-disk list $(readlink -f /srv/data) | egrep -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}') +if [ -z $(ceph-volume lvm list vg_test/lv_test |grep 'cluster fsid' | awk -F'fsid' '{print \$2}'|tr -d ' ') ]; then + exit 0 +fi +test f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 = $(ceph-volume lvm list vg_test/lv_test |grep 'cluster fsid' | awk -F'fsid' '{print \$2}'|tr -d ' ') ", 'logoutput' => true ) } - it { should contain_exec('ceph-osd-prepare-/srv/data').with( + it { should contain_exec('ceph-osd-prepare-vg_test/lv_test').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /srv/data) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi + +if [ $(echo vg_test/lv_test|cut -c 1) = '/' ]; then + disk=vg_test/lv_test +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev/vg_test/lv_test fi -ceph-disk prepare --filestore --cluster testcluster --cluster-uuid f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 $(readlink -f /srv/data) $(readlink -f /srv/journal) -udevadm settle +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 +fi +ceph-volume lvm prepare --filestore --cluster testcluster --cluster-fsid f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 --data vg_test/lv_test --journal vg_test/lv_journal ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /srv/data) -ceph-disk list | egrep \" *((${disk}1?|${disk}p1?) .*ceph data, (prepared|active)|\\ -(${disk}5?|${disk}p5?) .*ceph lockbox, (prepared|active), for (${disk}1?|${disk}p1?))\" || -{ test -f $disk/fsid && test -f $disk/ceph_fsid && test -f $disk/magic ;} +ceph-volume lvm list vg_test/lv_test ", 'logoutput' => true ) } - it { should contain_exec('ceph-osd-activate-/srv/data').with( + it { should contain_exec('ceph-osd-activate-vg_test/lv_test').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /srv/data) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi -fi -# activate happens via udev when using the entire device -if ! test -b \$disk && ! ( test -b \${disk}1 || test -b \${disk}p1 ); then - ceph-disk activate $disk || true +if [ $(echo vg_test/lv_test|cut -c 1) = '/' ]; then + disk=vg_test/lv_test +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev/vg_test/lv_test fi -if test -f /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && ( test -b ${disk}1 || test -b ${disk}p1 ); then - ceph-disk activate ${disk}1 || true +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi +id=$(ceph-volume lvm list vg_test/lv_test | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +fsid=$(ceph-volume lvm list vg_test/lv_test | grep 'osd fsid'|awk -F 'osd fsid' '{print \$2}'|tr -d ' ') +ceph-volume lvm activate \$id \$fsid ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -ceph-disk list | egrep \" *((\${disk}1?|\${disk}p1?) .*ceph data, active|\\ -(\${disk}5?|\${disk}p5?) .*ceph lockbox, active, for (\${disk}1?|\${disk}p1?))\" || -ls -ld /var/lib/ceph/osd/testcluster-* | grep \" $(readlink -f /srv/data)\$\" +id=$(ceph-volume lvm list vg_test/lv_test | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +ps -fCceph-osd|grep \"\\--id \$id \" ", 'logoutput' => true ) } end describe "with NVMe param" do let :title do '/dev/nvme0n1' end - it { should contain_exec('ceph-osd-check-udev-/dev/nvme0n1').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements -# Before Infernalis the udev rules race causing the activation to fail so we -# disable them. More at: http://www.spinics.net/lists/ceph-devel/msg28436.html -mv -f /usr/lib/udev/rules.d/95-ceph-osd.rules /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && udevadm control --reload || true -", - 'onlyif' => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -DISABLE_UDEV=$(ceph --version | awk 'match(\$3, /[0-9]+\\.[0-9]+/) {if (substr(\$3, RSTART, RLENGTH) <= 0.94) {print 1} else { print 0 } }') -test -f /usr/lib/udev/rules.d/95-ceph-osd.rules && test \$DISABLE_UDEV -eq 1 -", - 'logoutput' => true, - ) } it { should contain_exec('ceph-osd-prepare-/dev/nvme0n1').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/nvme0n1) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi + +if [ $(echo /dev/nvme0n1|cut -c 1) = '/' ]; then + disk=/dev/nvme0n1 +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev//dev/nvme0n1 fi -ceph-disk prepare --cluster ceph $(readlink -f /dev/nvme0n1) $(readlink -f '') -udevadm settle +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 +fi +ceph-volume lvm prepare --cluster ceph --data /dev/nvme0n1 ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/nvme0n1) -ceph-disk list | egrep \" *((${disk}1?|${disk}p1?) .*ceph data, (prepared|active)|\\ -(${disk}5?|${disk}p5?) .*ceph lockbox, (prepared|active), for (${disk}1?|${disk}p1?))\" || -{ test -f $disk/fsid && test -f $disk/ceph_fsid && test -f $disk/magic ;} +ceph-volume lvm list /dev/nvme0n1 ", 'logoutput' => true ) } it { should contain_exec('ceph-osd-activate-/dev/nvme0n1').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/nvme0n1) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi -fi -# activate happens via udev when using the entire device -if ! test -b \$disk && ! ( test -b \${disk}1 || test -b \${disk}p1 ); then - ceph-disk activate $disk || true +if [ $(echo /dev/nvme0n1|cut -c 1) = '/' ]; then + disk=/dev/nvme0n1 +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev//dev/nvme0n1 fi -if test -f /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && ( test -b ${disk}1 || test -b ${disk}p1 ); then - ceph-disk activate ${disk}1 || true +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi +id=$(ceph-volume lvm list /dev/nvme0n1 | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +fsid=$(ceph-volume lvm list /dev/nvme0n1 | grep 'osd fsid'|awk -F 'osd fsid' '{print \$2}'|tr -d ' ') +ceph-volume lvm activate \$id \$fsid ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -ceph-disk list | egrep \" *((\${disk}1?|\${disk}p1?) .*ceph data, active|\\ -(\${disk}5?|\${disk}p5?) .*ceph lockbox, active, for (\${disk}1?|\${disk}p1?))\" || -ls -ld /var/lib/ceph/osd/ceph-* | grep \" $(readlink -f /dev/nvme0n1)\$\" +id=$(ceph-volume lvm list /dev/nvme0n1 | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +ps -fCceph-osd|grep \"\\--id \$id \" ", 'logoutput' => true ) } end describe "with cciss param" do let :title do '/dev/cciss/c0d0' end - it { should contain_exec('ceph-osd-check-udev-/dev/cciss/c0d0').with( - 'command' => "/bin/true # comment to satisfy puppet syntax requirements -# Before Infernalis the udev rules race causing the activation to fail so we -# disable them. More at: http://www.spinics.net/lists/ceph-devel/msg28436.html -mv -f /usr/lib/udev/rules.d/95-ceph-osd.rules /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && udevadm control --reload || true -", - 'onlyif' => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -DISABLE_UDEV=$(ceph --version | awk 'match(\$3, /[0-9]+\\.[0-9]+/) {if (substr(\$3, RSTART, RLENGTH) <= 0.94) {print 1} else { print 0 } }') -test -f /usr/lib/udev/rules.d/95-ceph-osd.rules && test \$DISABLE_UDEV -eq 1 -", - 'logoutput' => true, - ) } it { should contain_exec('ceph-osd-prepare-/dev/cciss/c0d0').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/cciss/c0d0) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi + +if [ $(echo /dev/cciss/c0d0|cut -c 1) = '/' ]; then + disk=/dev/cciss/c0d0 +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev//dev/cciss/c0d0 fi -ceph-disk prepare --cluster ceph $(readlink -f /dev/cciss/c0d0) $(readlink -f '') -udevadm settle +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 +fi +ceph-volume lvm prepare --cluster ceph --data /dev/cciss/c0d0 ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/cciss/c0d0) -ceph-disk list | egrep \" *((${disk}1?|${disk}p1?) .*ceph data, (prepared|active)|\\ -(${disk}5?|${disk}p5?) .*ceph lockbox, (prepared|active), for (${disk}1?|${disk}p1?))\" || -{ test -f $disk/fsid && test -f $disk/ceph_fsid && test -f $disk/magic ;} +ceph-volume lvm list /dev/cciss/c0d0 ", 'logoutput' => true ) } it { should contain_exec('ceph-osd-activate-/dev/cciss/c0d0').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /dev/cciss/c0d0) -if ! test -b $disk ; then - echo $disk | egrep -e '^/dev' -q -v - mkdir -p $disk - if getent passwd ceph >/dev/null 2>&1; then - chown -h ceph:ceph $disk - fi -fi -# activate happens via udev when using the entire device -if ! test -b \$disk && ! ( test -b \${disk}1 || test -b \${disk}p1 ); then - ceph-disk activate $disk || true +if [ $(echo /dev/cciss/c0d0|cut -c 1) = '/' ]; then + disk=/dev/cciss/c0d0 +else + # If data is vg/lv, block device is /dev/vg/lv + disk=/dev//dev/cciss/c0d0 fi -if test -f /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && ( test -b ${disk}1 || test -b ${disk}p1 ); then - ceph-disk activate ${disk}1 || true +if ! test -b \$disk ; then + # Since nautilus, only block devices or lvm logical volumes can be used for OSDs + exit 1 fi +id=$(ceph-volume lvm list /dev/cciss/c0d0 | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +fsid=$(ceph-volume lvm list /dev/cciss/c0d0 | grep 'osd fsid'|awk -F 'osd fsid' '{print \$2}'|tr -d ' ') +ceph-volume lvm activate \$id \$fsid ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -ceph-disk list | egrep \" *((\${disk}1?|\${disk}p1?) .*ceph data, active|\\ -(\${disk}5?|\${disk}p5?) .*ceph lockbox, active, for (\${disk}1?|\${disk}p1?))\" || -ls -ld /var/lib/ceph/osd/ceph-* | grep \" $(readlink -f /dev/cciss/c0d0)\$\" +id=$(ceph-volume lvm list /dev/cciss/c0d0 | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') +ps -fCceph-osd|grep \"\\--id \$id \" ", 'logoutput' => true ) } end describe "with ensure absent" do let :title do - '/srv' + 'vg_test/lv_test' end let :params do { :ensure => 'absent', } end - it { should contain_exec('remove-osd-/srv').with( + it { should contain_exec('remove-osd-vg_test/lv_test').with( 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex -disk=$(readlink -f /srv) -if [ -z \"\$id\" ] ; then - id=$(ceph-disk list | sed -nEe \"s:^ *${disk}1? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\") -fi -if [ -z \"\$id\" ] ; then - id=$(ls -ld /var/lib/ceph/osd/ceph-* | sed -nEe \"s:.*/ceph-([0-9]+) *-> *${disk}\$:\\1:p\" || true) -fi +id=$(ceph-volume lvm list vg_test/lv_test | grep 'osd id'|awk -F 'osd id' '{print \$2}'|tr -d ' ') if [ \"\$id\" ] ; then + ceph --cluster ceph osd out osd.\$id stop ceph-osd cluster=ceph id=\$id || true service ceph stop osd.\$id || true - systemctl stop ceph-osd@$id || true + systemctl stop ceph-osd@\$id || true ceph --cluster ceph osd crush remove osd.\$id ceph --cluster ceph auth del osd.\$id ceph --cluster ceph osd rm \$id rm -fr /var/lib/ceph/osd/ceph-\$id/* umount /var/lib/ceph/osd/ceph-\$id || true rm -fr /var/lib/ceph/osd/ceph-\$id + ceph-volume lvm zap vg_test/lv_test fi ", 'unless' => "/bin/true # comment to satisfy puppet syntax requirements -set -ex -disk=$(readlink -f /srv) -if [ -z \"\$id\" ] ; then - id=$(ceph-disk list | sed -nEe \"s:^ *${disk}1? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\") -fi -if [ -z \"\$id\" ] ; then - id=$(ls -ld /var/lib/ceph/osd/ceph-* | sed -nEe \"s:.*/ceph-([0-9]+) *-> *${disk}\$:\\1:p\" || true) -fi -if [ \"\$id\" ] ; then - test ! -d /var/lib/ceph/osd/ceph-\$id +set -x +ceph-volume lvm list vg_test/lv_test +if [ \$? -eq 0 ]; then + exit 1 else - true # if there is no id we do nothing + exit 0 fi ", 'logoutput' => true ) } end describe "with ensure set to bad value" do let :title do '/srv' end let :params do { :ensure => 'badvalue', } end it { should raise_error(Puppet::Error, /Ensure on OSD must be either present or absent/) } end end on_supported_os({ :supported_os => OSDefaults.get_supported_os }).each do |os,facts| context "on #{os}" do let (:facts) do facts.merge!(OSDefaults.get_facts()) end it_behaves_like 'ceph osd' end end end