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
2023-02-26 01:17:16 +01:00

49 lines
1.5 KiB
YAML

- name: Download PPA signing key
become: true
apt_key:
keyserver: keyserver.ubuntu.com
id: "37C84554E7E0A261E4F76E1ED26E6ED000654A3E"
keyring: /etc/apt/trusted.gpg.d/syncthing.gpg
- name: Install APT repository
become: true
apt_repository:
repo: "deb [signed-by=/etc/apt/trusted.gpg.d/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
- 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
copy:
src: "{{ role_path }}/files/{{ syncthing_profile }}/cert.pem"
dest: ~/.config/syncthing/cert.pem
register: certificate
- name: Enable Syncthing
become: true
systemd:
enabled: true
name: "syncthing@{{ ansible_user_id }}"
state: "{{ state }}"
vars:
state: "{{ 'restarted' if config.changed or private_key.changed or certificate.changed else 'started' }}"