Make haproxy stats listen on lo and mgmt VIP
This commit makes haproxy stats service listen only on loopback and management VIP Change-Id: Ifc6d6f3a3031bebeff8d96cf0ed0ae4923ef2b67 Closes-bug: #1465271
This commit is contained in:
parent
7e10ed56bc
commit
de59f299a9
@ -9,6 +9,7 @@ class cluster::haproxy (
|
|||||||
$primary_controller = false,
|
$primary_controller = false,
|
||||||
$debug = false,
|
$debug = false,
|
||||||
$other_networks = false,
|
$other_networks = false,
|
||||||
|
$stats_ipaddresses = ['127.0.0.1']
|
||||||
) {
|
) {
|
||||||
include ::concat::setup
|
include ::concat::setup
|
||||||
include ::haproxy::params
|
include ::haproxy::params
|
||||||
@ -54,6 +55,7 @@ class cluster::haproxy (
|
|||||||
class { 'haproxy::base':
|
class { 'haproxy::base':
|
||||||
global_options => $global_options,
|
global_options => $global_options,
|
||||||
defaults_options => $defaults_options,
|
defaults_options => $defaults_options,
|
||||||
|
stats_ipaddresses => $stats_ipaddresses,
|
||||||
use_include => true,
|
use_include => true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ group :development, :test do
|
|||||||
gem 'rspec-system-puppet', :require => false
|
gem 'rspec-system-puppet', :require => false
|
||||||
gem 'rspec-system-serverspec', :require => false
|
gem 'rspec-system-serverspec', :require => false
|
||||||
gem 'serverspec', :require => false
|
gem 'serverspec', :require => false
|
||||||
gem 'puppet-lint', :require => false
|
|
||||||
gem 'pry', :require => false
|
gem 'pry', :require => false
|
||||||
gem 'simplecov', :require => false
|
gem 'simplecov', :require => false
|
||||||
end
|
end
|
||||||
|
@ -28,6 +28,7 @@ class haproxy::base (
|
|||||||
$use_include = $haproxy::params::use_include,
|
$use_include = $haproxy::params::use_include,
|
||||||
$use_stats = $haproxy::params::use_stats,
|
$use_stats = $haproxy::params::use_stats,
|
||||||
$stats_port = $haproxy::params::stats_port,
|
$stats_port = $haproxy::params::stats_port,
|
||||||
|
$stats_ipaddresses = $haproxy::params::stats_ipaddresses
|
||||||
) inherits haproxy::params {
|
) inherits haproxy::params {
|
||||||
include concat::setup
|
include concat::setup
|
||||||
|
|
||||||
|
@ -68,4 +68,5 @@ class haproxy::params {
|
|||||||
}
|
}
|
||||||
$use_stats = true
|
$use_stats = true
|
||||||
$stats_port = '10000'
|
$stats_port = '10000'
|
||||||
|
$stats_ipaddresses = ['127.0.0.1']
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
|
|
||||||
listen Stats *:<%= @stats_port %>
|
listen Stats
|
||||||
|
<% Array(@stats_ipaddresses).uniq.each do |ip| -%>
|
||||||
|
bind <%= ip %>:<%= @stats_port %>
|
||||||
|
<% end -%>
|
||||||
mode http
|
mode http
|
||||||
stats enable
|
stats enable
|
||||||
stats uri /
|
stats uri /
|
||||||
|
@ -8,4 +8,5 @@ class { 'cluster::haproxy':
|
|||||||
primary_controller => hiera('primary_controller'),
|
primary_controller => hiera('primary_controller'),
|
||||||
debug => hiera('debug', false),
|
debug => hiera('debug', false),
|
||||||
other_networks => direct_networks($network_scheme['endpoints']),
|
other_networks => direct_networks($network_scheme['endpoints']),
|
||||||
|
stats_ipaddresses => [hiera('management_vip'),'127.0.0.1']
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ describe manifest do
|
|||||||
|
|
||||||
networks = []
|
networks = []
|
||||||
endpoints = Noop.hiera_structure 'network_scheme/endpoints'
|
endpoints = Noop.hiera_structure 'network_scheme/endpoints'
|
||||||
|
management_vip = Noop.hiera 'management_vip'
|
||||||
endpoints.each{ |k,v|
|
endpoints.each{ |k,v|
|
||||||
if v['IP'].is_a?(Array)
|
if v['IP'].is_a?(Array)
|
||||||
v['IP'].each { |ip|
|
v['IP'].each { |ip|
|
||||||
@ -25,6 +26,14 @@ describe manifest do
|
|||||||
'other_networks' => networks.join(' '),
|
'other_networks' => networks.join(' '),
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
it "should contain stats fragment and listen only on lo and #{management_vip}" do
|
||||||
|
should contain_concat__fragment('haproxy-stats').with_content(
|
||||||
|
%r{\n\s*bind\s+127\.0\.0\.1:10000\s*$\n}
|
||||||
|
)
|
||||||
|
should contain_concat__fragment('haproxy-stats').with_content(
|
||||||
|
%r{\n\s*bind\s+#{management_vip}:10000\s*\n}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user