From 1c17a3f3d99b5f0a64c0a066c230b7181252771e Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Tue, 12 Dec 2023 23:52:43 +0530 Subject: [PATCH] feat: make mcaptcha systemd service wait on deps --- ansible/roles/mcaptcha/tasks/main.yml | 8 +++--- .../mcaptcha/mcaptcha.service.j2} | 25 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) rename ansible/{artifacts/mcaptcha/mcaptcha.service => templates/mcaptcha/mcaptcha.service.j2} (61%) diff --git a/ansible/roles/mcaptcha/tasks/main.yml b/ansible/roles/mcaptcha/tasks/main.yml index 4852cfa..6ee38b9 100644 --- a/ansible/roles/mcaptcha/tasks/main.yml +++ b/ansible/roles/mcaptcha/tasks/main.yml @@ -42,9 +42,9 @@ - name: Copy mCaptcha systemd servicefile become: true - ansible.builtin.copy: - src: ./artifacts/mcaptcha/mcaptcha.service - dest: /etc/systemd/system/ + ansible.builtin.template: + src: ./templates/mcaptcha/mcaptcha.service.j2 + dest: /etc/systemd/system/mcaptcha.service owner: root group: root force: true @@ -57,7 +57,7 @@ state: directory mode: "0755" -- name: Copy mCaptcha systemd servicefile +- name: Copy mCaptcha config file become: true notify: restart mcaptcha ansible.builtin.template: diff --git a/ansible/artifacts/mcaptcha/mcaptcha.service b/ansible/templates/mcaptcha/mcaptcha.service.j2 similarity index 61% rename from ansible/artifacts/mcaptcha/mcaptcha.service rename to ansible/templates/mcaptcha/mcaptcha.service.j2 index 9889943..49dac32 100644 --- a/ansible/artifacts/mcaptcha/mcaptcha.service +++ b/ansible/templates/mcaptcha/mcaptcha.service.j2 @@ -2,18 +2,23 @@ Description=mCaptcha: PoW CAPTCHA system After=syslog.target After=network.target -### -# Don't forget to add the database service dependencies -### -# -#Wants=mariadb.service -#After=mariadb.service -# + +{% if cache_type == 'redis' %} +Wants=redis.service +After=redis.service +{% endif %} + +{% if database_type == 'postgres' %} Wants=postgresql.service After=postgresql.service -# -#Wants=redis.service -#After=redis.service +{% endif %} + +{% if database_type == 'mariadb' %} +Wants=mariadb.service +After=mariadb.service +{% endif %} + + [Service] RestartSec=2s