Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for issue #587: "haproxy::globals::sort_options_alphabetic: false" not effective #613

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifests/backend.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
String $instance = 'haproxy',
String[1] $section_name = $name,
Boolean $sort_options_alphabetic = true,
Optional[Boolean] $sort_options_alphabetic = undef,
Optional[String] $description = undef,
Optional[String] $defaults = undef,
Optional[Stdlib::Absolutepath] $config_file = undef,
Expand Down
2 changes: 1 addition & 1 deletion manifests/defaults.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#
define haproxy::defaults (
Hash $options = {},
Boolean $sort_options_alphabetic = true,
Optional[Boolean] $sort_options_alphabetic = undef,
Boolean $merge_options = $haproxy::params::merge_options,
String $instance = 'haproxy',
) {
Expand Down
2 changes: 1 addition & 1 deletion manifests/frontend.pp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
},
String $instance = 'haproxy',
String[1] $section_name = $name,
Boolean $sort_options_alphabetic = true,
Optional[Boolean] $sort_options_alphabetic = undef,
Optional[String] $description = undef,
Optional[String] $defaults = undef,
Boolean $defaults_use_backend = true,
Expand Down
2 changes: 1 addition & 1 deletion manifests/listen.pp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
},
String $instance = 'haproxy',
String[1] $section_name = $name,
Boolean $sort_options_alphabetic = true,
Optional[Boolean] $sort_options_alphabetic = undef,
Optional[String] $description = undef,
Optional[String] $defaults = undef,
Optional[Stdlib::Absolutepath] $config_file = undef,
Expand Down
2 changes: 1 addition & 1 deletion manifests/resolver.pp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
Optional[Integer[512, 8192]] $accepted_payload_size = undef,
String $instance = 'haproxy',
String[1] $section_name = $name,
Boolean $sort_options_alphabetic = true,
Optional[Boolean] $sort_options_alphabetic = undef,
Boolean $collect_exported = true,
Optional[Stdlib::Absolutepath] $config_file = undef,
Optional[String] $defaults = undef,
Expand Down
41 changes: 41 additions & 0 deletions spec/defines/listen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,47 @@
}
end

context 'when listen options are specified with global sort_options_alphabetic disabled' do
let(:pre_condition) do
<<-PUPPET
include haproxy
class { 'haproxy::globals':
sort_options_alphabetic => false,
}
PUPPET
end

let(:params) do
{
name: 'apache',
bind: {
'0.0.0.0:48001-48003' => []
},
mode: 'http',
options: {
'reqadd' => 'X-Forwarded-Proto:\ https',
'reqidel' => '^X-Forwarded-For:.*',
'default_backend' => 'dev00_webapp',
'capture request header' => ['X-Forwarded-For len 50', 'Host len 15', 'Referrer len 15'],
'acl' => ['dst_dev01 dst_port 48001', 'dst_dev02 dst_port 48002', 'dst_dev03 dst_port 48003'],
'use_backend' => ['dev01_webapp if dst_dev01', 'dev02_webapp if dst_dev02', 'dev03_webapp if dst_dev03'],
'option' => ['httpchk', 'httplog', 'http-server-close', 'forwardfor except 127.0.0.1'],
'compression' => 'algo gzip',
'bind-process' => 'all',
'http-check' => ['send hdr Host test.example.com meth GET uri /health', 'expect status 204']
}
}
end

it {
is_expected.to contain_concat__fragment('haproxy-apache_listen_block').with(
'order' => '20-apache-00',
'target' => '/etc/haproxy/haproxy.cfg',
'content' => "\nlisten apache\n bind 0.0.0.0:48001-48003 \n mode http\n acl dst_dev01 dst_port 48001\n acl dst_dev02 dst_port 48002\n acl dst_dev03 dst_port 48003\n bind-process all\n capture request header X-Forwarded-For len 50\n capture request header Host len 15\n capture request header Referrer len 15\n compression algo gzip\n reqidel ^X-Forwarded-For:.*\n reqadd X-Forwarded-Proto:\\ https\n use_backend dev01_webapp if dst_dev01\n use_backend dev02_webapp if dst_dev02\n use_backend dev03_webapp if dst_dev03\n default_backend dev00_webapp\n option httpchk\n option httplog\n option http-server-close\n option forwardfor except 127.0.0.1\n http-check send hdr Host test.example.com meth GET uri /health\n http-check expect status 204\n", # rubocop:disable Layout/LineLength
)
}
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
Expand Down
Loading