puppet-prod/modules/zfs/lib/facter/zfs_zpools.rb
Ben Vincent c2cb2f994d
All checks were successful
Build / precommit (pull_request) Successful in 3m34s
feat: add ZFS facts to prevent zpool disk changes
- add zfs_zpools and zfs_datasets facts to detect existing ZFS resources
- skip zpool creation when pools already exist
2025-10-18 21:13:32 +11:00

20 lines
506 B
Ruby

# frozen_string_literal: true
Facter.add(:zfs_zpools) do
confine kernel: 'Linux'
setcode do
zpools = []
if Facter::Core::Execution.which('zpool')
begin
output = Facter::Core::Execution.execute('zpool list -H -o name 2>/dev/null', on_fail: nil)
zpools = output.strip.split("\n") if output && !output.empty?
rescue StandardError => e
Facter.debug("Error getting zpool information: #{e.message}")
end
end
zpools.empty? ? nil : zpools
end
end