ctucx.git: ansible-configs

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

commit c13230b58cefe699a2d26713644838afc0d3c86b
parent cd44ff173ace9bcad410aebb2a883db81e2ad355
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 17:32:15 +0100

roles/pleroma: some improvements
7 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/roles/pleroma/handlers/main.yml b/roles/pleroma/handlers/main.yml
@@ -0,0 +1,17 @@
+---
+
+- name: "[OpenRC] Restart service: pleroma (to deploy config changes)"
+  service:
+    name: pleroma
+    state: restarted
+  when:
+    - ansible_service_mgr == "openrc"
+  listen: "Restart pleroma"
+
+- name: "[systemd] Restart service: pleroma (to deploy config changes)"
+  systemd:
+    name: pleroma
+    state: restarted
+  when:
+    - ansible_service_mgr == "systemd"
+  listen: "Restart pleroma"
diff --git a/roles/pleroma/meta/main.yml b/roles/pleroma/meta/main.yml
@@ -2,4 +2,7 @@
 
 dependencies:
   - role: postgresql
+  - role: nginx
+    when:
+      - services.pleroma.nginx.enable is true
    
\ No newline at end of file
diff --git a/roles/pleroma/tasks/configure.yml b/roles/pleroma/tasks/configure.yml
@@ -7,6 +7,7 @@
     mode: 0755
     owner: pleroma
     group: pleroma
+  notify: "Restart pleroma"
 
 - name: "Copy secretsContent to: /var/lib/pleroma/secret.exs"
   copy:

@@ -15,3 +16,4 @@
     owner:   pleroma
     group:   pleroma
     mode:    0700
+  notify: "Restart pleroma"
diff --git a/roles/pleroma/tasks/main.yml b/roles/pleroma/tasks/main.yml
@@ -32,6 +32,5 @@
     - services.pleroma.enable is defined
     - services.pleroma.enable is false
 
-
-
-
+- name: Run handlers
+  meta: flush_handlers
diff --git a/roles/pleroma/tasks/nginx.yml b/roles/pleroma/tasks/nginx.yml
@@ -7,8 +7,4 @@
     mode: 0644
     owner: nginx
     group: nginx
-
-- name: "[OpenRC] Restart service: nginx"
-  service:
-    name: nginx
-    state: restarted
+  notify: "Restart nginx"+
\ No newline at end of file
diff --git a/roles/pleroma/tasks/remove.yml b/roles/pleroma/tasks/remove.yml
@@ -0,0 +1,29 @@
+---
+
+- name: "[OpenRC] Disable and stop service: pleroma"
+  service:
+    name: pleroma
+    enabled: no
+    state: stopped
+  when:
+    - ansible_service_mgr == "openrc"
+
+- name: "[Alpine] Remove package: pleroma"
+  apk:
+    name: pleroma
+    state: absent
+  when:
+    - ansible_distribution == "Alpine" 
+
+- name: "Delete leftovers"
+  file:
+    path: "{{item}}"
+    state: absent
+  with_items:
+    - /etc/pleroma
+
+- name: "Delete nginx vhost for: pleroma"
+  file:
+    path: /etc/nginx/conf.d/pleroma.conf
+    state: absent
+  notify: "Restart nginx"
diff --git a/roles/pleroma/tasks/start.yml b/roles/pleroma/tasks/start.yml
@@ -1,9 +1,9 @@
 ---
 
-- name: "[OpenRC] Enable and restart service: pleroma"
+- name: "[OpenRC] Enable and start service: pleroma"
   service:
     name: pleroma
     enabled: yes
-    state: restarted
+    state: started
   when:
     - ansible_service_mgr == "openrc"