ctucx.git: ansible-configs

My personal ansible roles and playbooks

commit 231d7e41bfc23451182cfce988c9054c2591d725
parent 0712bd193c71eb338d6124499fa1ea9a6ad44905
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 17:04:13 +0100

roles/bind: improvements
3 files changed, 11 insertions(+), 22 deletions(-)
diff --git a/roles/bind/meta/main.yml b/roles/bind/meta/main.yml
@@ -1,4 +1,6 @@
 ---
 
 dependencies:
-  - nftables-handler-
\ No newline at end of file
+  - role: nftables-handler
+    when:
+      - network.nftables.enable is true
diff --git a/roles/bind/tasks/main.yml b/roles/bind/tasks/main.yml
@@ -21,10 +21,10 @@
     - services.bind.enable is defined
     - services.bind.enable is true
 
-- name: Run handlers
-  meta: flush_handlers
-
 - include: remove.yml
   when:
     - services.bind.enable is defined
     - services.bind.enable is false
+
+- name: Run handlers
+  meta: flush_handlers
diff --git a/roles/bind/tasks/remove.yml b/roles/bind/tasks/remove.yml
@@ -42,21 +42,9 @@
     - /etc/bind
     - /etc/named.conf
     - /var/lib/named
-    - /etc/nftables.d/bind.nft
 
-
-- name: "[OpenRC] Restart service: nftables"
-  service:
-    name: nftables
-    state: restarted
-  when:
-    - ansible_service_mgr == "openrc"
-    - network.nftables.enable is true
-
-- name: "[systemd] Restart service: nftables"
-  systemd:
-    name: nftables
-    state: restarted
-  when:
-    - ansible_service_mgr == "systemd"
-    - network.nftables.enable is true
+- name: "[nftables] Delete rule for: bind"
+  file:
+    path: /etc/nftables.d/bind.nft
+    state: absent
+  notify: "Restart nftables"