[mountain-of-faith] syncthing
change wosrtulzxrmmtyurnvzlmxsqzwlrtkvk
commit 1235b4cd62e62c9a662bc4aa4f0a3574cf990140
author Alpha Chen <alpha@kejadlen.dev>
date
parent lumpxvyq
diff --git a/mountain-of-faith/README.md b/mountain-of-faith/README.md
index 283c3e9..4eb8998 100644
--- a/mountain-of-faith/README.md
+++ b/mountain-of-faith/README.md
@@ -14,5 +14,8 @@ ansible-playbook -l mountain-of-faith mountain-of-faith/main.yml
 
 ```sh
 mc alias set minio http://mountain-of-faith:9000 root $MINIO_PASSWORD
+
+# arq
+mc mb minio/arq
 mc admin accesskey create minio root --policy mountain-of-faith/minio/arq.json
 ```
diff --git a/mountain-of-faith/main.yml b/mountain-of-faith/main.yml
index a969517..be4cdcb 100644
--- a/mountain-of-faith/main.yml
+++ b/mountain-of-faith/main.yml
@@ -12,6 +12,14 @@
       loop:
         - chromium
 
+    - name: Install things
+      ansible.builtin.apt:
+        name: "{{ item }}"
+        state: present
+        update_cache: true
+      loop:
+        - neovim
+
     - name: Update all packages to their latest version
       ansible.builtin.apt:
         name: "*"
@@ -116,10 +124,9 @@
         state: started
 
 - import_playbook: minio.yml
+- import_playbook: syncthing.yml
 
-# TODO smokeping
-# TODO syncthing
-
-- import_playbook: caddy.yml
+# TODO smokeping (or blackbox_exporter?)
+# TODO caddy?
 
 # vim: ft=yaml.ansible
diff --git a/mountain-of-faith/minio/restic.json b/mountain-of-faith/minio/restic.json
new file mode 100644
index 0000000..fbe5772
--- /dev/null
+++ b/mountain-of-faith/minio/restic.json
@@ -0,0 +1,15 @@
+{
+  "Version": "2012-10-17",
+  "Statement": [
+    {
+      "Effect": "Allow",
+      "Action": [
+        "s3:*"
+      ],
+      "Resource": [
+        "arn:aws:s3:::restic",
+        "arn:aws:s3:::restic/*"
+      ]
+    }
+  ]
+}
diff --git a/mountain-of-faith/syncthing.yml b/mountain-of-faith/syncthing.yml
new file mode 100644
index 0000000..1cf68a2
--- /dev/null
+++ b/mountain-of-faith/syncthing.yml
@@ -0,0 +1,77 @@
+# https://apt.syncthing.net/
+
+- name: Install Syncthing
+  tags: syncthing
+  hosts: mountain-of-faith
+  become: true
+  tasks:
+
+    - name: Assert distribution is Debian
+      ansible.builtin.assert:
+        that:
+          - ansible_distribution == "Debian"
+        fail_msg: "This playbook only supports Debian distributions"
+
+    # sudo mkdir -p /etc/apt/keyrings
+    # sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
+    - name: Add Syncthing GPG key
+      ansible.builtin.apt_key:
+        url: https://syncthing.net/release-key.gpg
+        state: present
+
+    # echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
+    - name: Add Syncthing repository
+      ansible.builtin.apt_repository:
+        repo: deb https://apt.syncthing.net/ syncthing stable
+        state: present
+
+    # sudo apt-get update
+    # sudo apt-get install syncthing
+    - name: Install Syncthing
+      ansible.builtin.apt:
+        name: syncthing
+        state: present
+        update_cache: true
+
+    - name: Create Syncthing group
+      ansible.builtin.group:
+        name: syncthing
+        system: true
+        state: present
+
+    - name: Create Syncthing user
+      ansible.builtin.user:
+        name: syncthing
+        group: syncthing
+        system: true
+
+    - name: Create Syncthing data directory
+      ansible.builtin.file:
+        path: /mnt/mountain-of-faith/syncthing
+        state: directory
+        owner: syncthing
+        group: syncthing
+        mode: "0755"
+
+    - name: Enable and start Syncthing service
+      ansible.builtin.systemd:
+        name: syncthing@syncthing.service
+        enabled: true
+        state: started
+        daemon_reload: true
+
+    - name: Update GUI listen address in config.xml
+      ansible.builtin.lineinfile:
+        path: /home/syncthing/.local/state/syncthing/config.xml
+        regexp: '^\s*<address>.*:8384</address>'
+        line: '        <address>0.0.0.0:8384</address>'
+        backup: true
+      notify: restart syncthing
+
+  handlers:
+    - name: restart syncthing
+      ansible.builtin.systemd:
+        name: syncthing@syncthing.service
+        state: restarted
+
+# vim: ft=yaml.ansible