commit 0f5252790190f0eddbf79b95dc059b0437bdbf98
parent c3e49bc77300982bedbebe5826e664015ed4a3f1
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 17:04:52 +0100
parent c3e49bc77300982bedbebe5826e664015ed4a3f1
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 17:04:52 +0100
roles/fritzboxExporter: improvements
3 files changed, 17 insertions(+), 27 deletions(-)
diff --git a/roles/fritzboxExporter/meta/main.yml b/roles/fritzboxExporter/meta/main.yml @@ -1,6 +1,9 @@ --- dependencies: - - nginx - - nginx-handler - - nftables-handler- \ No newline at end of file + - role: nginx + when: + - services.fritzboxExporter.nginx.enable is true + - role: nftables-handler + when: + - network.nftables.enable is true
diff --git a/roles/fritzboxExporter/tasks/main.yaml b/roles/fritzboxExporter/tasks/main.yaml @@ -27,10 +27,10 @@ - services.fritzboxExporter.enable is defined - services.fritzboxExporter.enable is true -- name: Run handlers - meta: flush_handlers - - include: remove.yml when: - services.fritzboxExporter.enable is defined - services.fritzboxExporter.enable is false + +- name: Run handlers + meta: flush_handlers
diff --git a/roles/fritzboxExporter/tasks/remove.yml b/roles/fritzboxExporter/tasks/remove.yml @@ -32,26 +32,14 @@ - ansible_distribution == "Archlinux" -- name: "Delete leftovers" +- name: "Delete nginx vhost for: fritzbox-exporter" file: - path: "{{item}}" + path: /etc/nginx/conf.d/fritzbox-exporter.conf state: absent - with_items: - - /etc/nginx/conf.d/fritzbox-exporter.conf - - /etc/nftables.d/fritzbox-exporter.nft + notify: "Restart nginx" -- 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: fritzbox-exporter" + file: + path: /etc/nftables.d/fritzbox-exporter.nft + state: absent + notify: "Restart nftables"