main.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ---
  2. - name: Fetched syncthing release
  3. shell:
  4. chdir: /tmp
  5. cmd: fetch https://github.com/syncthing/syncthing/releases/download/v1.21.0/syncthing-freebsd-amd64-v1.21.0.tar.gz
  6. - name: Unpacked syncthing release
  7. shell:
  8. chdir: /tmp
  9. cmd: tar zxf syncthing-freebsd-amd64-v1.21.0.tar.gz
  10. - name: Syncthing installed
  11. shell:
  12. chdir: /tmp/syncthing-freebsd-amd64-v1.21.0
  13. cmd: "cp syncthing /usr/local/bin/syncthing & cp etc/freebsd-rc/syncthing /usr/local/etc/rc.d/syncthing & chmod +x /usr/local/etc/rc.d/syncthing"
  14. warn: false
  15. - name: Syncthing enabled
  16. shell: sysrc syncthing_enable="YES"
  17. - name: Syncthing group set to wheel
  18. shell: sysrc syncthing_group="wheel"
  19. - name: Syncthing user set to root
  20. shell: sysrc syncthing_group="root"
  21. - name: Ensure syncthing is running
  22. service: name=syncthing state=started
  23. - name: Syncthing enabled on all interfaces
  24. shell:
  25. cmd: "sed -i -e '/^ <address>127.0.0.1:8384/s/127.0.0.1/0.0.0.0/' /usr/local/etc/syncthing/config.xml"
  26. warn: false
  27. notify: Syncthing restarted
  28. - name: Syncthing TLS enabled
  29. shell:
  30. cmd: 'sed -i -e ''/^ <gui/s/tls="false"/tls="true"/'' /usr/local/etc/syncthing/config.xml'
  31. warn: false
  32. notify: Syncthing restarted
  33. - name: Syncthing password protected user
  34. ansible.builtin.lineinfile:
  35. path: /usr/local/etc/syncthing/config.xml
  36. insertafter: "^ <address>0.0.0.0:8384</address>"
  37. line: " <user>admin</user>"
  38. notify: Syncthing restarted
  39. - name: Syncthing password protected pass
  40. ansible.builtin.lineinfile:
  41. path: /usr/local/etc/syncthing/config.xml
  42. insertafter: "^ <address>0.0.0.0:8384</address>"
  43. line: " <password>{{ syncthing_admin_pass }}</password>"
  44. notify: Syncthing restarted
  45. - name: Syncthing disable fsWatcher
  46. shell:
  47. cmd: 'sed -i -e ''s/fsWatcherEnabled="true"/fsWatcherEnabled="false"/'' /usr/local/etc/syncthing/config.xml'
  48. warn: false
  49. notify: Syncthing restarted
  50. - name: Ensure syncthing is restarted
  51. service: name=syncthing state=restarted