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})
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
# 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
|
||||
@@ -0,0 +1,20 @@
|
||||
# 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
|
||||
@@ -0,0 +1,35 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'facter'
|
||||
require 'yaml'
|
||||
|
||||
Facter.add('minio_pool_dns') do
|
||||
setcode do
|
||||
yaml_file_path = '/opt/puppetlabs/facter/facts.d/minio_facts.yaml'
|
||||
|
||||
# check if the YAML file exists
|
||||
next {} unless File.exist?(yaml_file_path)
|
||||
|
||||
# load data from YAML
|
||||
data = YAML.load_file(yaml_file_path)
|
||||
minio_members = data['minio_members']
|
||||
minio_region = data['minio_region']
|
||||
minio_pool = data['minio_pool']
|
||||
domain = Facter.value(:networking)['domain']
|
||||
|
||||
# create result hash
|
||||
result = {}
|
||||
|
||||
# Check CNAME for each node_id from 1 to minio_members
|
||||
(1..minio_members).each do |node_id|
|
||||
cname_target = "#{minio_region}-#{minio_pool}-#{node_id}.#{domain}"
|
||||
command = "host #{cname_target} > /dev/null 2>&1"
|
||||
|
||||
# Using system method to execute the command
|
||||
# It returns true if the command gives exit status 0 (success), otherwise false
|
||||
result[cname_target] = system(command)
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user