Explicit conditional with ensure statement

The ensure conditional allowed any value other than present
to ensure absent an osd. If the user had mistakenly put the
value at 'presen' or 'presentt' it would remove the OSD.
The conditional has been update prevents any value other than
either present or absent from being acceptable.

Change-Id: I7440544518ae5f830a76c2ae222d8b8610b0c97d
This commit is contained in:
Matthew J. Black 2016-07-11 18:35:09 -04:00
parent 6ac269c841
commit adcce43d26
5 changed files with 42 additions and 3 deletions

View File

@ -230,7 +230,7 @@ test ! -e ${keyring_path}
}
}
} else {
} elsif $ensure == absent {
service { $mon_service:
ensure => stopped
}
@ -253,5 +253,7 @@ test ! -d \$mon_data
ceph_config {
"mon.${id}/public_addr": ensure => absent;
} -> Package<| tag == 'ceph' |>
} else {
fail('Ensure on MON must be either present or absent')
}
}

View File

@ -131,7 +131,7 @@ ls -ld /var/lib/ceph/osd/${cluster_name}-* | grep ' ${data}\$'
logoutput => true,
}
} else {
} elsif $ensure == absent {
# ceph-disk: support osd removal http://tracker.ceph.com/issues/7454
exec { "remove-osd-${name}":
@ -172,6 +172,7 @@ fi
logoutput => true,
timeout => $exec_timeout,
} -> Ceph::Mon<| ensure == absent |>
} else {
fail('Ensure on OSD must be either present or absent')
}
}

View File

@ -0,0 +1,6 @@
---
issues:
- OSD define ensure statement has been updated to require either an explicit absent for OSD to be removed.
- MON define ensure statement has been updated to require either an explicit absent for MON to be removed.
- If ensure is set to any value other than present or absent, it will generate an error message for both
OSD and MON resources.

View File

@ -714,6 +714,21 @@ test ! -d \$mon_data
",
'logoutput' => true) }
end
describe "with ensure set with bad value" do
let :title do
'A'
end
let :params do
{
:ensure => 'badvalue',
}
end
it { is_expected.to raise_error(Puppet::Error, /Ensure on MON must be either present or absent/) }
end
end
end

View File

@ -206,6 +206,21 @@ fi
'logoutput' => true
) }
end
describe "with ensure set to bad value" do
let :title do
'/srv'
end
let :params do
{
:ensure => 'badvalue',
}
end
it { is_expected.to raise_error(Puppet::Error, /Ensure on OSD must be either present or absent/) }
end
end
context 'Debian Family' do