Class: Puppetserver::Ca::Config::PuppetServer
- Inherits:
-
Object
- Object
- Puppetserver::Ca::Config::PuppetServer
- Defined in:
- lib/puppetserver/ca/config/puppetserver.rb
Overview
Provides an interface for querying Puppetserver settings w/o loading Puppetserver or any TK config service. Uses the ruby-hocon gem for parsing.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(supplied_config_path = nil) ⇒ PuppetServer
constructor
A new instance of PuppetServer.
-
#load ⇒ Object
Populate this config object with the CA-related settings.
Constructor Details
#initialize(supplied_config_path = nil) ⇒ PuppetServer
Returns a new instance of PuppetServer.
20 21 22 23 24 25 26 |
# File 'lib/puppetserver/ca/config/puppetserver.rb', line 20 def initialize(supplied_config_path = nil) @using_default_location = !supplied_config_path @config_path = supplied_config_path || "/etc/puppetlabs/puppetserver/conf.d/ca.conf" @settings = nil @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
18 19 20 |
# File 'lib/puppetserver/ca/config/puppetserver.rb', line 18 def errors @errors end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
18 19 20 |
# File 'lib/puppetserver/ca/config/puppetserver.rb', line 18 def settings @settings end |
Class Method Details
.parse(config_path = nil) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/puppetserver/ca/config/puppetserver.rb', line 11 def self.parse(config_path = nil) instance = new(config_path) instance.load return instance end |
Instance Method Details
#load ⇒ Object
Populate this config object with the CA-related settings
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puppetserver/ca/config/puppetserver.rb', line 29 def load if explicitly_given_config_file_or_default_config_exists? begin results = Hocon.load(@config_path) rescue Hocon::ConfigError => e errors << e. end end overrides = results || {} @settings = supply_defaults(overrides).freeze end |