Puppet filters

16 views
Skip to first unread message

Nir Fishler

unread,
Dec 18, 2022, 2:44:17 AM12/18/22
to Puppet Users
Hey Guys,

I'm trying to pull data from an array using the 'mountpoints' facter

$root_partition = $mountpoints.filter |$values| { $values[0] =~ "/$" }

the results I get are:

Notice: {/ => {device => /dev/mapper/ubuntu--vg-ubuntu--lv, filesystem => ext4, options => [rw, relatime], size_bytes => 262901354496, available_bytes => 240302788608, used_bytes => 11734274048, capacity => 4.66%, size => 244.85 GiB, available => 223.80 GiB, used => 10.93 GiB}}
Notice: /Stage[main]/Disk_usage/Notify[{/ => {device => /dev/mapper/ubuntu--vg-ubuntu--lv, filesystem => ext4, options => [rw, relatime], size_bytes => 262901354496, available_bytes => 240302788608, used_bytes => 11734274048, capacity => 4.66%, size => 244.85 GiB, available => 223.80 GiB, used => 10.93 GiB}}]/message: defined 'message' as '{/ => {device => /dev/mapper/ubuntu--vg-ubuntu--lv, filesystem => ext4, options => [rw, relatime], size_bytes => 262901354496, available_bytes => 240302788608, used_bytes => 11734274048, capacity => 4.66%, size => 244.85 GiB, available => 223.80 GiB, used => 10.93 GiB}}'

What I need is the get the 'capacity' value out of it.


Thanks!
Nir.

Martin Alfke

unread,
Dec 18, 2022, 3:35:59 AM12/18/22
to puppet...@googlegroups.com
Hi Nir,

do you only need the capacity from the root file system?

You can access the data hash directly: $facts['mountpoints']['/']['capacity']

hth,
Martin
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/a3de8dab-287c-40da-be6c-c8036bba38c5n%40googlegroups.com.

Nir Fishler

unread,
Dec 18, 2022, 3:52:26 AM12/18/22
to Puppet Users
Perfect!

Thanks Martin.

Reply all
Reply to author
Forward
0 new messages