L-P.syncthing
ansible-role-syncthing
====================== Install Syncthing.
Requirements
You need a Debian-based system and root access or the ability to use become on the remote machine.
Check the Syncthing documentation to find out which ports you need to open. This role does not handle firewall settings.
Role Variables
All variables listed here are optional.
The only way to configure Syncthing is by editing its config.xml
file, see the
Example Playbook section for more information.
# Change these if the repository/key changes or if you're hosting your own:
syncthing_apt_key_id:
syncthing_apt_key_url:
syncthing_apt_repository:
# Change the syncthing user name or home directory if needed:
syncthing_user:
syncthing_user_home:
# Set this to false if you don't want the role to create and manage the user.
# You need to create the user specified in syncthing_user manually
# _before_ using the role.
syncthing_manage_user:
# Set this to true to pull the Syncthing configuration from the remote host,
# refer to the Example Playbook section for details.
syncthing_fetch_config:
# This specifies where the fetched files will be saved.
syncthing_fetch_dir:
# Contents of configuration files
syncthing_config_cert:
syncthing_config_key:
syncthing_config_https_cert:
syncthing_config_https_key:
syncthing_config_config:
Dependencies
None.
Example Playbook
# To install Syncthing
- hosts: servers
roles:
- { role: l-p.syncthing }
Syncthing configuration is dynamic and can be changed with the GUI at runtime.
You need to get the configuration from the host and save it in the syncthing_config_*
variables to keep it safe for future runs.
If you fail to fetch the configuration before running the role again, all new devices, folders, and settings will be lost on the remote host.
If you don’t set the syncthing_config_*
variables, nothing will be overwritten, but you'll lose your configuration if something goes wrong with your server.
# To fetch the generated configuration
- hosts: servers
roles:
- { role: l-p.syncthing, syncthing_fetch_config: true }
You can use lookup
to read files and set the variables:
syncthing_config_cert: "{{lookup('file', 'files/{{ inventory_hostname }}/home/syncthing/.config/syncthing/cert.pem')}}"
syncthing_config_key: "{{lookup('file', 'files/{{ inventory_hostname }}/home/syncthing/.config/syncthing/key.pem')}}"
syncthing_config_https_cert: "{{lookup('file', 'files/{{ inventory_hostname }}/home/syncthing/.config/syncthing/https-cert.pem')}}"
syncthing_config_https_key: "{{lookup('file', 'files/{{ inventory_hostname }}/home/syncthing/.config/syncthing/https-key.pem')}}"
syncthing_config_config: "{{lookup('file', 'files/{{ inventory_hostname }}/home/syncthing/.config/syncthing/config.xml')}}"
It’s best practice to use ansible-vault
to encrypt your keys; lookup
will decrypt them as needed.
License
MIT