Class: Caco::SettingsLoader
- Inherits:
-
Trailblazer::Operation
- Object
- Trailblazer::Operation
- Caco::SettingsLoader
- Defined in:
- lib/caco/settings_loader.rb
Instance Method Summary collapse
- #config_load(ctx, facts:, data_path:) ⇒ Object
- #config_setup(ctx) ⇒ Object
- #custom_config(ctx) ⇒ Object
- #facter_needed_values(ctx) ⇒ Object
- #hiera_setup_keys(ctx, keys_path:) ⇒ Object
- #set_caco_eyaml_parser(ctx, parser:) ⇒ Object
- #setup_validate_params(ctx, keys_path: nil, data_path: nil) ⇒ Object
Instance Method Details
#config_load(ctx, facts:, data_path:) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/caco/settings_loader.rb', line 48 def config_load(ctx, facts:, data_path:, **) # From more generic to specific Config.load_and_set_settings( data_path.join("common.yaml"), data_path.join("os", "#{facts[:facter_os_name]}.yaml"), data_path.join("os", "#{facts[:facter_os_name]}", "#{facts[:facter_distro_codename]}.yaml"), # maybe add some organizations here? # maybe add some roles here? data_path.join("nodes", "#{facts[:facter_fqdn]}"), ) Settings.reload! end |
#config_setup(ctx) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/caco/settings_loader.rb', line 18 def config_setup(ctx, **) Config.setup do |config| config.const_name = 'Settings' config.use_env = true end end |
#custom_config(ctx) ⇒ Object
61 62 63 64 65 |
# File 'lib/caco/settings_loader.rb', line 61 def custom_config(ctx, **) Settings.prometheus = Config::Options.new Settings.prometheus.root = "/opt/prometheus" Settings.prometheus.config_root = "/etc/prometheus" end |
#facter_needed_values(ctx) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/caco/settings_loader.rb', line 37 def facter_needed_values(ctx, **) ctx[:facts] = {} ctx[:facts][:facter_kernel] = Caco::Facter.("kernel") ctx[:facts][:facter_os_name] = Caco::Facter.("os", "name") ctx[:facts][:facter_distro_codename] = (ctx[:facts][:facter_kernel] == "Linux" ? Caco::Facter.("os", "distro", "codename") : nil) ctx[:facts][:facter_release_full] = Caco::Facter.("os", "release", "full") ctx[:facts][:facter_release_major] = Caco::Facter.("os", "release", "major") ctx[:facts][:facter_release_minor] = Caco::Facter.("os", "release", "minor") ctx[:facts][:facter_fqdn] = Caco::Facter.("networking", "fqdn") end |
#hiera_setup_keys(ctx, keys_path:) ⇒ Object
25 26 27 28 29 |
# File 'lib/caco/settings_loader.rb', line 25 def hiera_setup_keys(ctx, keys_path:, **) Hiera::Backend::Eyaml::Options[:pkcs7_public_key] = keys_path.join("public_key.pkcs7.pem") Hiera::Backend::Eyaml::Options[:pkcs7_private_key] = keys_path.join("private_key.pkcs7.pem") ctx[:parser] = Hiera::Backend::Eyaml::Parser::ParserFactory.encrypted_parser end |
#set_caco_eyaml_parser(ctx, parser:) ⇒ Object
31 32 33 34 35 |
# File 'lib/caco/settings_loader.rb', line 31 def set_caco_eyaml_parser(ctx, parser:, **) Caco.configure do |config| config.eyaml_parser = parser end end |
#setup_validate_params(ctx, keys_path: nil, data_path: nil) ⇒ Object
13 14 15 16 |
# File 'lib/caco/settings_loader.rb', line 13 def setup_validate_params(ctx, keys_path: nil, data_path: nil, **) ctx[:keys_path] = !keys_path.nil? ? Pathname.new(keys_path) : Pathname.new(Caco.root.join("keys")) ctx[:data_path] = !data_path.nil? ? Pathname.new(data_path) : Pathname.new(Caco.root.join("data")) end |