diff --git a/group_vars/all b/group_vars/all index e2e63b0..e530ee8 100644 --- a/group_vars/all +++ b/group_vars/all @@ -242,3 +242,6 @@ aur_fonts: - ttf-caladea - ttf-courier-prime - ttf-heuristica + +syncthing: + run_on: trusted diff --git a/playbook.yml b/playbook.yml index 9cbc6ad..c76f292 100644 --- a/playbook.yml +++ b/playbook.yml @@ -72,6 +72,7 @@ - { role: hostsctl, tags: ['hostsctl'], when: "hostsctl is defined" } - { role: himawaripy, tags: ['himawaripy'], when: "himawaripy is defined" } - { role: kiwix, tags: ['kiwix'] } + - { role: syncthing, tags: ['syncthing'], when: "syncthing is defined" } vars_prompt: - name: user_password prompt: "Enter desired user password" diff --git a/roles/syncthing/tasks/main.yml b/roles/syncthing/tasks/main.yml new file mode 100644 index 0000000..4837f69 --- /dev/null +++ b/roles/syncthing/tasks/main.yml @@ -0,0 +1,31 @@ +--- +- name: Install syncthing + pacman: name=syncthing state=present + +- name: Enable and start syncthing service + systemd: name=syncthing.service user=yes enabled=yes state=started + become: yes + become_user: "{{ user.name }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}" + when: syncthing.run_on == "all" + +- name: Remove syncthing from trusted unit list + lineinfile: dest=/usr/local/etc/trusted_units + state=absent + line="syncthing.service,user:{{ user.name }}" + when: syncthing.run_on == "all" + +- name: Disable syncthing service + systemd: name=syncthing.service user=yes enabled=no + become: yes + become_user: "{{ user.name }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ user.uid }}" + when: syncthing.run_on == "trusted" + +- name: Add syncthing to trusted unit list + lineinfile: dest=/usr/local/etc/trusted_units + state=present + line="syncthing.service,user:{{ user.name }}" + when: syncthing.run_on == "trusted"