- From: Booker Bense <
>
- To:
- Subject: [chef] Re: Re: Re: Re: testing for mounted fs, and trying shell_out
- Date: Wed, 26 Sep 2012 09:52:14 -0700
On Tue, Sep 25, 2012 at 3:18 PM, Booker Bense
<
>
wrote:
>
>
Why not just open /proc/mounts and read it?
>
>
Shelling out of ruby code to run a grep pipe seems overly complicated
>
and fragile.
>
if node['ecs']
mnt = Array.new
File.open '/proc/mounts' do |io|
mnt = io.grep(/\/ebs.*md[1-9]/ )
end
if ( mnt.empty?)
# Fail
else
# Create awesome
end
end
If you can write your shell_out in a few lines of Ruby, it is almost
always faster, simpler and more robust. It is very easy to generate a
false positive error return from a shell command. Because what you're
actually testing is the execution of the shell, not the actual result.
"The Ruby Way" is an excellent source of recipes for doing basic shell stuff.
- Booker C. Bense
Archive powered by MHonArc 2.6.16.