ctucx.git: ansible-configs

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

commit e500f10a4bd2360e318926959c89022a942aea18
parent 90e99699918f3d53d2d0c11749bb42dbb07e62dd
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 21:12:31 +0100

roles/synapse: split tasks into multiple files
8 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/roles/synapse/handlers/main.yml b/roles/synapse/handlers/main.yml
@@ -0,0 +1,17 @@
+---
+
+- name: "[OpenRC] Restart service: synapse (to deploy config changes)"
+  service:
+    name: synapse
+    state: restarted
+  when:
+    - ansible_service_mgr == "openrc"
+  listen: "Restart synapse"
+
+- name: "[systemd] Restart service: synapse (to deploy config changes)"
+  systemd:
+    name: synapse
+    state: restarted
+  when:
+    - ansible_service_mgr == "systemd"
+  listen: "Restart synapse"
diff --git a/roles/synapse/meta/main.yaml b/roles/synapse/meta/main.yaml
@@ -2,3 +2,4 @@
 
 dependencies:
   - role: postgresql
+  - role: nginx+
\ No newline at end of file
diff --git a/roles/synapse/tasks/configure.yml b/roles/synapse/tasks/configure.yml
@@ -7,6 +7,7 @@
     mode: 0655
     owner: synapse
     group: synapse
+  notify: "Restart synapse"
 
 - name: "Copy log-config to: /etc/synapse/log.yaml"
   copy:

@@ -15,6 +16,7 @@
     mode: 0655
     owner: synapse
     group: synapse
+  notify: "Restart synapse"
 
 - name: "[Alpine] Copy web-config to: /etc/riot-web/config.json"
   copy:

@@ -38,7 +40,7 @@
     - services.synapse.webClient.enable is defined
     - services.synapse.webClient.enable is true
 
-- name: "[Archlinux] Copy web-config to: /etc/webapps/element/onfig.json"
+- name: "[Archlinux] Copy web-config to: /etc/webapps/element/config.json"
   copy:
     src: "{{ services.synapse.webClientConfig }}"
     dest: "/etc/webapps/element/config.json"
diff --git a/roles/synapse/tasks/install.yml b/roles/synapse/tasks/install.yml
@@ -4,7 +4,6 @@
   apk:
     name: synapse
     state: present
-    update_cache: yes
   when:
     - ansible_distribution == "Alpine" 
 

@@ -12,7 +11,6 @@
   apk:
     name: riot-web
     state: present
-    update_cache: yes
   when:
     - system.enableOwnRepos is false
     - ansible_distribution == "Alpine" 

@@ -23,7 +21,6 @@
   apk:
     name: schildichat-web
     state: present
-    update_cache: yes
   when:
     - system.enableOwnRepos is true
     - ansible_distribution == "Alpine" 

@@ -36,7 +33,6 @@
   pacman:
     name: matrix-synapse
     state: present
-    update_cache: yes
   when:
     - ansible_distribution == "Archlinux" 
 

@@ -44,7 +40,6 @@
   pacman:
     name: element-web
     state: present
-    update_cache: yes
   when:
     - ansible_distribution == "Archlinux" 
     - services.synapse.webClient.enable is defined
diff --git a/roles/synapse/tasks/main.yml b/roles/synapse/tasks/main.yml
@@ -32,3 +32,4 @@
     - services.synapse.enable is defined
     - services.synapse.enable is false
 
+- meta: flush_handlers
diff --git a/roles/synapse/tasks/nginx.yml b/roles/synapse/tasks/nginx.yml
@@ -7,18 +7,4 @@
     mode: 0644
     owner: nginx
     group: nginx
-
-
-- name: "[OpenRC] Restart service: nginx"
-  service:
-    name: nginx
-    state: restarted
-  when:
-    - ansible_service_mgr == "openrc"
-
-- name: "[systemd] Restart service: nginx"
-  systemd:
-    name: nginx
-    state: restarted
-  when:
-    - ansible_service_mgr == "systemd"
+  notify: "Restart nginx"+
\ No newline at end of file
diff --git a/roles/synapse/tasks/remove.yml b/roles/synapse/tasks/remove.yml
@@ -35,6 +35,12 @@
     path: "{{item}}"
     state: absent
   with_items:
-    - /etc/nginx/conf.d/synapse.conf
     - /etc/synapse
-    - /etc/webapps/element-
\ No newline at end of file
+    - /etc/webapps/element
+    - /etc/webapps/schildichat-web
+
+- name: "Delete nginx vhost for: synapse"
+  file:
+    path: /etc/nginx/conf.d/synapse.conf
+    state: absent
+  notify: "Restart nginx"
diff --git a/roles/synapse/tasks/start.yml b/roles/synapse/tasks/start.yml
@@ -1,17 +1,17 @@
 ---
 
-- name: "[OpenRC] Enable and restart service: synapse"
+- name: "[OpenRC] Enable and start service: synapse"
   service:
     name: synapse
     enabled: yes
-    state: restarted
+    state: started
   when:
     - ansible_service_mgr == "openrc"
 
-- name: "[systemd] Enable and restart service: synapse"
+- name: "[systemd] Enable and start service: synapse"
   systemd:
     name: synapse
     enabled: yes
-    state: restarted
+    state: started
   when:
     - ansible_service_mgr == "systemd" 
\ No newline at end of file