main.yml 2.0 KB

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