Initial commit

This commit is contained in:
Mathieu Pasquet 2021-01-04 22:23:04 +01:00
commit b2dbc57bde
3 changed files with 63 additions and 0 deletions

13
README.md Normal file
View File

@ -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**

47
tasks/main.yml Normal file
View File

@ -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

3
templates/listen.conf.j2 Normal file
View File

@ -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