mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Allow configuration to be defined in an ENV var
If `ENV['VMPOOLER_CONFIG']` is defined, it is read in as a YAML configuration. This allows vmpooler to run in a docker daemon via `docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler` rather than embedding a YAML file within the container.
This commit is contained in:
parent
c5aedc12cb
commit
efe21b27cd
1 changed files with 11 additions and 4 deletions
|
|
@ -21,11 +21,18 @@ module Vmpooler
|
|||
end
|
||||
|
||||
def self.config(filepath='vmpooler.yaml')
|
||||
# Load the configuration file
|
||||
parsed_config = {}
|
||||
|
||||
if ENV['VMPOOLER_CONFIG']
|
||||
# Load configuration from ENV
|
||||
parsed_config = YAML.load(ENV['VMPOOLER_CONFIG'])
|
||||
else
|
||||
# Load the configuration file from disk
|
||||
config_file = File.expand_path(filepath)
|
||||
parsed_config = YAML.load_file(config_file)
|
||||
end
|
||||
|
||||
# Set some defaults
|
||||
# Set some configuration defaults
|
||||
parsed_config[:redis] ||= {}
|
||||
parsed_config[:redis]['server'] ||= 'localhost'
|
||||
parsed_config[:redis]['data_ttl'] ||= 168
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue