From ac082440d983de391b2a66ae885feb67ac17681d Mon Sep 17 00:00:00 2001 From: "pulsar89.5" Date: Thu, 28 Dec 2023 17:39:20 +0100 Subject: [PATCH] feat: Merge rules and tables in one file --- tasks/configuration.yml | 8 ++++---- templates/rules.conf.j2 | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tasks/configuration.yml b/tasks/configuration.yml index 026396f..4bb9661 100644 --- a/tasks/configuration.yml +++ b/tasks/configuration.yml @@ -33,10 +33,10 @@ group: root mode: u=rw,g=,o= src: "{{ role_path }}/templates/rules.conf.j2" - dest: "/srv/nftables/rules_{{ item.filename }}.conf" - loop: "{{ nftables_rules }}" - loop_control: - label: "{{ item.filename }}" + dest: "/srv/nftables/rules.conf" +# loop: "{{ nftables_rules }}" +# loop_control: +# label: "{{ item.filename }}" become: true notify: Redémarrer nftables.service diff --git a/templates/rules.conf.j2 b/templates/rules.conf.j2 index 81e015c..a8c2958 100644 --- a/templates/rules.conf.j2 +++ b/templates/rules.conf.j2 @@ -1,5 +1,7 @@ # {{ ansible_managed }} -{% for rule in item.rules %} -{{ rule }} +{% for item in nftables_rules %} +# BEGIN {{ item.name }} +{{ item.rules | join('\n') }} +# END {{ item.name }} {% endfor %}