diff --git a/manifests/osd.pp b/manifests/osd.pp index 0c110db9..41114e9f 100644 --- a/manifests/osd.pp +++ b/manifests/osd.pp @@ -73,12 +73,52 @@ define ceph::osd ( $ceph_check_udev = "ceph-osd-check-udev-${name}" $ceph_prepare = "ceph-osd-prepare-${name}" $ceph_activate = "ceph-osd-activate-${name}" + $ceph_zap_osd = "ceph-osd-zap-${name}" Package<| tag == 'ceph' |> -> Exec[$ceph_check_udev] + Exec[$ceph_zap_osd] -> Exec[$ceph_check_udev] Ceph_config<||> -> Exec[$ceph_prepare] Ceph::Mon<||> -> Exec[$ceph_prepare] Ceph::Key<||> -> Exec[$ceph_prepare] + if $journal { + $ceph_zap_journal = "ceph-osd-zap-${name}-${journal}" + Exec[$ceph_zap_osd] -> Exec[$ceph_zap_journal] + Exec[$ceph_zap_journal] -> Exec[$ceph_check_udev] + exec { $ceph_zap_journal: + command => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +if [ -b ${journal} ]; then + ceph-disk zap ${journal} +fi +", + unless => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +! test -b ${journal} || +test $(parted -ms ${journal} p 2>&1 | egrep -c 'Error.*unrecognised disk label') -eq 0 +", + logoutput => true, + timeout => $exec_timeout, + } + } + + exec { $ceph_zap_osd: + command => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +if [ -b ${data} ]; then + ceph-disk zap ${data} +fi +", + unless => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +! test -b ${data} || +test $(parted -ms ${data} p 2>&1 | egrep -c 'Error.*unrecognised disk label') -eq 0 +", + logoutput => true, + timeout => $exec_timeout, + } + + $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 diff --git a/spec/defines/ceph_osd_spec.rb b/spec/defines/ceph_osd_spec.rb index 211f8315..b41ba79b 100644 --- a/spec/defines/ceph_osd_spec.rb +++ b/spec/defines/ceph_osd_spec.rb @@ -29,6 +29,20 @@ describe 'ceph::osd' do '/srv' end + it { is_expected.to contain_exec('ceph-osd-zap-/srv').with( + 'command' => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +if [ -b /srv ]; then + ceph-disk zap /srv +fi +", + 'unless' => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +! test -b /srv || +test $(parted -ms /srv p 2>&1 | egrep -c 'Error.*unrecognised disk label') -eq 0 +", + 'logoutput' => true, + ) } it { is_expected.to 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 @@ -100,6 +114,34 @@ ls -ld /var/lib/ceph/osd/ceph-* | grep ' /srv\$' } end + it { is_expected.to contain_exec('ceph-osd-zap-/srv/data').with( + 'command' => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +if [ -b /srv/data ]; then + ceph-disk zap /srv/data +fi +", + 'unless' => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +! test -b /srv/data || +test $(parted -ms /srv/data p 2>&1 | egrep -c 'Error.*unrecognised disk label') -eq 0 +", + 'logoutput' => true, + ) } + it { is_expected.to contain_exec('ceph-osd-zap-/srv/data-/srv/journal').with( + 'command' => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +if [ -b /srv/journal ]; then + ceph-disk zap /srv/journal +fi +", + 'unless' => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +! test -b /srv/journal || +test $(parted -ms /srv/journal p 2>&1 | egrep -c 'Error.*unrecognised disk label') -eq 0 +", + 'logoutput' => true, + ) } it { is_expected.to 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