Re: [Puppet Users] Question on searching for and using data inside a structured fact

2017-11-08 Thread R.I.Pienaar
nothing wrong with keys() but...

function uuid_for_partition($needle) {
  $uuid = $facts["partitions"].reduce() |$memo, $partition| {
$partition[1]["mount"] ? {
  $needle => $partition[0],
  default => $memo
}
  }
}

notice(uuid_for_partition("/boot"))


On Thu, Nov 9, 2017, at 00:54, Sean wrote:
> Hi,
> 
> I have been attempting (and failing miserably) at trying to obtain the
> UUID 
> of a partition mounted in a specific directory from the partitions fact.  
> I'm using puppet 4.10.8.
> 
> As an example, let's say I'm looking for the UUID of /boot on my
> systems...
> 
> $ facter partitions
> {"sda1"=>{"size"=>"1048576", "mount"=>"/boot/efi"}, 
> "sda2"=>{"uuid"=>"14528e73-61cc-4503-b24f-47c3b6e2aee2",
> "size"=>"1048576", 
> "mount"=>"/boot"},
> "sda3"=>{"uuid"=>"c0f0fa3e-b389-4814-ae8b-dec3b14816fb", 
> "size"=>"974673920"}}
> 
> I can successfully use the filter function to find the sda2 hash in
> puppet:
> 
> $x = $facts['partitions'].filter |$p,$d| { $d['mount' == '/boot' }
> $k = keys($x)
> $u = $x[k[0]]['uuid']
> notify { "$u": }
> 
> 
> This produces the desired resulting data, a string with the UUID, but it 
> requires using puppetlabs-stdlib's keys function.  So, is there a way to 
> accomplish this with native puppet alone?
> 
> Thanks you kindly.
> 
> -- 
> 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/fa9679ba-72a4-4ba2-8cbf-a1695cdefa8a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


-- 
R.I.Pienaar / www.devco.net / @ripienaar

-- 
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/1510213415.3457730.118944.2FE14A60%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Question on searching for and using data inside a structured fact

2017-11-08 Thread Sean
Hi,

I have been attempting (and failing miserably) at trying to obtain the UUID 
of a partition mounted in a specific directory from the partitions fact.  
I'm using puppet 4.10.8.

As an example, let's say I'm looking for the UUID of /boot on my systems...

$ facter partitions
{"sda1"=>{"size"=>"1048576", "mount"=>"/boot/efi"}, 
"sda2"=>{"uuid"=>"14528e73-61cc-4503-b24f-47c3b6e2aee2", "size"=>"1048576", 
"mount"=>"/boot"}, "sda3"=>{"uuid"=>"c0f0fa3e-b389-4814-ae8b-dec3b14816fb", 
"size"=>"974673920"}}

I can successfully use the filter function to find the sda2 hash in puppet:

$x = $facts['partitions'].filter |$p,$d| { $d['mount' == '/boot' }
$k = keys($x)
$u = $x[k[0]]['uuid']
notify { "$u": }


This produces the desired resulting data, a string with the UUID, but it 
requires using puppetlabs-stdlib's keys function.  So, is there a way to 
accomplish this with native puppet alone?

Thanks you kindly.

-- 
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/fa9679ba-72a4-4ba2-8cbf-a1695cdefa8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.