L-P.syncthing
ansible-role-syncthing
安装 Syncthing。
要求
需要一个基于Debian的发行版,远程主机需要具有root权限或使用_became_。
请查看 Syncthing文档 以了解需要打开的端口。此角色不处理防火墙配置。
角色变量
所有变量都是可选的。
设置Syncthing选项的唯一方法是编辑其 config.xml
文件,详细信息请参见
示例剧本 部分。
# 如果存储库/密钥更改或想要托管自己的,请更改这些:
syncthing_apt_key_id:
syncthing_apt_key_url:
syncthing_apt_repository:
# 如果您希望更改Syncthing用户名或主目录:
syncthing_user:
syncthing_user_home:
# 如果您不希望角色创建和管理用户,请将此设置为false。
# 您需要在使用角色之前手动创建配置中的syncthing_user指定的用户。
syncthing_manage_user:
# 如果要从远程主机获取Syncthing配置,请将此设置为true,
# 详细信息请参见示例剧本部分。
syncthing_fetch_config:
# 获取的文件将写入的位置。
syncthing_fetch_dir:
# 配置文件内容
syncthing_config_cert:
syncthing_config_key:
syncthing_config_https_cert:
syncthing_config_https_key:
syncthing_config_config:
依赖
没有。
示例剧本
# 安装Syncthing
- hosts: servers
roles:
- { role: l-p.syncthing }
Syncthing配置是动态的,通过GUI在运行时进行编辑。
如果您希望保留配置并确保下次运行角色时服务器的配置,您需要从主机获取配置,并将其写入 syncthing_config_*
变量。
如果在再次运行角色之前未获取配置,所有新设备/文件夹/配置将从远程主机中删除。
如果您不设置 syncthing_config_*
变量,则不会覆盖任何内容,
但如果服务器发生故障,您将丢失配置。
# 获取生成的配置
- hosts: servers
roles:
- { role: l-p.syncthing, syncthing_fetch_config: true }
您可以使用 lookup
来读取文件并设置变量:
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')}}"
建议使用 ansible-vault
来加密密钥,lookup
将实时解密它们。
许可证
MIT