[chef] Re: Re: Re: Re: testing for mounted fs, and trying shell_out


Chronological Thread 
  • From: Booker Bense < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: testing for mounted fs, and trying shell_out
  • Date: Tue, 25 Sep 2012 15:18:10 -0700

On Tue, Sep 25, 2012 at 3:10 PM, Brasic, Carl 
< >
 wrote:
> On Tue, Sep 25, 2012 at 4:43 PM, 
> < >
>  wrote:
>> cool... so my approach to the task using shell_out and begin/rescue is
>> sane, if not good?
>
> Seems like you're expecting shell_out to raise an exception if  the
> grep command doesn't find the mount.  That's not how shell_out works,
> so your rescue block will never run.
> Instead you should be checking #exitstatus:
>
>   if node['ec2']
>     ebs_mounted = shell_out("grep /ebs /proc/mounts 2>&1 | grep -q
> md[1-9]").exitstatus.zero?
>   end
>


Why not just open /proc/mounts and read it?

Shelling out of ruby code to run a grep pipe seems overly complicated
and fragile.

Google for "ruby recipe check for string in file"

- Booker C. Bense



Archive powered by MHonArc 2.6.16.

§