Files
seafile-mirror-ansible/tasks/main.yml

80 lines
2.0 KiB
YAML
Raw Normal View History

2023-05-26 11:11:15 +02:00
# SPDX-FileCopyrightText: 2023 Max Mehl <https://mehl.mx>
#
# SPDX-License-Identifier: Apache-2.0
2023-05-26 11:04:55 +02:00
---
- name: Ensure local seafile user is configured correctly
include_role:
name: users
apply:
become: false
vars:
username: "{{ seafile_local_user.user }}"
password: "{{ seafile_local_user.pass | default('') }}"
- name: Ensure requirements are installed
apt:
name:
- moreutils # chronic
- pipx
2023-05-26 11:04:55 +02:00
- seafile-cli
become: false # need to do this as root
- name: Define directory for Seafile mirror service as fact
set_fact:
2025-04-03 14:57:59 +02:00
seafile_mirror_dir: "~/seafile_mirror"
2023-05-26 11:04:55 +02:00
- name: Ensure directory for Seafile mirror service exists
file:
path: "{{ seafile_mirror_dir }}"
2023-05-26 11:04:55 +02:00
state: directory
2023-12-13 20:16:52 +01:00
mode: "0755"
2023-05-26 11:04:55 +02:00
recurse: true
- name: Ensure Seafile mirror configuration exists
template:
src: seafile_mirror.conf.yaml.j2
dest: "{{ seafile_mirror_dir }}/seafile_mirror.conf.yaml"
2023-12-13 20:16:52 +01:00
mode: "0600"
2023-05-26 11:04:55 +02:00
- name: Ensure log file with user permissions exists
file:
path: /var/log/seafile-mirror.log
state: touch
mode: "0644"
owner: "{{ seafile_local_user.user }}"
group: "{{ seafile_local_user.user }}"
become: false
2023-05-26 11:04:55 +02:00
- name: Ensure cron entry for Seafile mirror service
cron:
name: Seafile Mirror Service
job: "chronic pipx run seafile-mirror -c {{ seafile_mirror_dir }} -l /var/log/seafile-mirror.log"
2024-11-18 10:45:10 +01:00
minute: "{{ seafile_cron.minute }}"
hour: "{{ seafile_cron.hour }}"
day: "{{ seafile_cron.day }}"
month: "{{ seafile_cron.month }}"
weekday: "{{ seafile_cron.weekday }}"
2023-05-26 11:04:55 +02:00
- name: Ensure Seafile config dir exists
file:
2025-04-03 14:57:59 +02:00
path: "~/config"
2023-05-26 11:04:55 +02:00
state: directory
2023-12-13 20:16:52 +01:00
mode: "0755"
2023-05-26 11:04:55 +02:00
- name: Ensure Seafile config dir is initialised
command:
2025-04-03 14:57:59 +02:00
cmd: seaf-cli init -d "~/config"
2023-05-26 11:04:55 +02:00
register: result
changed_when: '"already exists" not in result.stdout'
- name: Setup systemd user service
include_role:
name: systemd-user
apply:
become: false
vars:
user: "{{ seafile_local_user.user }}"
service: seaf-daemon
2025-04-03 14:57:59 +02:00
copy_file: seaf-daemon.service