ctucx.git: ansible-configs

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

commit c362d545a0d4847d7aa172d990be8665385a4077
parent 426dc36a4821ecab29e99d72fc0629055f49d0ba
Author: Leah Thein <leah@toaster.fritz.box>
Date: Thu, 3 Dec 2020 00:11:30 +0100

syncthing: allow configuration without nginx
3 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/config-files/syncthing/syncthing.initd b/config-files/syncthing/syncthing.initd
@@ -1,20 +0,0 @@
-#!/sbin/openrc-run
-
-name=$RC_SVCNAME
-command=/usr/bin/syncthing
-command_args="${SYNCTHING_ARGS:--no-browser}"
-command_user="leah:leah"
-pidfile=/run/${RC_SVCNAME}.pid
-command_background=yes
-start_stop_daemon_args="--stdout /var/log/$RC_SVCNAME/${RC_SVCNAME}.log --stderr /var/log/$RC_SVCNAME/${RC_SVCNAME}.log"
-
-depend() {
-        use logger dns
-        need net
-        after firewall
-}
-
-start_pre() {
-        checkpath --directory --owner $command_user --mode 0775 \
-                /var/log/$RC_SVCNAME
-}
diff --git a/roles/syncthing/tasks/main.yml b/roles/syncthing/tasks/main.yml
@@ -7,8 +7,8 @@
    update_cache: yes
 
 - name: copy initd to destination host 
-  copy: 
-    src: config-files/syncthing/syncthing.initd
+  template: 
+    src: syncthing-initd.j2
     dest: /etc/init.d/syncthing-leah
     mode: 0755
 

@@ -25,17 +25,22 @@
     mode: 0644
     owner: nginx
     group: nginx
+  when: syncthing.disableReverseProxy is not defined
 
-- awall:
+- name: enable firewall-rules for syncthing
+  awall:
    name: syncthing
    state: enabled
    activate: yes
 
-- service:
+- name: restart syncthing
+  service:
    name: syncthing-leah
    enabled: yes
    state: restarted
 
-- service:
+- name: restart nginx
+  service:
    name: nginx
    state: restarted
+  when: syncthing.disableReverseProxy is not defined
diff --git a/roles/syncthing/templates/syncthing-initd.j2 b/roles/syncthing/templates/syncthing-initd.j2
@@ -0,0 +1,24 @@
+#!/sbin/openrc-run
+
+name=$RC_SVCNAME
+command=/usr/bin/syncthing
+{% if syncthing.guiAddress is defined %}
+command_args="-no-browser -gui-address={{ syncthing.guiAddress }}"
+{% else %}
+command_args="-no-browser"
+{% endif %}
+command_user="leah:leah"
+pidfile=/run/${RC_SVCNAME}.pid
+command_background=yes
+start_stop_daemon_args="--stdout /var/log/$RC_SVCNAME/${RC_SVCNAME}.log --stderr /var/log/$RC_SVCNAME/${RC_SVCNAME}.log"
+
+depend() {
+        use logger dns
+        need net
+        after firewall
+}
+
+start_pre() {
+        checkpath --directory --owner $command_user --mode 0775 \
+                /var/log/$RC_SVCNAME
+}