commit 0712bd193c71eb338d6124499fa1ea9a6ad44905
parent f8f91deac156e02b44359276fee8b23d1d262a5a
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 17:03:42 +0100
parent f8f91deac156e02b44359276fee8b23d1d262a5a
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 17:03:42 +0100
roles/maddy: split tasks into multiple files
8 files changed, 39 insertions(+), 36 deletions(-)
diff --git a/roles/maddy/handlers/main.yml b/roles/maddy/handlers/main.yml @@ -0,0 +1,17 @@ +--- + +- name: "[OpenRC] Restart service: maddy (to deploy config changes)" + service: + name: maddy + state: restarted + when: + - ansible_service_mgr == "openrc" + listen: "Restart maddy" + +- name: "[systemd] Restart service: maddy (to deploy config changes)" + systemd: + name: maddy + state: restarted + when: + - ansible_service_mgr == "systemd" + listen: "Restart maddy"
diff --git a/roles/maddy/meta/main.yml b/roles/maddy/meta/main.yml @@ -0,0 +1,4 @@ +--- + +dependencies: + - role: nftables-handler+ \ No newline at end of file
diff --git a/roles/maddy/tasks/checks.yml b/roles/maddy/tasks/checks.yml @@ -4,6 +4,11 @@ when: - ansible_distribution != "Alpine" +- fail: msg="This Role only works when Option 'system.enableOwnRepos' is true!" + when: + - system.enableOwnRepos is false + - services.mbusd.enable is true + - fail: msg="Option 'services.maddy.hostname' has to be set!" when: - services.maddy.hostname is not defined
diff --git a/roles/maddy/tasks/configure.yml b/roles/maddy/tasks/configure.yml @@ -15,6 +15,7 @@ mode: 0644 owner: maddy group: maddy + notify: "Restart maddy" - name: "Create file: /var/log/maddy.log" file:
diff --git a/roles/maddy/tasks/firewall.yml b/roles/maddy/tasks/firewall.yml @@ -4,22 +4,4 @@ copy: src: nftables-rule.nft dest: /etc/nftables.d/maddy.nft - when: - - network.nftables.enable is true - -- 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 - + notify: "Restart nftables"+ \ No newline at end of file
diff --git a/roles/maddy/tasks/main.yml b/roles/maddy/tasks/main.yml @@ -30,3 +30,5 @@ - services.maddy.enable is defined - services.maddy.enable is false +- name: Run handlers + meta: flush_handlers
diff --git a/roles/maddy/tasks/remove.yml b/roles/maddy/tasks/remove.yml @@ -25,20 +25,10 @@ - "/etc/init.d/maddy" - "/etc/maddy" - "/var/log/maddy.log" - - "/etc/nftables.d/maddy.nft" -- name: "[OpenRC] Restart service: nftables" - service: - name: nftables - state: restarted - when: - - ansible_service_mgr == "openrc" - - network.nftables.enable is true +- name: "[nftables] Delete rule for: maddy" + file: + path: /etc/nftables.d/maddy.nft + state: absent + notify: "Restart nftables" -- name: "[systemd] Restart service: nftables" - systemd: - name: nftables - state: restarted - when: - - ansible_service_mgr == "systemd" - - network.nftables.enable is true
diff --git a/roles/maddy/tasks/start.yml b/roles/maddy/tasks/start.yml @@ -1,9 +1,9 @@ --- -- name: "[OpenRC] Enable and restart service: maddy" +- name: "[OpenRC] Enable and start service: maddy" service: name: maddy enabled: yes - state: restarted + state: started when: - ansible_service_mgr == "openrc"