diff options
Diffstat (limited to 'roles/syncthing/tasks/main.yml')
-rw-r--r-- | roles/syncthing/tasks/main.yml | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/roles/syncthing/tasks/main.yml b/roles/syncthing/tasks/main.yml index 1be6dae..3c5ddb2 100644 --- a/roles/syncthing/tasks/main.yml +++ b/roles/syncthing/tasks/main.yml @@ -9,8 +9,77 @@ 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 + |