Skip to content

Commit

Permalink
add volume_group_map fact
Browse files Browse the repository at this point in the history
  • Loading branch information
rtib committed Jul 14, 2023
1 parent f05f0e0 commit 5ceaeee
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/facter/volume_group_map.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5ceaeee

Please sign in to comment.