ansible-syncthing/tasks/main.yml

76 lines
1.7 KiB
YAML

---
- name: Ensure syncthing user is present
user:
name: syncthing
state: present
create_home: yes
home: "{{ syncthing.home }}"
shell: /usr/sbin/nologin
- name: Ensure syncthing dir is present
file:
path: "{{ syncthing.dir }}"
state: directory
owner: syncthing
group: syncthing
mode: 0700
- name: Ensure syncthing is installed
apt:
name:
- syncthing
- python-lxml
- python3-lxml
state: latest
- name: Ensure syncthing is running
systemd:
name: syncthing@syncthing.service
state: started
enabled: yes
- name: Set the sync directory
xml:
path: "{{ syncthing.home }}/.config/syncthing/config.xml"
xpath: /configuration/folder
attribute: path
value: "{{ syncthing.dir }}"
notify: restart syncthing
retries: 3
delay: 3
register: result
until: not result.failed
- name: Add an user to log into the interface
xml:
path: "{{ syncthing.home }}/.config/syncthing/config.xml"
xpath: /configuration/gui/user
value: "{{ syncthing.user }}"
notify: restart syncthing
retries: 3
delay: 3
register: result
until: not result.failed
- name: Set the password
xml:
path: "{{ syncthing.home }}/.config/syncthing/config.xml"
xpath: /configuration/gui/password
value: "{{ syncthing.password }}"
notify: restart syncthing
retries: 3
delay: 3
register: result
until: not result.failed
- name: Make public the management interface
xml:
path: "{{ syncthing.home }}/.config/syncthing/config.xml"
xpath: /configuration/gui/address
value: 0.0.0.0:8384
notify: restart syncthing
retries: 3
delay: 3
register: result
until: not result.failed