Merge "Refactor direct_networks to not call Hiera directly"
This commit is contained in:
commit
8f4dd7d184
|
@ -1,8 +1,3 @@
|
||||||
require 'rubygems'
|
|
||||||
require 'json'
|
|
||||||
require 'hiera'
|
|
||||||
require 'ipaddr'
|
|
||||||
|
|
||||||
Puppet::Parser::Functions::newfunction(:direct_networks, :type => :rvalue, :doc => <<-EOS
|
Puppet::Parser::Functions::newfunction(:direct_networks, :type => :rvalue, :doc => <<-EOS
|
||||||
parses network scheme and returns networks
|
parses network scheme and returns networks
|
||||||
directly attached to the host
|
directly attached to the host
|
||||||
|
@ -10,16 +5,14 @@ Puppet::Parser::Functions::newfunction(:direct_networks, :type => :rvalue, :doc
|
||||||
) do |argv|
|
) do |argv|
|
||||||
|
|
||||||
endpoints = argv[0]
|
endpoints = argv[0]
|
||||||
|
networks = []
|
||||||
|
|
||||||
ENV['LANG'] = 'C'
|
endpoints.each{ |k,v|
|
||||||
$hiera = Hiera.new(:config => '/etc/hiera.yaml')
|
if v.has_key?('IP') and v['IP'].is_a?(Array)
|
||||||
|
v['IP'].each { |ip|
|
||||||
endpoints = $hiera.lookup('network_scheme', false, {})[endpoints]
|
networks << IPAddr.new(ip).to_s + "/" + ip.split('/')[1]
|
||||||
|
}
|
||||||
ip = []
|
end
|
||||||
endpoints.each do |x,y|
|
}
|
||||||
ip.push(y['IP'].join(' ')) if y.is_a?(Hash) and y.has_key?('IP') and y['IP'] != 'none'
|
return networks.join(' ')
|
||||||
end
|
|
||||||
|
|
||||||
return ip.map! { |a| IPAddr.new(a).to_s + "/" + a.split('/')[1]}.join(' ')
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
notice('MODULAR: cluster-haproxy.pp')
|
notice('MODULAR: cluster-haproxy.pp')
|
||||||
|
|
||||||
|
$network_scheme = hiera('network_scheme', {})
|
||||||
|
|
||||||
class { 'cluster::haproxy':
|
class { 'cluster::haproxy':
|
||||||
haproxy_maxconn => '16000',
|
haproxy_maxconn => '16000',
|
||||||
haproxy_bufsize => '32768',
|
haproxy_bufsize => '32768',
|
||||||
primary_controller => hiera('primary_controller'),
|
primary_controller => hiera('primary_controller'),
|
||||||
debug => hiera('debug', false),
|
debug => hiera('debug', false),
|
||||||
other_networks => direct_networks('endpoints'),
|
other_networks => direct_networks($network_scheme['endpoints']),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue