From 8ce56f15e0751870b56805010241dcfe8389b10f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Sat, 17 Dec 2022 21:59:58 +0100 Subject: refactor: remove global __services from roles --- roles/relayd/templates/relayd.conf.j2 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'roles/relayd/templates') diff --git a/roles/relayd/templates/relayd.conf.j2 b/roles/relayd/templates/relayd.conf.j2 index c97e9da..b66ffa7 100644 --- a/roles/relayd/templates/relayd.conf.j2 +++ b/roles/relayd/templates/relayd.conf.j2 @@ -8,8 +8,8 @@ log connection errors table { 127.0.0.1 } {% call(h) macros.loop_valid_hosts("servers") -%} table <{{ h.inventory_hostname }}> { {{ h.__ip.internal }} } -{% for service in h.__services if service.domain is defined %} -table <{{ h.inventory_hostname }}_{{ service.domain }}> { {{ h.__ip.internal }} } +{% for name, rules in h.relayd_rules.items() if rules.domain is defined %} +table <{{ h.inventory_hostname }}_{{ rules.domain }}> { {{ h.__ip.internal }} } {% endfor %} {%- endcall %} @@ -34,10 +34,10 @@ http protocol "https" { tls keypair "{{ relayd_domain_name }}" pass request quick header "Host" value "{{ relayd_domain_name }}" forward to {% call(h) macros.loop_valid_hosts("servers") -%} -{% for service in h.__services if service.domain is defined %} - {% set domain_name = service.domain ~ "." ~ relayd_domain_name -%} +{% for name, rules in h.relayd_rules.items() if rules.domain is defined %} + {% set domain_name = rules.domain ~ "." ~ relayd_domain_name -%} tls keypair "{{ domain_name }}" - pass request quick header "Host" value "{{ domain_name }}" forward to <{{ h.inventory_hostname }}_{{ service.domain }}> + pass request quick header "Host" value "{{ domain_name }}" forward to <{{ h.inventory_hostname }}_{{ rules.domain }}> {% endfor %} {%- endcall %} @@ -52,9 +52,9 @@ http protocol "http" { pass request quick header "Host" value "{{ relayd_domain_name }}" forward to {% call(h) macros.loop_valid_hosts("servers") -%} -{% for service in h.__services if service.domain is defined %} - {% set domain_name = service.domain ~ "." ~ relayd_domain_name -%} - pass request quick header "Host" value "{{ domain_name }}" forward to <{{ h.inventory_hostname }}_{{ service.domain }}> +{% for name, rules in h.relayd_rules.items() if rules.domain is defined %} + {% set domain_name = rules.domain ~ "." ~ relayd_domain_name -%} + pass request quick header "Host" value "{{ domain_name }}" forward to <{{ h.inventory_hostname }}_{{ rules.domain }}> {% endfor %} {%- endcall %} @@ -75,8 +75,8 @@ relay "wwwtls" { protocol "https" forward to port 80 check http "/" code 200 {% call(h) macros.loop_valid_hosts("servers") -%} -{% for service in h.__services if service.domain is defined %} - forward to <{{ h.inventory_hostname }}_{{ service.domain }}> port {{ service.port }} check tcp +{% for name, rules in h.relayd_rules.items() if rules.domain is defined %} + forward to <{{ h.inventory_hostname }}_{{ rules.domain }}> port {{ rules.port }} check tcp {% endfor %} {%- endcall %} } -- cgit v1.2.3