puppet-prod/modules/facts/lib/facter/minio_group_exists.rb
Ben Vincent 1f7b347ef4 refacter: tidy facts
- create a facts module, move all facts to this module
2024-02-17 22:57:36 +11:00

21 lines
491 B
Ruby

# frozen_string_literal: true
# check that the minio group exists
require 'yaml'
Facter.add('minio_group_exists') 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)
group_name = minio_facts['minio_group']
group_exists = system("getent group #{group_name} >/dev/null 2>&1")
group_exists
end
end