Ok. so i’ve written a set of code that does the following:
- if file system doesnt exist, create /u01 file system with 200G.
- loop through filesystems looking for /u01 and validate there is 100g available.
But i am being bitten by convergence doing step 2, before step 1 happens.
The code does not find /u01.
I am struggling how to get around this with using the chef execute statement.
what i need is for the execute statement to loop through the ohai file systems
and find /u01 and check if space exists?
Here is my original code (simplified for the sake of this discourse):
FS=’/u01’
execute “make_FS_#{FS}” do
user 'root’
group node[:root_group]
command "/usr/sbin/crfs -v jfs2 -dlvl01 #{FS}"
not_if "lsfs | fgrep #{FS} > /dev/null 2>&1"
end
mount “#{FS}” do
device 'lvl01’
options 'rw’
action [:mount, :enable]
end
Validate enough space in file sytem exists for install:
targetsize=100 # in gigabytes.
ruby_block “check if avaialble space on file system /u01” do
block do
found=false
node[‘filesystem’].each do |dev,properties|
fsize=properties[‘kb_available’]
# ohai returns size in 512 byte blocks.
# so to turn into gigs, need to convert.
#
meg=1024*1024*2
availInGigs = fsize.to_i / meg
fsnam=properties['mount']
if ( FS == fsnam )
found=true
if ( targetsize > availInGigs )
raise "Not enough space in filesystem: #{FS}"
end
end
end
if ( found != true )
raise "filesystem: #{FS} is NOT FOUND"
end
end
end