aboutsummaryrefslogblamecommitdiffstats
path: root/roles/syncthing/tasks/main.yml
blob: 3c5ddb21b68fd003a13eb5df21f7da4f8cc1f8a1 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                             



































































                                                                 




                                               
 

# 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

remember that computers suck.