From a3e4b8d822360acb6865de3f3b910001bd10545d Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sat, 3 Dec 2022 14:50:43 +0100 Subject: [PATCH] use docker compose for syncthing create /apps and /data directory --- roles/pizzeria/tasks/main.yml | 2 +- .../config.xml.j2 => files/config.xml} | 39 ++++++++------- roles/syncthing/files/docker-compose.yml | 20 ++++++++ roles/syncthing/meta/main.yml | 3 ++ roles/syncthing/tasks/main.yml | 49 +++++++++++-------- 5 files changed, 72 insertions(+), 41 deletions(-) rename roles/syncthing/{templates/config.xml.j2 => files/config.xml} (85%) create mode 100644 roles/syncthing/files/docker-compose.yml create mode 100644 roles/syncthing/meta/main.yml diff --git a/roles/pizzeria/tasks/main.yml b/roles/pizzeria/tasks/main.yml index 649d5af..da03235 100644 --- a/roles/pizzeria/tasks/main.yml +++ b/roles/pizzeria/tasks/main.yml @@ -2,7 +2,7 @@ git: repo: https://github.com/pizzapim/pizzeria dest: /apps/pizzeria -- name: Start the Docker compose +- name: Start the Docker Compose community.docker.docker_compose: project_src: /apps/pizzeria pull: true diff --git a/roles/syncthing/templates/config.xml.j2 b/roles/syncthing/files/config.xml similarity index 85% rename from roles/syncthing/templates/config.xml.j2 rename to roles/syncthing/files/config.xml index 81006ac..db87388 100644 --- a/roles/syncthing/templates/config.xml.j2 +++ b/roles/syncthing/files/config.xml @@ -1,12 +1,9 @@ - - + + basic - - - 1 3600 @@ -34,6 +31,14 @@ standard false false + false + false + false + false + + 1024 + 4096 +
dynamic
@@ -45,16 +50,6 @@ false 0
- -
dynamic
- false - false - 0 - 0 - 0 - false - 0 -
0.0.0.0:8384
@@ -84,7 +79,6 @@ https://data.syncthing.net/newdata false 1800 - true 12 false 24 @@ -117,9 +111,6 @@ - - - 1 3600 @@ -147,6 +138,14 @@ standard false false + false + false + false + false + + 1024 + 4096 +
dynamic
@@ -158,5 +157,7 @@ false 0
+
+ diff --git a/roles/syncthing/files/docker-compose.yml b/roles/syncthing/files/docker-compose.yml new file mode 100644 index 0000000..7f4e6d8 --- /dev/null +++ b/roles/syncthing/files/docker-compose.yml @@ -0,0 +1,20 @@ +--- +version: "2.1" +services: + syncthing: + image: lscr.io/linuxserver/syncthing:latest + container_name: syncthing + hostname: syncthing + environment: + - PUID=1000 + - PGID=1000 + - TZ=Europe/Amsterdam + volumes: + - /apps/syncthing/config:/config + - /data/syncthing:/data + ports: + - 8384:8384 + - 22000:22000/tcp + - 22000:22000/udp + - 21027:21027/udp + restart: unless-stopped diff --git a/roles/syncthing/meta/main.yml b/roles/syncthing/meta/main.yml new file mode 100644 index 0000000..090690b --- /dev/null +++ b/roles/syncthing/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - role: common + - role: docker diff --git a/roles/syncthing/tasks/main.yml b/roles/syncthing/tasks/main.yml index a8f6805..a371b19 100644 --- a/roles/syncthing/tasks/main.yml +++ b/roles/syncthing/tasks/main.yml @@ -1,27 +1,34 @@ -- name: Install Syncthing - apt: - name: syncthing - state: latest - update_cache: true -- name: Create syncthing user - user: - name: syncthing - home: /home/syncthing - state: present -- name: Copy Syncthing configuration - template: - src: "{{ role_path }}/templates/config.xml.j2" - dest: /home/syncthing/.config/syncthing/config.xml +- name: Create Syncthing app directory + file: + path: /apps/syncthing + state: directory +- name: Create Syncthing configuration directory + file: + path: /apps/syncthing/config + state: directory - name: Copy Syncthing private key copy: src: "{{ role_path }}/files/key.pem" - dest: /home/syncthing/.config/syncthing/key.pem + dest: /apps/syncthing/config/key.pem - name: Copy Syncthing certificate copy: src: "{{ role_path }}/files/cert.pem" - dest: /home/syncthing/.config/syncthing/cert.pem -- name: Enable Syncthing service - systemd: - name: syncthing@syncthing - enabled: true - state: restarted + dest: /apps/syncthing/config/cert.pem +- name: Copy Syncthing configuration + copy: + src: "{{ role_path }}/files/config.xml" + dest: /apps/syncthing/config/config.xml +- name: Create Syncthing data directory + file: + path: /data/syncthing + state: directory + mode: 0777 +- name: Copy docker compose script + copy: + src: "{{ role_path }}/files/docker-compose.yml" + dest: /apps/syncthing/docker-compose.yml +- name: Start Docker Compose + docker_compose: + project_src: /apps/syncthing + pull: true + remove_orphans: true