Skip to content

Commit

Permalink
Merge pull request #239 from ctiml/config_file
Browse files Browse the repository at this point in the history
(MODULES-3412) Use haproxy::config_file instead of default config_file
  • Loading branch information
hunner committed Jun 9, 2016
2 parents 2503853 + f497247 commit 81afceb
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manifests/backend.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
include ::haproxy::params
if $instance == 'haproxy' {
$instance_name = 'haproxy'
$config_file = $haproxy::params::config_file
$config_file = $haproxy::config_file
} else {
$instance_name = "haproxy-${instance}"
$config_file = inline_template($haproxy::params::config_file_tmpl)
Expand Down
2 changes: 1 addition & 1 deletion manifests/balancermember.pp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
include haproxy::params
if $instance == 'haproxy' {
$instance_name = 'haproxy'
$config_file = $haproxy::params::config_file
$config_file = $haproxy::config_file
} else {
$instance_name = "haproxy-${instance}"
$config_file = inline_template($haproxy::params::config_file_tmpl)
Expand Down
2 changes: 1 addition & 1 deletion manifests/frontend.pp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
include haproxy::params
if $instance == 'haproxy' {
$instance_name = 'haproxy'
$config_file = $haproxy::params::config_file
$config_file = $haproxy::config_file
} else {
$instance_name = "haproxy-${instance}"
$config_file = inline_template($haproxy::params::config_file_tmpl)
Expand Down
2 changes: 1 addition & 1 deletion manifests/listen.pp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
include haproxy::params
if $instance == 'haproxy' {
$instance_name = 'haproxy'
$config_file = $haproxy::params::config_file
$config_file = $haproxy::config_file
} else {
$instance_name = "haproxy-${instance}"
$config_file = inline_template($haproxy::params::config_file_tmpl)
Expand Down
2 changes: 1 addition & 1 deletion manifests/userlist.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
include haproxy::params
if $instance == 'haproxy' {
$instance_name = 'haproxy'
$config_file = $haproxy::params::config_file
$config_file = $haproxy::config_file
} else {
$instance_name = "haproxy-${instance}"
$config_file = inline_template($haproxy::params::config_file_tmpl)
Expand Down
17 changes: 17 additions & 0 deletions spec/defines/backend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,22 @@
end
end

context "when a non-default config file is used" do
let(:pre_condition) { 'class { "haproxy": config_file => "/etc/non-default.cfg" }' }
let(:title) { 'baz' }
let(:params) do
{
:options => {
'balance' => 'roundrobin',
},
}
end
it { should contain_concat__fragment('haproxy-baz_backend_block').with(
'order' => '20-baz-00',
'target' => '/etc/non-default.cfg',
'content' => "\nbackend baz\n balance roundrobin\n",
) }
end

# C9956 WONTFIX
end
17 changes: 17 additions & 0 deletions spec/defines/balancermember_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,21 @@
'content' => " server server01 192.168.56.200 check\n server server02 192.168.56.201 check\n"
) }
end
context "when a non-default config file is used" do
let(:pre_condition) { 'class { "haproxy": config_file => "/etc/non-default.cfg" }' }
let(:params) do
{
:name => 'haproxy',
:listening_service => 'baz',
:server_names => ['server01', 'server02'],
:ipaddresses => ['10.0.0.1', '10.0.0.2'],
:options => ['check']
}
end
it { should contain_concat__fragment('haproxy-baz_balancermember_haproxy').with(
'order' => '20-baz-01-haproxy',
'target' => '/etc/non-default.cfg',
'content' => " server server01 10.0.0.1 check\n server server02 10.0.0.2 check\n",
) }
end
end
22 changes: 22 additions & 0 deletions spec/defines/frontend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,27 @@
) }
end

context "when a non-default config file is used" do
let(:pre_condition) { 'class { "haproxy": config_file => "/etc/non-default.cfg" }' }
let(:params) do
{
:name => 'bar',
:bind => {
'*:5000' => [],
},
:options => {
'option' => [
'tcplog',
],
},
}
end
it { should contain_concat__fragment('haproxy-bar_frontend_block').with(
'order' => '15-bar-00',
'target' => '/etc/non-default.cfg',
'content' => "\nfrontend bar\n bind *:5000 \n option tcplog\n",
) }
end

# C9950 C9951 C9952 WONTFIX
end
23 changes: 23 additions & 0 deletions spec/defines/listen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,4 +347,27 @@
) }
end

context "when a non-default config file is used" do
let(:pre_condition) { 'class { "haproxy": config_file => "/etc/non-default.cfg" }' }
let(:params) do
{
:name => 'bar',
:bind => {
'*:5000' => [],
},
:options => {
'option' => [
'tcplog',
],
'balance' => 'roundrobin',
},
}
end
it { should contain_concat__fragment('haproxy-bar_listen_block').with(
'order' => '20-bar-00',
'target' => '/etc/non-default.cfg',
'content' => "\nlisten bar\n bind *:5000 \n balance roundrobin\n option tcplog\n",
) }
end

end
20 changes: 20 additions & 0 deletions spec/defines/userlist_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,24 @@
) }

end

context "when a non-default config file is used" do
let(:pre_condition) { 'class { "haproxy": config_file => "/etc/non-default.cfg" }' }
let(:params) do
{
:name => 'bar',
:users => [
'scott insecure-password elgato',
],
:groups => [
'superuser users scott',
],
}
end
it { should contain_concat__fragment('haproxy-bar_userlist_block').with(
'order' => '12-bar-00',
'target' => '/etc/non-default.cfg',
'content' => "\nuserlist bar\n group superuser users scott\n user scott insecure-password elgato\n",
) }
end
end

0 comments on commit 81afceb

Please sign in to comment.