# syncthing ~~ roles/syncthing/tasks/main.yml # Init syncthing user and settings --- - name: ensure syncthing package is present package: name: syncthing state: present - name: ensure syncthing directory exists file: path: "{{ syncthing_dir }}" owner: "{{ syncthing_user }}" group: "{{ syncthing_group }}" mode: 0700 state: directory - name: ensure original syncthing dir does not exist file: path: /var/syncthing state: absent - name: ensure syncthing directory is redirected file: src: "{{ syncthing_dir }}" dest: /var/syncthing owner: _syncthing group: _syncthing mode: 0700 state: link - name: ensure syncthing is started once service: name: syncthing state: restarted - name: wait for generation of config. pause: seconds: 2 - name: ensure syncthing is stopped once service: name: syncthing state: stopped - name: ensure GUI options community.general.xml: path: "{{ syncthing_dir }}/.config/syncthing/config.xml" xpath: "/configuration/gui" attribute: "{{ item[0] }}" value: "{{ item[1] }}" loop: - [ "enabled", "true" ] - [ "tls", "true" ] - name: ensure GUI listen address community.general.xml: path: "{{ syncthing_dir }}/.config/syncthing/config.xml" xpath: "/configuration/gui/address" value: "{{ syncthing_gui_address }}:{{ syncthing_gui_port }}" - name: ensure common options community.general.xml: path: "{{ syncthing_dir }}/.config/syncthing/config.xml" xpath: "/configuration/options/{{ item[0] }}" value: "{{ item[1] }}" loop: - [ "globalAnnounceEnabled", "false" ] - [ "localAnnounceEnabled", "true" ] - [ "relaysEnabled", "false" ] - [ "natEnabled", "false" ] - [ "startBrowser", "false" ] - name: import openbsd custom rules include_tasks: _openbsd.yml when: ansible_distribution == "OpenBSD" - name: ensure syncthing is started and enabled service: name: syncthing state: restarted enabled: true