main.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. ---
  2. - name: Syncthing installed
  3. community.general.pkgng:
  4. name: syncthing
  5. state: latest
  6. - name: Syncthing enabled
  7. shell: sysrc syncthing_enable="YES"
  8. - name: Syncthing group set to wheel
  9. shell: sysrc syncthing_group="wheel"
  10. - name: Syncthing user set to root
  11. shell: sysrc syncthing_user="root"
  12. - name: Ensure syncthing is running
  13. service: name=syncthing state=started
  14. - name: Syncthing enabled on all interfaces
  15. shell:
  16. 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"
  17. notify: Syncthing restarted
  18. - name: Syncthing TLS enabled
  19. shell:
  20. cmd: 'sed -i -e ''/^ <gui/s/tls="false"/tls="true"/'' /usr/local/etc/syncthing/config.xml'
  21. notify: Syncthing restarted
  22. - name: Syncthing password protected user
  23. ansible.builtin.lineinfile:
  24. path: /usr/local/etc/syncthing/config.xml
  25. insertafter: "^ <address>0.0.0.0:8384</address>"
  26. line: " <user>admin</user>"
  27. notify: Syncthing restarted
  28. - name: Syncthing password protected pass
  29. ansible.builtin.lineinfile:
  30. path: /usr/local/etc/syncthing/config.xml
  31. insertafter: "^ <address>0.0.0.0:8384</address>"
  32. line: " <password>{{ syncthing_admin_pass }}</password>"
  33. notify: Syncthing restarted
  34. - name: Syncthing disable fsWatcher
  35. shell:
  36. cmd: 'sed -i -e ''s/fsWatcherEnabled="true"/fsWatcherEnabled="false"/'' /usr/local/etc/syncthing/config.xml'
  37. notify: Syncthing restarted
  38. - name: Ensure syncthing is restarted
  39. service: name=syncthing state=restarted