2020-11-10 21:17:11 +01:00
|
|
|
#jinja2: lstrip_blocks: "True", trim_blocks: "True"
|
2017-08-07 13:48:54 +02:00
|
|
|
#!/usr/sbin/nft -f
|
|
|
|
# {{ ansible_managed }}
|
2017-08-07 17:07:35 +02:00
|
|
|
{% set globalmerged = nft_global_default_rules.copy() %}
|
2018-08-06 15:09:20 +02:00
|
|
|
{% set _ = globalmerged.update(nft_global_rules) %}
|
2017-08-07 17:07:35 +02:00
|
|
|
{% set _ = globalmerged.update(nft_global_group_rules) %}
|
2020-12-30 17:12:50 +01:00
|
|
|
{% if nft_merged_groups and hostvars[inventory_hostname]['nft_combined_rules'].nft_global_group_rules is defined%}
|
2020-11-10 21:17:11 +01:00
|
|
|
{% set _ = globalmerged.update(hostvars[inventory_hostname]['nft_combined_rules'].nft_global_group_rules) %}
|
|
|
|
{% endif %}
|
2017-08-07 17:07:35 +02:00
|
|
|
{% set _ = globalmerged.update(nft_global_host_rules) %}
|
|
|
|
|
2017-08-07 13:48:54 +02:00
|
|
|
# clean
|
|
|
|
flush ruleset
|
|
|
|
|
2020-06-02 09:22:17 +02:00
|
|
|
include "{{ nft_define_conf_path }}"
|
2017-08-08 12:11:58 +02:00
|
|
|
|
2018-02-06 15:50:31 +01:00
|
|
|
table inet filter {
|
2017-08-07 17:07:35 +02:00
|
|
|
chain global {
|
|
|
|
{% for group, rules in globalmerged|dictsort %}
|
|
|
|
# {{ group }}
|
2020-11-10 21:17:11 +01:00
|
|
|
{% if not rules %}
|
2017-08-07 17:07:35 +02:00
|
|
|
# (none)
|
2020-11-10 21:17:11 +01:00
|
|
|
{% endif %}
|
|
|
|
{% for rule in rules %}
|
2017-08-07 17:07:35 +02:00
|
|
|
{{ rule }}
|
2020-11-10 21:17:11 +01:00
|
|
|
{% endfor %}
|
2017-08-07 17:07:35 +02:00
|
|
|
{% endfor %}
|
|
|
|
}
|
2017-08-08 14:32:59 +02:00
|
|
|
include "{{ nft_set_conf_path }}"
|
2017-08-07 17:37:41 +02:00
|
|
|
include "{{ nft_input_conf_path }}"
|
2017-08-08 15:35:05 +02:00
|
|
|
include "{{ nft_output_conf_path }}"
|
2017-08-07 13:48:54 +02:00
|
|
|
}
|
2019-04-16 11:50:30 +02:00
|
|
|
|
2019-04-16 15:59:08 +02:00
|
|
|
{% if nft__nat_table_manage %}
|
|
|
|
# Additionnal table for Network Address Translation (NAT)
|
|
|
|
table ip nat {
|
2019-04-16 18:57:31 +02:00
|
|
|
include "{{ nft_set_conf_path }}"
|
2019-04-16 15:59:08 +02:00
|
|
|
include "{{ nft__nat_prerouting_conf_path }}"
|
|
|
|
include "{{ nft__nat_postrouting_conf_path }}"
|
|
|
|
}
|
|
|
|
{% endif %}
|
|
|
|
|
2019-04-16 11:50:30 +02:00
|
|
|
{% if nft__custom_content|d() %}
|
|
|
|
# Custom content from ipr-cnrs.nftables
|
|
|
|
{{ nft__custom_content }}
|
|
|
|
{% endif %}
|