From 5ceaeee654f9473f23f411b373247bad4fbfaabe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20R=C3=A9p=C3=A1si?= Date: Fri, 14 Jul 2023 16:51:03 +0200 Subject: [PATCH] add volume_group_map fact --- lib/facter/volume_group_map.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/facter/volume_group_map.rb diff --git a/lib/facter/volume_group_map.rb b/lib/facter/volume_group_map.rb new file mode 100644 index 00000000..a26ac6fe --- /dev/null +++ b/lib/facter/volume_group_map.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +Facter.add(:volume_group_map) do + # Fact should be confined to only linux servers that have the lvs command + confine do + Facter.value('kernel') == 'Linux' && + Facter::Core::Execution.which('vgs') + end + + setcode do + Facter.value(:volume_groups).keys.to_h do |vg| + [ + vg, + Facter::Core::Execution.exec("vgs -o pv_name #{vg} --noheading --nosuffix") + .split("\n") + .map { |x| x.strip } + .join(',') + ] + end + end +end