feat: moved enc_role and enc_env to ruby facts

This commit is contained in:
2024-04-24 23:30:27 +10:00
parent df05be21f6
commit e0dbecbfa0
4 changed files with 48 additions and 9 deletions
+13
View File
@@ -0,0 +1,13 @@
# frozen_string_literal: true
Facter.add('enc_env') do
setcode do
require 'yaml'
# Check if the YAML file exists
if File.exist?('/root/.cache/custom_facts.yaml')
data = YAML.load_file('/root/.cache/custom_facts.yaml')
# Use safe navigation to return 'enc_env' or nil
data&.dig('enc_env')
end
end
end
+13
View File
@@ -0,0 +1,13 @@
# frozen_string_literal: true
Facter.add('enc_role') do
setcode do
require 'yaml'
# Check if the YAML file exists
if File.exist?('/root/.cache/custom_facts.yaml')
data = YAML.load_file('/root/.cache/custom_facts.yaml')
# Use safe navigation to return 'enc_role' or nil
data&.dig('enc_role')
end
end
end