Update repo structure as part of nixification

This commit is contained in:
Gene Liverman 2023-09-14 00:01:31 -04:00
parent 49e67c64fb
commit cc0efcfdde
56 changed files with 181 additions and 154 deletions

View file

@ -0,0 +1,23 @@
# frozen_string_literal: true
Facter.add(:os_release) do
confine kernel: 'Linux'
setcode do
file_path = '/etc/os-release'
if File.exist?(file_path)
os_release_hash = {}
File.open(file_path, 'r') do |file|
file.each_line do |line|
next if line.nil? || line.strip.length.eql?(0)
line_data = line.split('=')
key = line_data[0].downcase
value = line_data[1].strip.gsub(/(^")|("$)/, '')
os_release_hash[key] = value
end
end
os_release_hash
end
end
end

View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
Puppet::Functions.create_function(:find_group) do
dispatch :find_group do
param 'String', :some_path
return_type 'String'
end
def find_group(some_path)
File.stat(some_path).gid.to_s
end
end

View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
Puppet::Functions.create_function(:find_owner) do
dispatch :find_owner do
param 'String', :some_path
return_type 'String'
end
def find_owner(some_path)
File.stat(some_path).uid.to_s
end
end

View file

@ -0,0 +1,12 @@
# frozen_string_literal: true
Puppet::Functions.create_function(:homedir_to_user) do
dispatch :homedir_to_user do
param 'String', :some_path
return_type 'String'
end
def homedir_to_user(some_path)
some_path.split('/')[-1]
end
end