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.
21 22 23 24 25 26 27 |
# File 'lib/puppetserver/ca/config/puppetserver.rb', line 21 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.
19 20 21 |
# File 'lib/puppetserver/ca/config/puppetserver.rb', line 19 def errors @errors end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
19 20 21 |
# File 'lib/puppetserver/ca/config/puppetserver.rb', line 19 def settings @settings end |
Class Method Details
.parse(config_path = nil) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/puppetserver/ca/config/puppetserver.rb', line 12 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
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/puppetserver/ca/config/puppetserver.rb', line 30 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 |