From b2dbc57bde806773157775b483bc49af231f74a9 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 4 Jan 2021 22:23:04 +0100 Subject: [PATCH] Initial commit --- README.md | 13 +++++++++++ tasks/main.yml | 47 ++++++++++++++++++++++++++++++++++++++++ templates/listen.conf.j2 | 3 +++ 3 files changed, 63 insertions(+) create mode 100644 README.md create mode 100644 tasks/main.yml create mode 100644 templates/listen.conf.j2 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e02a536 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# Syncthing discosrv ansible role + +When having a server that does not connect directly to the internet, but which +can interact with other machines through a VPN (tinc), it is useful to have +our own syncthing discovery server to be able to use syncthing on it. + +This role sets up discosrv on archlinux and makes it listen exclusively on +the VPN ip. + +## Expected host parameters + +**vpn_ip** + diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..b5d6809 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,47 @@ +--- + +- name: Download discosrv package + become: yes + become_user: pkg + command: + cmd: yay -G syncthing-discosrv + chdir: /home/pkg/ + + +- name: Build discosrv package + become: yes + become_user: pkg + command: + cmd: makepkg + chdir: /home/pkg/syncthing-discosrv + creates: "/home/pkg/syncthing-discosrv/syncthing-discosrv-*.pkg*" + +- name: Find pkg + find: + paths: /home/pkg/syncthing-discosrv + file_type: file + patterns: "syncthing-discosrv*pkg*" + register: srv_pkg + +- name: Install discosrv + community.general.pacman: + name: "{{ srv_pkg.files[0].path }}" + state: present + +- name: Install custom dir + file: + path: /etc/systemd/system/syncthing-discosrv.service.d + state: directory + +- name: Add custom exec line to discosrv + template: + dest: /etc/systemd/system/syncthing-discosrv.service.d/listen.conf + src: listen.conf.j2 + mode: 0644 + +- name: Enable and run discosrv + systemd: + enabled: true + state: started + name: syncthing-discosrv + diff --git a/templates/listen.conf.j2 b/templates/listen.conf.j2 new file mode 100644 index 0000000..9aeff71 --- /dev/null +++ b/templates/listen.conf.j2 @@ -0,0 +1,3 @@ +[Service] +ExecStart= +ExecStart=/usr/bin/syncthing-discosrv -db-dir /var/discosrv/discosrv.db -cert /var/discosrv/cert.pem -key /var/discosrv/key.pem -listen={{ vpn_ip }}:5555 -replication-listen-address={{ vpn_ip }}:19200