From dfbaa7b4da0b46281ebfe0795217c71a0cff90bf Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Thu, 8 Jan 2026 19:51:49 +0100 Subject: [PATCH] Update syncthing configuration --- host_vars/fudiggity/syncthing.yml | 11 +-- tasks/syncthing.yml | 21 +++-- templates/syncthing/config.j2 | 112 -------------------------- templates/syncthing/docker-compose.j2 | 2 +- 4 files changed, 13 insertions(+), 133 deletions(-) diff --git a/host_vars/fudiggity/syncthing.yml b/host_vars/fudiggity/syncthing.yml index 8ca4cf8..0721455 100644 --- a/host_vars/fudiggity/syncthing.yml +++ b/host_vars/fudiggity/syncthing.yml @@ -1,14 +1,7 @@ --- syncthing_app_dir: "/srv/docker/syncthing" -syncthing_config_version: 37 -syncthing_api_key: !vault | - $ANSIBLE_VAULT;1.1;AES256 - 31663863326431623139663861316432656264646533323934393033386263613162303266613265 - 3239613930623264383161363664636232663764616138360a643239393735393862376133313062 - 63643434636462306663303434393837353230623830323065626432346336363332363063313533 - 6334633838636664610a323762373839393331653130393136356136303535393662643736643735 - 30316565373866326337383137633639636566623263333061633830366634666537633765343533 - 3736383135393238663963353131663733363962343163363539 +syncthing_image_tag: "syncthing/syncthing:2.0" +syncthing_config_version: 51 syncthing_devices: - name: Desktop diff --git a/tasks/syncthing.yml b/tasks/syncthing.yml index e4649d3..71b2668 100644 --- a/tasks/syncthing.yml +++ b/tasks/syncthing.yml @@ -25,6 +25,11 @@ owner: sonny group: sonny +- name: Stop current containers + community.docker.docker_compose_v2: + project_src: "{{ syncthing_app_dir }}" + state: stopped + - name: Remove previous Syncthing configurations become: true ansible.builtin.file: @@ -40,6 +45,11 @@ group: sonny mode: "0755" +# The current configuration has the bare minimum options configured per element +# and relies on falling back to syncthing's defaults. This is because Syncthing +# overwrites the config file while the application is running, +# see https://forum.syncthing.net/t/manage-devices-and-folders-with-ansible/20078. +# Note that the config version should also be updated whenever the image tag is updated. - name: Copy Syncthing configuration become: true ansible.builtin.template: @@ -58,17 +68,6 @@ group: sonny mode: "0755" -- name: Stop current containers - community.docker.docker_compose_v2: - project_src: "{{ syncthing_app_dir }}" - state: stopped - -- name: Pull missing image - community.docker.docker_compose_v2: - project_src: "{{ syncthing_app_dir }}" - pull: missing - state: stopped - - name: Remove dangling containers community.docker.docker_compose_v2: project_src: "{{ syncthing_app_dir }}" diff --git a/templates/syncthing/config.j2 b/templates/syncthing/config.j2 index c48c0d8..372a48a 100644 --- a/templates/syncthing/config.j2 +++ b/templates/syncthing/config.j2 @@ -14,39 +14,7 @@ {%- endfor %} - basic 20 - - 3600 - - basic - - - 0 - 0 - 0 - random - false - 0 - 0 - -1 - false - false - false - 25 - .stfolder - false - 0 - 2 - false - standard - standard - false - false - false - false - false - false {%- endfor %} @@ -56,20 +24,12 @@ name="{{ device.name }}" compression="metadata">
{{ device.address }}
- false - false - 0 - 0 - 0 false - 0 - 0 {%- endfor %}
{{ syncthing_listen_address }}:{{ syncthing_gui_port }}
- {{ syncthing_api_key }} default true
@@ -77,76 +37,4 @@ tcp://{{ syncthing_listen_address }}:{{ syncthing_protocol_port }} - - - - - basic - - - - - - 1 - - - 3600 - - basic - - - 0 - 0 - 0 - random - false - 0 - 0 - 10 - false - false - false - 25 - .stfolder - false - 0 - 2 - false - standard - standard - false - false - - - -
dynamic
- false - false - 0 - 0 - 0 - false - 0 - 0 -
- - - (?d).DS_Store - -
diff --git a/templates/syncthing/docker-compose.j2 b/templates/syncthing/docker-compose.j2 index 628e132..8c9d46a 100644 --- a/templates/syncthing/docker-compose.j2 +++ b/templates/syncthing/docker-compose.j2 @@ -8,7 +8,7 @@ networks: services: syncthing: - image: syncthing/syncthing + image: {{ syncthing_image_tag }} container_name: syncthing environment: - PUID=1000