From cc138080818b5606848b049c8dbd13ca2a81d01d Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Tue, 27 Dec 2022 18:12:17 +0100 Subject: [PATCH] enable syncthing only if necessary --- roles/syncthing/tasks/main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/roles/syncthing/tasks/main.yml b/roles/syncthing/tasks/main.yml index ec6069c..03c8e69 100644 --- a/roles/syncthing/tasks/main.yml +++ b/roles/syncthing/tasks/main.yml @@ -10,17 +10,22 @@ template: src: "{{ role_path }}/templates/config.xml.j2" dest: ~/.config/syncthing/config.xml + register: config - name: Copy Syncthing private key copy: src: "{{ role_path }}/files/key.pem" dest: ~/.config/syncthing/key.pem + register: private_key - name: Copy Syncthing certificate copy: src: "{{ role_path }}/files/cert.pem" dest: ~/.config/syncthing/cert.pem + register: certificate - name: Enable Syncthing become: true systemd: enabled: true name: "syncthing@{{ ansible_user_id }}" - state: restarted + state: "{{ state }}" + vars: + state: "{{ 'restarted' if config.changed or private_key.changed or certificate.changed else 'started' }}"