From 96a9b003ad31a49a24eea0f3709333dc27ae9610 Mon Sep 17 00:00:00 2001 From: Arne Teuke Date: Tue, 28 Jan 2025 16:32:55 +0100 Subject: [PATCH] edit proxy --- manifests/server/proxy.pp | 44 +++++++++++++++++------------ templates/haproxy_backend_rule.erb | 5 ++-- templates/haproxy_frontend_rule.erb | 10 ++++--- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/manifests/server/proxy.pp b/manifests/server/proxy.pp index 3abbe1a..6ed8439 100644 --- a/manifests/server/proxy.pp +++ b/manifests/server/proxy.pp @@ -40,27 +40,35 @@ ############################################################################### define cd_haproxy::server::proxy ( -$haproxy_fqdn = undef, -$frontend_name = undef, -$frontend_mode = undef, -$fe_use_backend = '', -$fe_bind_mode = undef, -$frontend_order = '010', -$acl_rule_front = '', -$acl_rule_back = '', -$backend_name = undef, -$backend_order = '030', -$fe_maxconn = '', -$be_server_name = undef, -$be_balance = '', -$be_mode = '', + $haproxy_fqdn = undef, + $frontend_name = undef, + $frontend_mode = undef, + $fe_use_backend = '', + $fe_bind_mode = undef, + $frontend_order = '010', + $acl_rule_front = '', + $acl_rule_back = '', + $backend_name = undef, + $backend_order = '030', + $fe_maxconn = '', + $be_server_name = undef, + $be_balance = '', + $be_mode = '', ) { -$hy_main_config = '/etc/haproxy/haproxy.cfg' -$hy_frontendrule = 'cd_haproxy/haproxy_frontend_rule.erb' -$hy_backendrule = 'cd_haproxy/haproxy_backend_rule.erb' -$hy_acl_rule = 'cd_haproxy/haproxy_acl_rule.erb' + $hy_main_config = '/etc/haproxy/haproxy.cfg' + $hy_frontendrule = 'cd_haproxy/haproxy_frontend_rule.erb' + $hy_backendrule = 'cd_haproxy/haproxy_backend_rule.erb' + $hy_acl_rule = 'cd_haproxy/haproxy_acl_rule.erb' + + + # Ensure acl_rule_front and acl_rule_back are arrays + $acl_rule_front_array = Array($acl_rule_front) + $acl_rule_back_array = Array($acl_rule_back) + + # Ensure fe_use_backend are arrays + $fe_use_backend_array = Array($fe_use_backend) # create frontend section concat::fragment { "frontend_${name}": diff --git a/templates/haproxy_backend_rule.erb b/templates/haproxy_backend_rule.erb index f7ed8d7..f1a4a82 100644 --- a/templates/haproxy_backend_rule.erb +++ b/templates/haproxy_backend_rule.erb @@ -3,8 +3,9 @@ backend <%= @backend_name %> <% if @be_mode != '' -%> mode <%= @be_mode %> <% end -%> -<% if @acl_rule_back != '' -%> -acl <%= @acl_rule_back %> +<% if !@acl_rule_back_array.empty? -%> +<% @acl_rule_back_array.each do |acl_rule| -%> +acl <%= acl_rule %> <% end -%> <% if @be_balance != '' -%> balance <%= @be_balance %> diff --git a/templates/haproxy_frontend_rule.erb b/templates/haproxy_frontend_rule.erb index 95ee885..496bf0f 100644 --- a/templates/haproxy_frontend_rule.erb +++ b/templates/haproxy_frontend_rule.erb @@ -5,11 +5,13 @@ bind <%= @fe_bind_mode %> <% if @fe_maxconn != '' -%> maxconn <%= @fe_maxconn %> <% end -%> -<% if @acl_rule_front != '' -%> -acl <%= @acl_rule_front %> +<% if !@acl_rule_front_array.empty? -%> +<% @acl_rule_front_array.each do |acl_rule| -%> +acl <%= acl_rule %> <% end -%> -<% if @fe_use_backend != '' -%> -use_backend <%= @fe_use_backend %> +<% if !@fe_use_backend_array_array.empty? -%> +<% @fe_use_backend_array_array_array.each do |fe_use_backend| -%> +use_backend <%= fe_use_backend %> <% else -%> use_backend <%= @backend_name %>