Example Recipe with LVM is failing on compute flavor servers
Closed this issue · 2 comments
StarryShark commented
Hi there, I am using example but it is failing with following error,
================================================================================
Error executing action `create` on resource 'lvm_volume_group[vg_data0]'
================================================================================
LVM::External::ExternalFailure
------------------------------
Fatal error, `/sbin/lvm vgcreate vg_data0 /dev/vda /dev/xvdb` returned 5 with 'Device /dev/vda not found (or ignored by filtering).
Unable to add physical volume '/dev/vda' to volume group 'vg_data0'.'
I think node[:rackspacecloud][:cbs][:attached_volumes] is producing all the attached block storage volumes. In compute or memory flavor servers it means OS volume as well. How can I get the device for volume created and attached by :create_and_attach
action only?
martinb3 commented
Hi there -- I don't think there's going to be an easy way to get that information back. You'd probably want to re-run ohai and let it find the new volumes, then filter out the one you know is the OS one (these are usually consistent in naming, so excluding /dev/vda should be enough).
martinb3 commented
Perhaps something like this:
include_recipe 'rackspacecloud'
include_recipe 'lvm'
rackspace = data_bag_item("rackspace", "cloud")
rackspace_username = rackspace["rackspace_username"]
rackspace_api_key = rackspace["rackspace_api_key"]
(1..2).each do |vol_number|
rackspacecloud_cbs "#{node[:hostname]}-#{vol_number}" do
type "SATA"
size 100
rackspace_username rackspace_username
rackspace_api_key rackspace_api_key
rackspace_region "#{node[:rackspace][:cloud][:region]}"
action :create_and_attach
end
end
#use lazy attribute evaluation to get attachment data at execution time
lvm_volume_group 'vg00' do
not_if {node[:rackspacecloud][:cbs][:attached_volumes].empty? }
physical_volumes lazy {node[:rackspacecloud][:cbs][:attached_volumes].collect do |attachment|
next if attachment["device"] == '/dev/sda'
attachment["device"]
end}
logical_volume 'blockstorage' do
size '100%VG'
filesystem 'ext4'
mount_point '/var/log'
end
end