On Wednesday, March 18, 2015 at 8:45:58 PM UTC-5, Hiu wrote:
>
> hi all,
>
> I am wondering if I would like to retrieve the mount points values from 
> the facter. From the facter -p, I can see that I do have the information. 
> e.g.
>
> partitions => {
> "sda1"=>{
> "mount"=>"/boot", 
> "uuid"=>"4e5014d1-080a-4182-aa89-bc83159b85fb", 
> "filesystem"=>"ext4", 
> "size"=>"614400"}, 
> "sda2"=>{
> "mount"=>"/", 
> "uuid"=>"edbab169-7983-4e38-9c71-24f0f88cccaa", 
> "filesystem"=>"ext4", 
> "size"=>"18257920"}, 
> "sda3"=>{
> "uuid"=>"b9674244-6686-49b0-b778-91052d78767f", 
> "filesystem"=>"swap", 
> "size"=>"2097152"}
> }
>
> And $mount is the one that I am looking for. Question: how can i loop 
> through the $partitions data structure and harvest $mount and detect if 
> there is a mount point call "/data". thanks!
>


It can be done.  Your best bet is probably a custom function or an inline 
template, either one of which can be used to process your data with 
arbitrary Ruby code.  Exactly how that would look depends a lot on what you 
want to do with the data, and in what form you want to receive the result.  
If all you want to know is whether there is any *x* for which $::partitions[
*x*]['mount'] == '/data', then it might look like this:

$has_data_partition = inline_template("<%= (! @partitions.select { | fs, 
opts | '/data' == opts['mount'] }.empty? ).to_s %>")
if $has_data_partition == 'true' {
  # ...
} else {
  # ...
}


John



-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/08abe585-e621-4823-bf4f-01218d92b8f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to