All checks were successful
Build / precommit (pull_request) Successful in 3m34s
- add zfs_zpools and zfs_datasets facts to detect existing ZFS resources - skip zpool creation when pools already exist
20 lines
518 B
Ruby
20 lines
518 B
Ruby
# frozen_string_literal: true
|
|
|
|
Facter.add(:zfs_datasets) do
|
|
confine kernel: 'Linux'
|
|
setcode do
|
|
datasets = []
|
|
|
|
if Facter::Core::Execution.which('zfs')
|
|
begin
|
|
output = Facter::Core::Execution.execute('zfs list -H -o name 2>/dev/null', on_fail: nil)
|
|
datasets = output.strip.split("\n") if output && !output.empty?
|
|
rescue StandardError => e
|
|
Facter.debug("Error getting zfs dataset information: #{e.message}")
|
|
end
|
|
end
|
|
|
|
datasets.empty? ? nil : datasets
|
|
end
|
|
end
|