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

50 lines
1.4 KiB
YAML
Raw Normal View History

2023-02-11 21:33:25 +00:00
- name: Download PPA signing key
become: true
apt_key:
keyserver: keyserver.ubuntu.com
id: "37C84554E7E0A261E4F76E1ED26E6ED000654A3E"
keyring: /etc/apt/keyrings/syncthing.gpg
- name: Install APT repository
become: true
apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/syncthing.gpg] https://apt.syncthing.net/ syncthing stable"
register: apt_repository
- name: Update APT cache
become: true
apt:
update_cache: true
when: apt_repository.changed
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' }}"