27 lines
718 B
Ruby
27 lines
718 B
Ruby
# frozen_string_literal: true
|
|
|
|
# check all datadirs for minio are initialised
|
|
|
|
require 'yaml'
|
|
Facter.add('minio_datadirs_initialised') do
|
|
setcode do
|
|
yaml_file_path = '/opt/puppetlabs/facter/facts.d/minio_facts.yaml'
|
|
|
|
# check if the YAML file exists first
|
|
next false unless File.exist?(yaml_file_path)
|
|
|
|
minio_facts = YAML.load_file(yaml_file_path)
|
|
dev_count = minio_facts['minio_blockdev_count']
|
|
datadir = minio_facts['minio_datadir']
|
|
|
|
# check datadir if no blockdevices are used, otherwise check the store locations
|
|
if dev_count.zero?
|
|
Dir.exist?(datadir)
|
|
else
|
|
(1..dev_count).all? do |number|
|
|
Dir.exist?("#{datadir}/store#{number}")
|
|
end
|
|
end
|
|
end
|
|
end
|