diff --git a/.ansible/roles/media_server/files/clonedrive.service b/.ansible/roles/media_server/files/clonedrive.service deleted file mode 100644 index ca0ab41..0000000 --- a/.ansible/roles/media_server/files/clonedrive.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Clonedrive service -After=network.target -StartLimitIntervalSec=0 - -[Service] -Type=simple -Restart=always -RestartSec=60 -User=media -Group=media -ExecStart=/srv/app/clonedrive/clonedrive.py - -[Install] -WantedBy=multi-user.target diff --git a/.ansible/roles/media_server/files/cloudplow.service b/.ansible/roles/media_server/files/cloudplow.service index e777156..bf98758 100644 --- a/.ansible/roles/media_server/files/cloudplow.service +++ b/.ansible/roles/media_server/files/cloudplow.service @@ -1,6 +1,7 @@ [Unit] Description=cloudplow -After=network-online.target +After=mnt-media.mount +Requires=mnt-media.mount [Service] User=media diff --git a/.ansible/roles/media_server/files/cloudplow_config.json b/.ansible/roles/media_server/files/cloudplow_config.json index 802fb1b..214a75b 100644 --- a/.ansible/roles/media_server/files/cloudplow_config.json +++ b/.ansible/roles/media_server/files/cloudplow_config.json @@ -2,7 +2,7 @@ "core": { "dry_run": false, "rclone_binary_path": "/usr/bin/rclone", - "rclone_config_path": "/srv/etc/rclone.conf" + "rclone_config_path": "/srv/etc/rclone/rclone.conf" }, "hidden": { "/mnt/.media.cache/.unionfs": { diff --git a/.ansible/roles/media_server/tasks/main.yaml b/.ansible/roles/media_server/tasks/main.yaml index b0a10f9..2316277 100644 --- a/.ansible/roles/media_server/tasks/main.yaml +++ b/.ansible/roles/media_server/tasks/main.yaml @@ -5,7 +5,6 @@ - name: "Media Server: Group" tags: - install - - clonedrive - cloudplow group: name: "media" @@ -14,7 +13,6 @@ - name: "Media Server: User" tags: - install - - clonedrive - cloudplow user: name: "media" @@ -23,22 +21,6 @@ expires: -1 become: yes - - name: "Media Server: Mountpoints" - tags: - - install - - clonedrive - file: - path: "{{ item }}" - state: directory - owner: "media" - group: "media" - loop: - - "/mnt/media" - - "/mnt/GoogleDriveCrypt" - - "/mnt/.media.cache" - - "/mnt/.overlay.work" - become: yes - - name: "Media Server: Cloudplow: git repo" tags: - install @@ -61,27 +43,6 @@ recurse: yes become: yes - - name: "Media Server: Clonedrive: git repo" - tags: - - install - - clonedrive - git: - repo: "https://github.com/scottwallacesh/clonedrive.git" - dest: "/srv/app/clonedrive" - become: yes - - - name: "Media Server: Clonedrive: directory" - tags: - - install - - clonedrive - file: - path: "/srv/app/clonedrive" - state: directory - mode: "0755" - owner: "media" - group: "media" - become: yes - - name: "Media Server: Cloudplow: config" tags: - config @@ -94,37 +55,6 @@ group: "media" become: yes - - name: "Media Server: Configuration: sudoers" - tags: - - config - - clonedrive - copy: - dest: "/etc/sudoers.d/media_clonedrive" - content: "media ALL = NOPASSWD: /usr/bin/mount,/usr/bin/umount\n" - mode: "0440" - become: yes - - - name: "Media Server: Clonedrive: service config" - tags: - - install - - clonedrive - copy: - dest: "/etc/systemd/system/clonedrive.service" - src: "files/clonedrive.service" - mode: "0644" - become: yes - - - name: "Media Server: Clonedrive: service" - tags: - - config - - clonedrive - systemd: - name: "clonedrive" - state: started - enabled: yes - daemon_reload: yes - become: yes - - name: "Media Server: Cloudplow: Python dependencies" tags: - install diff --git a/.ansible/roles/rclone_mount/files/mnt-media.mount b/.ansible/roles/rclone_mount/files/mnt-media.mount new file mode 100644 index 0000000..a401e81 --- /dev/null +++ b/.ansible/roles/rclone_mount/files/mnt-media.mount @@ -0,0 +1,10 @@ +[Unit] +Before=local-fs.target +After=rclone.service +Requires=rclone.service + +[Mount] +Where=/mnt/media +What=overlay +Type=overlay +Options=rw,relatime,lowerdir=/mnt/GoogleDriveCrypt,upperdir=/mnt/.media.cache,workdir=/mnt/.overlay.work diff --git a/.ansible/roles/rclone_mount/files/rclone.service b/.ansible/roles/rclone_mount/files/rclone.service new file mode 100644 index 0000000..b96b461 --- /dev/null +++ b/.ansible/roles/rclone_mount/files/rclone.service @@ -0,0 +1,29 @@ +[Unit] +Description=Google Drive (rclone) +AssertPathIsDirectory=/mnt/GoogleDriveCrypt +Requires=systemd-networkd.service +Wants=network-online.target +After=network-online.target +Before=mnt-media.mount + +[Service] +Type=simple +ExecStart=/usr/bin/rclone mount \ + --config=/srv/etc/rclone/rclone.conf \ + --allow-other \ + --no-modtime \ + --read-only \ + --dir-cache-time=240m \ + --tpslimit=10 \ + --tpslimit-burst=1 \ + --buffer-size=1G \ + GoogleDriveCrypt:/ /mnt/GoogleDriveCrypt +ExecStartPost=/bin/bash -c 'while [ ! -d /mnt/GoogleDriveCrypt/_Other ]; do /usr/bin/sleep 5; done' +ExecStop=/bin/fusermount -u /mnt/GoogleDriveCrypt +Restart=always +RestartSec=10 +User=media +Group=media + +[Install] +WantedBy=multi-user.target diff --git a/.ansible/roles/rclone_mount/tasks/main.yaml b/.ansible/roles/rclone_mount/tasks/main.yaml index 6f18c35..67ac8ca 100644 --- a/.ansible/roles/rclone_mount/tasks/main.yaml +++ b/.ansible/roles/rclone_mount/tasks/main.yaml @@ -3,6 +3,21 @@ tags: - rclone block: + - name: "Rclone: Mountpoints" + tags: + - install + file: + path: "{{ item }}" + state: directory + owner: "media" + group: "media" + loop: + - "/mnt/media" + - "/mnt/GoogleDriveCrypt" + - "/mnt/.media.cache" + - "/mnt/.overlay.work" + become: yes + - name: "Rclone: Packages" tags: - install @@ -31,3 +46,42 @@ regexp: "^#?user_allow_other" line: "user_allow_other" become: yes + + - name: "Rclone: Install: rclone service" + tags: + - install + copy: + dest: "/etc/systemd/system/rclone.service" + src: "files/rclone.service" + owner: "root" + group: "root" + mode: "0444" + become: yes + + - name: "Rclone: Configure: rclone service" + tags: + - config + systemd: + name: rclone + enabled: yes + state: started + become: yes + + - name: "Rclone: Install:/mnt/media mount" + tags: + - install + copy: + dest: "/etc/systemd/system/mnt-media.mount" + src: "files/mnt-media.mount" + owner: "root" + group: "root" + mode: "0444" + become: yes + + - name: "Rclone: Configure: /mnt/media mount" + tags: + - config + systemd: + name: mnt-media.mount + state: started + become: yes