ctucx.git: ansible-configs

My personal ansible roles and playbooks [deprecated in favor of nixos]

commit 9e18855d3398edd9208a9606952a8a56fd4b457f
parent 8a49007753ea972ac5654a1404163fb31443290d
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 23 Feb 2021 21:21:41 +0100

roles/common/nftables: provide a default config
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/roles/common/tasks/firewall-nftables.yml b/roles/common/tasks/firewall-nftables.yml
@@ -18,17 +18,9 @@
     - ansible_distribution == "Archlinux"
     - network.nftables.enable is true
 
-- name: Fail when use nftables and no configFile
-  fail:
-    msg: Option 'network.nftables.configFile' not set!
-  when: 
-    - network.nftables.enable is true
-    - network.nftables.configFile is not defined
-
-
-- name: "[Alpine] Copy nftables config to destination"
+- name: "[Alpine] Create file: /etc/nftables.nft"
   copy:
-    src: "{{ network.nftables.configFile }}"
+    src: "{{ network.nftables.configFile | default('nftables-config.nft') }}"
     dest: /etc/nftables.nft
     mode: 0644
   register: nftablesConfig

@@ -36,9 +28,9 @@
     - ansible_distribution == "Alpine"
     - network.nftables.enable is true
 
-- name: "[Archlinux]  Copy nftables config to destination"
+- name: "[Archlinux] Create file: /etc/nftables.conf"
   copy:
-    src: "{{ network.nftables.configFile }}"
+    src: "{{ network.nftables.configFile | default('nftables-config.nft') }}"
     dest: /etc/nftables.conf
     mode: 0644
   register: nftablesConfig