diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2022-12-17 21:59:58 +0100 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2022-12-21 17:19:46 +0100 |
commit | 8ce56f15e0751870b56805010241dcfe8389b10f (patch) | |
tree | 5cb2c136ea8d829c93810d908e63501ff79afd6e /roles/relayd | |
parent | 783cfa8469c7922f787305e15e95c0619479744b (diff) | |
download | rules-8ce56f15e0751870b56805010241dcfe8389b10f.tar.gz |
refactor: remove global __services from roles
Diffstat (limited to 'roles/relayd')
-rw-r--r-- | roles/relayd/defaults/main.yml | 2 | ||||
-rw-r--r-- | roles/relayd/templates/relayd.conf.j2 | 20 |
2 files changed, 12 insertions, 10 deletions
diff --git a/roles/relayd/defaults/main.yml b/roles/relayd/defaults/main.yml index 7171f53..66eef3b 100644 --- a/roles/relayd/defaults/main.yml +++ b/roles/relayd/defaults/main.yml @@ -1,5 +1,7 @@ --- +relayd_rules: {} + relayd_configuration_file: /etc/relayd.conf relayd_domain_name: example.com relayd_transparent: true 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 <local> { 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 <local> {% 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 <local> {% 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 <local> 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 %} } |