ansible/roles/nftables/templates/nftables.conf.j2

54 lines
1.4 KiB
Plaintext
Raw Normal View History

2024-04-14 22:46:42 +00:00
{% set combined_defines = [ nftables_builtin_defines, nftables_defines ] | combine %}
{% set combined_sets = [ nftables_builtin_sets, nftables_sets ] | combine %}
{% set combined_input_rules = [ nftables_input_builtin_rules, nftables_input_rules ] | combine %}
{% set combined_forward_rules = [ nftables_forward_builtin_rules, nftables_forward_rules ] | combine %}
{% set combined_output_rules = [ nftables_output_builtin_rules, nftables_output_rules ] | combine %}
2022-09-04 13:59:28 +00:00
table inet filter {
2024-04-14 22:46:42 +00:00
{% for name, cfg in combined_defines.items() %}
{% if cfg is string or cfg is number %}
2022-09-04 13:59:28 +00:00
define {{ name }} = {{ cfg }}
2024-04-14 22:46:42 +00:00
{% elif cfg is sequence %}
2022-09-04 13:59:28 +00:00
define {{ name }} = {
2024-04-14 22:46:42 +00:00
{% for elem in cfg %}
2022-09-04 13:59:28 +00:00
{{ elem }},
{% endfor %}
}
2024-04-14 22:46:42 +00:00
{% endif %}
{% endfor %}
2022-09-04 13:59:28 +00:00
2024-04-14 22:46:42 +00:00
{% for name, cfg in combined_sets.items() %}
2022-09-04 13:59:28 +00:00
set {{ name }} {
2024-04-14 22:46:42 +00:00
{% for elem in cfg %}
2022-09-04 13:59:28 +00:00
{{ elem }}
{% endfor %}
}
2024-04-14 22:46:42 +00:00
{% endfor %}
2022-09-04 13:59:28 +00:00
chain input {
2024-04-14 22:46:42 +00:00
{% for comment, rules in combined_input_rules.items() %}
# {{ comment }}
{% for rule in rules %}
2022-09-04 13:59:28 +00:00
{{ rule }}
{% endfor %}
2024-04-14 22:46:42 +00:00
{% endfor %}
2022-09-04 13:59:28 +00:00
}
chain forward {
2024-04-14 22:46:42 +00:00
{% for comment, rules in combined_forward_rules.items() %}
# {{ comment }}
{% for rule in rules %}
2022-09-04 13:59:28 +00:00
{{ rule }}
{% endfor %}
2024-04-14 22:46:42 +00:00
{% endfor %}
2022-09-04 13:59:28 +00:00
}
chain output {
2024-04-14 22:46:42 +00:00
{% for comment, rules in combined_output_rules.items() %}
# {{ comment }}
{% for rule in rules %}
2022-09-04 13:59:28 +00:00
{{ rule }}
{% endfor %}
2024-04-14 22:46:42 +00:00
{% endfor %}
2022-09-04 13:59:28 +00:00
}
}