This repository has been archived on 2024-04-30. You can view files and clone it, but cannot push or open issues or pull requests.
setup/roles/syncthing/tasks/main.yml

34 lines
992 B
YAML
Raw Normal View History

2022-12-15 19:58:13 +00:00
- name: Install Syncthing
become: true
apt:
2022-12-19 22:27:26 +00:00
name: syncthing
2022-12-15 19:58:13 +00:00
- name: Create Syncthing configuration directory
file:
path: ~/.config/syncthing
state: directory
- name: Copy Syncthing configuration
template:
src: "{{ role_path }}/templates/config.xml.j2"
2022-12-15 19:58:13 +00:00
dest: ~/.config/syncthing/config.xml
2022-12-27 17:12:17 +00:00
register: config
2023-02-11 18:27:38 +00:00
vars:
profile: "{{ syncthing[syncthing_profile] }}"
2022-12-15 19:58:13 +00:00
- name: Copy Syncthing private key
copy:
2023-02-11 18:27:38 +00:00
src: "{{ role_path }}/files/{{ syncthing_profile }}/key.pem"
2022-12-15 19:58:13 +00:00
dest: ~/.config/syncthing/key.pem
2022-12-27 17:12:17 +00:00
register: private_key
2022-12-15 19:58:13 +00:00
- name: Copy Syncthing certificate
copy:
2023-02-11 18:27:38 +00:00
src: "{{ role_path }}/files/{{ syncthing_profile }}/cert.pem"
2022-12-15 19:58:13 +00:00
dest: ~/.config/syncthing/cert.pem
2022-12-27 17:12:17 +00:00
register: certificate
2022-12-15 21:39:05 +00:00
- name: Enable Syncthing
become: true
systemd:
enabled: true
name: "syncthing@{{ ansible_user_id }}"
2022-12-27 17:12:17 +00:00
state: "{{ state }}"
vars:
state: "{{ 'restarted' if config.changed or private_key.changed or certificate.changed else 'started' }}"