ctucx.git: ansible-configs

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

commit 13bb119f58080c179ff23930c793745250bdd8cb
parent 7ca398cc1911695103f38dfff7d9bb9a72398c2e
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 21:14:23 +0100

roles/smartied: split tasks into multiple files
8 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/roles/smartied/handlers/main.yml b/roles/smartied/handlers/main.yml
@@ -0,0 +1,10 @@
+---
+
+- name: "[systemd] Restart service: smartied (to deploy config changes)"
+  systemd:
+    daemon_reload: yes
+    name: smartied
+    state: restarted
+  when:
+    - ansible_service_mgr == "systemd"
+  listen: "Restart smartied"
diff --git a/roles/smartied/meta/main.yml b/roles/smartied/meta/main.yml
@@ -0,0 +1,4 @@
+---
+
+dependencies:
+  - role: nginx
diff --git a/roles/smartied/tasks/configure.yml b/roles/smartied/tasks/configure.yml
@@ -5,6 +5,7 @@
     src: "{{ services.smartied.configFile }}"
     dest: /etc/smartied.json
     mode: 0755
+  notify: "Restart smartied"
 
 - name: "Create directory: /etc/systemd/system/smartied.service.d"
   file:

@@ -16,4 +17,5 @@
   copy:
     src: smartied.service-override.conf
     dest: /etc/systemd/system/smartied.service.d/override.conf
-    mode: 0755-
\ No newline at end of file
+    mode: 0755
+  notify: "Restart smartied"
diff --git a/roles/smartied/tasks/install.yml b/roles/smartied/tasks/install.yml
@@ -6,7 +6,6 @@
       - smartied
       - smartie-pwa
     state: present
-    update_cache: yes
   when: 
     - ansible_distribution == "Archlinux" 
 
diff --git a/roles/smartied/tasks/main.yml b/roles/smartied/tasks/main.yml
@@ -32,7 +32,4 @@
     - services.smartied.enable is defined
     - services.smartied.enable is false
 
-
-
-
-
+- meta: flush_handlers
diff --git a/roles/smartied/tasks/nginx.yml b/roles/smartied/tasks/nginx.yml
@@ -7,17 +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"
diff --git a/roles/smartied/tasks/remove.yml b/roles/smartied/tasks/remove.yml
@@ -32,3 +32,9 @@
   with_items:
     - /etc/nginx/conf.d/smartied.conf
     - /etc/smartied.json
+
+- name: "Delete nginx vhost for: smartied"
+  file:
+    path: /etc/nginx/conf.d/smartied.conf
+    state: absent
+  notify: "Restart nginx"
diff --git a/roles/smartied/tasks/start.yml b/roles/smartied/tasks/start.yml
@@ -1,17 +1,17 @@
 ---
 
-- name: "[OpenRC] Restart and enable service: smartied"
+- name: "[OpenRC] Enable and start service: smartied"
   service:
     name: smartied
     enabled: yes
-    state: restarted
+    state: started
   when: 
     - ansible_service_mgr == "openrc"
 
-- name: "[systemd] Restart and enable service: smartied"
+- name: "[systemd] Enable and start service: smartied"
   systemd:
     name: smartied
     enabled: yes
-    state: restarted
+    state: started
   when: 
     - ansible_service_mgr == "systemd" 
\ No newline at end of file