puppet-prod/site/profiles/lib/facter/minio_user_exists.rb
Ben Vincent d8751ac6c8 feat: add minio profile
- add additional modules in Puppetfile
- update puppetlabs-lvm to 2.1.0
- add facts.d base path to hieradata
- add infra/storage and infra/storage/minio role data to hieradata
- add new facts for minio setup status
- add a static yaml minio-facts file to assist dynamic ruby facts
- updated hiera with additional directories (country/{role,region})
2024-01-05 21:44:41 +11:00

21 lines
474 B
Ruby

# frozen_string_literal: true
# check that the minio user exists
require 'yaml'
Facter.add('minio_user_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)
user_name = minio_facts['minio_user']
user_exists = system("id #{user_name} >/dev/null 2>&1")
user_exists
end
end