aboutsummaryrefslogtreecommitdiffstats
path: root/roles/pf/templates/pf.conf.j2
blob: 42b0bea2b6fbd5ead9247e3c06471188d6774001 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

{# pf ~~ templates/pf.conf.j2 #}
# pf ~~ /etc/pf.conf

# *
# common config. by Ansible
# *

set block-policy drop
set loginterface egress
set skip on { lo tun0 }

block all

{% for service in services %}
pass in quick on egress proto {{ service["proto"] }} to port {{ service["port"] }}
{% endfor %}

# redirection
{% for h in groups["all"] %}
{% set h = hostvars[h] %}
{##}
{% if h.services is defined %}
{% for service in h.services if h.ansible_host != "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 %}

# *
# sub-config. by Ansible
# *

{% if hypervisor is defined and vms is defined %}
# hypervisor network passthrough
{% for i in range(vms | length + 5) %}
set skip on tap{{ i }}
{% endfor %}
{% endif %}

{% include "templates/" + inventory_hostname + "/etc/pf.conf.j2" ignore missing %}

# *
# out. interface by Ansible 
# *

pass out quick inet
pass in proto { icmp, icmp6 } all

remember that computers suck.