Describe the Bug
The global section of haproxy-base.cfg.epp renders configuration parameters sorted alphabetically. This breaks HAProxy directives that require a specific ordering to take effect.
A concrete example: tune.lua.bool-sample-conversion must appear before any lua-load or lua-load-per-thread directive. Because l sorts before t, lua-load is always rendered first, causing HAProxy to silently ignore tune.lua.bool-sample-conversion with the following warning:
config : parsing [/etc/haproxy/haproxy.cfg:9] : ignored as some Lua was loaded already.
"tune.lua.bool-sample-conversion" must be set before any "lua-load" or
"lua-load-per-thread" directive for it to be considered.
This is a silent misconfiguration — HAProxy starts without error, but the tunable has no effect.
Expected Behavior
The module should either preserve the order in which parameters are supplied in the hash, or provide a mechanism to control ordering explicitly. Alphabetical sorting should not silently override HAProxy's own directive ordering requirements.
Steps to Reproduce
- Configure the
haproxy class with both tune.lua.bool-sample-conversion and lua-load in the global parameters hash
- Apply the Puppet catalog
- Inspect the rendered
/etc/haproxy/haproxy.cfg — lua-load appears before tune.lua.bool-sample-conversion due to alphabetical sorting
- Restart HAProxy and observe the warning in the logs
Workaround
Prepending a space to the key name forces it to sort before l:
{ ' tune.lua.bool-sample-conversion' => 'normal' },
{ 'lua-load' => '/etc/haproxy/lua/cors.lua' },
This is clearly unintended use of the API and fragile — it relies on ASCII sort order of whitespace preceding letters.
Suggested Fix
Make sorting optional. A sort_global_params parameter defaulting to true would preserve backward compatibility while allowing users to opt out when directive ordering matters:
class { 'haproxy':
sort_global_params => false,
global_options => {
'tune.lua.bool-sample-conversion' => 'normal',
'lua-load' => '/etc/haproxy/lua/cors.lua',
}
}
Alternatively, preserving insertion order by default (since Ruby hashes are ordered since 1.9) would be a simpler fix with no API change required.
Environment
- puppetlabs-haproxy version: 8.2.0
- HAProxy version: 3.2
- Platform: Ubuntu 24.04
- Puppet version: 8.x
Additional Context
The alphabetical sort is implemented in haproxy-base.cfg.epp line 2. Other HAProxy directives may have similar ordering requirements — this is not specific to Lua. The fix should be general rather than special-casing individual directives.
Describe the Bug
The
globalsection ofhaproxy-base.cfg.epprenders configuration parameters sorted alphabetically. This breaks HAProxy directives that require a specific ordering to take effect.A concrete example:
tune.lua.bool-sample-conversionmust appear before anylua-loadorlua-load-per-threaddirective. Becauselsorts beforet,lua-loadis always rendered first, causing HAProxy to silently ignoretune.lua.bool-sample-conversionwith the following warning:This is a silent misconfiguration — HAProxy starts without error, but the tunable has no effect.
Expected Behavior
The module should either preserve the order in which parameters are supplied in the hash, or provide a mechanism to control ordering explicitly. Alphabetical sorting should not silently override HAProxy's own directive ordering requirements.
Steps to Reproduce
haproxyclass with bothtune.lua.bool-sample-conversionandlua-loadin the global parameters hash/etc/haproxy/haproxy.cfg—lua-loadappears beforetune.lua.bool-sample-conversiondue to alphabetical sortingWorkaround
Prepending a space to the key name forces it to sort before
l:{ ' tune.lua.bool-sample-conversion' => 'normal' }, { 'lua-load' => '/etc/haproxy/lua/cors.lua' },This is clearly unintended use of the API and fragile — it relies on ASCII sort order of whitespace preceding letters.
Suggested Fix
Make sorting optional. A
sort_global_paramsparameter defaulting totruewould preserve backward compatibility while allowing users to opt out when directive ordering matters:Alternatively, preserving insertion order by default (since Ruby hashes are ordered since 1.9) would be a simpler fix with no API change required.
Environment
Additional Context
The alphabetical sort is implemented in
haproxy-base.cfg.eppline 2. Other HAProxy directives may have similar ordering requirements — this is not specific to Lua. The fix should be general rather than special-casing individual directives.