Skip to content

Commit 5ceaeee

Browse files
committed
add volume_group_map fact
1 parent f05f0e0 commit 5ceaeee

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/facter/volume_group_map.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
Facter.add(:volume_group_map) do
4+
# Fact should be confined to only linux servers that have the lvs command
5+
confine do
6+
Facter.value('kernel') == 'Linux' &&
7+
Facter::Core::Execution.which('vgs')
8+
end
9+
10+
setcode do
11+
Facter.value(:volume_groups).keys.to_h do |vg|
12+
[
13+
vg,
14+
Facter::Core::Execution.exec("vgs -o pv_name #{vg} --noheading --nosuffix")
15+
.split("\n")
16+
.map { |x| x.strip }
17+
.join(',')
18+
]
19+
end
20+
end
21+
end

0 commit comments

Comments
 (0)