From 83c079eb80e91e710307a11e63eaeffe3d6b9f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Sat, 17 Apr 2021 19:18:51 +0200 Subject: pf: Use macros --- roles/pf/templates/pf.conf.j2 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'roles/pf') diff --git a/roles/pf/templates/pf.conf.j2 b/roles/pf/templates/pf.conf.j2 index 0d2429f..154098e 100644 --- a/roles/pf/templates/pf.conf.j2 +++ b/roles/pf/templates/pf.conf.j2 @@ -1,5 +1,5 @@ +{% import 'macros.j2' as macros with context %} -{# pf ~~ templates/pf.conf.j2 #} # pf ~~ /etc/pf.conf # managed by Ansible @@ -15,16 +15,13 @@ pass in quick on egress proto {{ service["proto"] }} to port {{ service["port"] {% endfor %} # redirection -{% for h in groups["all"] %} -{% set h = hostvars[h] %} -{##} +{% call(h) macros.loop_valid_hosts("servers") %} {% if h.services is defined %} {% for service in h.services if h.ansible_host != global.dcontroller and service.public is defined and service.public %} pass in on egress proto {{ service.proto }} from any to any port {{ service.port }} rdr-to {{ h.ip.in }} {% endfor %} {% endif %} -{##} -{% endfor %} +{% endcall %} {# {% if hypervisor is defined and vms is defined %} @@ -42,4 +39,3 @@ pass out quick on egress inet from (tun0:network) nat-to (egress:0) # output network pass out quick inet pass in proto { icmp, icmp6 } all - -- cgit v1.2.3