- name: Install Syncthing
become: true
apt:
name: syncthing
- name: Create Syncthing configuration directory
file:
path: ~/.config/syncthing
state: directory
- name: Copy Syncthing configuration
template:
src: "{{ role_path }}/templates/config.xml.j2"
dest: ~/.config/syncthing/config.xml
register: config
vars:
profile: "{{ syncthing[syncthing_profile] }}"
- name: Copy Syncthing private key
copy:
src: "{{ role_path }}/files/{{ syncthing_profile }}/key.pem"
dest: ~/.config/syncthing/key.pem
register: private_key
- name: Copy Syncthing certificate
src: "{{ role_path }}/files/{{ syncthing_profile }}/cert.pem"
dest: ~/.config/syncthing/cert.pem
register: certificate
- name: Enable Syncthing
systemd:
enabled: true
name: "syncthing@{{ ansible_user_id }}"
state: "{{ state }}"
state: "{{ 'restarted' if config.changed or private_key.changed or certificate.changed else 'started' }}"