class Subspace::Configuration
Attributes
group_config[R]
host_config[R]
project_name[RW]
vars[R]
Public Class Methods
new()
click to toggle source
# File lib/subspace/configuration.rb, line 6 def initialize @host_config = {} @group_config = {} @vars = OpenStruct.new end
Public Instance Methods
binding_for(host: nil, group: nil)
click to toggle source
I think a better way to do this is possibly to just write out all the host vars directly to a yaml file That provides more flexibility, although this method provides a whitelist.
# File lib/subspace/configuration.rb, line 43 def binding_for(host: nil, group: nil) config = @vars.dup if host @host_config[host].each do |k,v| config[k] = v end end b = binding b.local_variable_set(:config, config) b end
group(name, hosts: [], vars: {})
click to toggle source
# File lib/subspace/configuration.rb, line 24 def group(name, hosts: [], vars: {}) group_config(name).hosts += hosts group_config(name).vars.merge!(vars) end
groups()
click to toggle source
# File lib/subspace/configuration.rb, line 20 def groups @group_config.keys end
host(name, options)
click to toggle source
# File lib/subspace/configuration.rb, line 12 def host(name, options) @host_config[name] = options end
hosts()
click to toggle source
# File lib/subspace/configuration.rb, line 16 def hosts @host_config.keys end
role(name, groups: [], vars: {})
click to toggle source
# File lib/subspace/configuration.rb, line 29 def role(name, groups: [], vars: {}) groups.each do |group| group_config(group).roles.push(name.to_sym) vars.each do |k,v| if group_config(group).vars[k] put "Warning, variable '#{k}' already set for group '#{group}'" end group_config(group).vars[k] = v end end end