From 83545b90e05cdaee7b7bf74cf4f4d2200e4536ab Mon Sep 17 00:00:00 2001 From: Reinhard Vicinus Date: Thu, 20 Jun 2024 17:39:16 +0200 Subject: [PATCH 1/3] fix sort_options_alphabetic parameter --- manifests/backend.pp | 2 +- manifests/defaults.pp | 2 +- manifests/frontend.pp | 2 +- manifests/resolver.pp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/backend.pp b/manifests/backend.pp index 79ec0587..4225b295 100644 --- a/manifests/backend.pp +++ b/manifests/backend.pp @@ -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, diff --git a/manifests/defaults.pp b/manifests/defaults.pp index a3bb838c..9731c795 100644 --- a/manifests/defaults.pp +++ b/manifests/defaults.pp @@ -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', ) { diff --git a/manifests/frontend.pp b/manifests/frontend.pp index 89a43754..dfe49ffb 100644 --- a/manifests/frontend.pp +++ b/manifests/frontend.pp @@ -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, diff --git a/manifests/resolver.pp b/manifests/resolver.pp index 330005b9..f193c803 100644 --- a/manifests/resolver.pp +++ b/manifests/resolver.pp @@ -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, From c0863db2d91624120688c7b224e296a7d6279606 Mon Sep 17 00:00:00 2001 From: Reinhard Vicinus Date: Thu, 20 Jun 2024 17:49:25 +0200 Subject: [PATCH 2/3] fix sort_options_alphabetic --- manifests/listen.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/listen.pp b/manifests/listen.pp index 6866476d..f1c774c7 100644 --- a/manifests/listen.pp +++ b/manifests/listen.pp @@ -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, From 4ccd23e5073ad5ea50d162c119214b36cf5b93e3 Mon Sep 17 00:00:00 2001 From: Reinhard Vicinus Date: Fri, 21 Jun 2024 11:42:35 +0200 Subject: [PATCH 3/3] added spec test for sort_options_alphabetic disabled globally --- spec/defines/listen_spec.rb | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/spec/defines/listen_spec.rb b/spec/defines/listen_spec.rb index 04dcdcab..5c339e2f 100644 --- a/spec/defines/listen_spec.rb +++ b/spec/defines/listen_spec.rb @@ -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