aboutsummaryrefslogtreecommitdiffstats
path: root/roles/setup_syncthing/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/setup_syncthing/tasks')
-rw-r--r--roles/setup_syncthing/tasks/main.yml131
1 files changed, 131 insertions, 0 deletions
diff --git a/roles/setup_syncthing/tasks/main.yml b/roles/setup_syncthing/tasks/main.yml
new file mode 100644
index 0000000..431f27f
--- /dev/null
+++ b/roles/setup_syncthing/tasks/main.yml
@@ -0,0 +1,131 @@
+
+# =========================================================================== #
+# __ __ __ _
+# _________ / /__ _______ ______ _____/ /_/ /_ (_)___ ____ _
+# / ___/ __ \/ / _ \ / ___/ / / / __ \/ ___/ __/ __ \/ / __ \/ __ `/
+# / / / /_/ / / __/ (__ ) /_/ / / / / /__/ /_/ / / / / / / / /_/ /
+# /_/ \____/_/\___(_) /____/\__, /_/ /_/\___/\__/_/ /_/_/_/ /_/\__, /
+# /____/ /____/
+#
+# =========================================================================== #
+
+---
+- name: Add group syncthing
+ group:
+ name: "{{ syncthing_user }}"
+ state: present
+
+- name: Add user syncthing
+ user:
+ name: "{{ syncthing_user }}"
+ comment: "{{ syncthing_group }}"
+ group: "{{ syncthing_group }}"
+
+- name: Create syncthing bin directory
+ file:
+ path: "{{ syncthing_bin_directory }}"
+ state: directory
+ owner: "{{ syncthing_user }}"
+ group: "{{ syncthing_group }}"
+ mode: 0755
+ recurse: True
+
+- name: Create syncthing sync directory
+ file:
+ path: "{{ syncthing_files_directory }}"
+ state: directory
+ owner: "{{ syncthing_user }}"
+ group: "{{ syncthing_group }}"
+ mode: 0755
+ recurse: True
+
+- name: Download and extract syncthing archive
+ become_user: syncthing
+ unarchive:
+ src: "{{ syncthing_download_url }}/{{ syncthing_version }}/syncthing-{{ syncthing_os }}-{{ syncthing_architecture }}-{{ syncthing_version }}.tar.gz"
+ dest: "{{ syncthing_download_directory }}"
+ remote_src: yes
+
+- name: Copy syncthing bin
+ copy:
+ src: "{{ syncthing_download_directory }}/syncthing-{{ syncthing_os }}-{{ syncthing_architecture }}-{{ syncthing_version }}/syncthing"
+ remote_src: yes
+ dest: "{{ syncthing_bin_directory }}"
+ owner: "{{ syncthing_user }}"
+ group: "{{ syncthing_group }}"
+ mode: 0744
+
+- name: Copy syncthing systemd unit
+ template:
+ src: "{{ syncthing_daemon_unit }}.service"
+ dest: "{{ g_systemd_unit_directory }}"
+ owner: root
+ group: root
+ mode: 0644
+
+- name: Start syncthing systemd unit
+ systemd:
+ name: "{{ syncthing_daemon_unit }}"
+ state: restarted
+ daemon_reload: yes
+
+- name: Stop syncthing systemd unit
+ systemd:
+ name: "{{ syncthing_daemon_unit }}"
+ state: stopped
+
+- name: Config networking
+ xml:
+ path: "{{ syncthing_config_directory }}/config.xml"
+ xpath: /configuration/gui/address
+ value: "0.0.0.0:{{ g_port_syncthing_gui }}"
+
+- name: Config clear directory path
+ xml:
+ path: "{{ syncthing_config_directory }}/config.xml"
+ xpath: "/configuration/folder/@path"
+ state: present
+
+- name: Config directory path
+ replace:
+ path: "{{ syncthing_config_directory }}/config.xml"
+ regexp: "path=\"\""
+ replace: "path=\"{{ syncthing_files_directory }}\""
+
+- name: Config disable relay
+ xml:
+ path: "{{ syncthing_config_directory }}/config.xml"
+ xpath: /configuration/options/relaysEnabled
+ value: "{{ syncthing_b_relays }}"
+
+- name: Config disable global announcements
+ xml:
+ path: "{{ syncthing_config_directory }}/config.xml"
+ xpath: /configuration/options/globalAnnounceEnabled
+ value: "{{ syncthing_b_global_announcements }}"
+
+- name: Config disable nat
+ xml:
+ path: "{{ syncthing_config_directory }}/config.xml"
+ xpath: /configuration/options/natEnabled
+ value: "{{ syncthing_b_nat }}"
+
+- name: Config disable crash reporting
+ xml:
+ path: "{{ syncthing_config_directory }}/config.xml"
+ xpath: /configuration/options/crashReportingEnabled
+ value: "{{ syncthing_b_crash_reporting }}"
+
+- name: Config disable browser autostart
+ xml:
+ path: "{{ syncthing_config_directory }}/config.xml"
+ xpath: /configuration/options/startBrowser
+ value: "{{ syncthing_b_start_browser }}"
+
+- name: Start and enable syncthing systemd unit
+ systemd:
+ name: "{{ syncthing_daemon_unit }}"
+ state: restarted
+ daemon_reload: yes
+ enabled: yes
+
remember that computers suck.