From d61fc21f3286cab88d0d6357b51ea19129b0f3fd Mon Sep 17 00:00:00 2001 From: pizzaniels Date: Thu, 12 Jan 2023 23:44:54 +0100 Subject: [PATCH] added Seafile. todo: traefik --- Makefile | 3 ++ playbooks/all.yml | 1 + playbooks/seafile.yml | 4 ++ roles/seafile/meta/main.yml | 4 ++ roles/seafile/tasks/main.yml | 17 +++++++ roles/seafile/templates/docker-compose.yml.j2 | 44 +++++++++++++++++++ roles/seafile/vars/main.yml | 22 ++++++++++ 7 files changed, 95 insertions(+) create mode 100644 playbooks/seafile.yml create mode 100644 roles/seafile/meta/main.yml create mode 100644 roles/seafile/tasks/main.yml create mode 100644 roles/seafile/templates/docker-compose.yml.j2 create mode 100644 roles/seafile/vars/main.yml diff --git a/Makefile b/Makefile index 8dee827..3af1ce8 100644 --- a/Makefile +++ b/Makefile @@ -34,4 +34,7 @@ borg: dataserver: ansible-playbook playbooks/dataserver.yml -i inventory/hosts.yml --ask-vault-pass +seafile: + ansible-playbook playbooks/seafile.yml -i inventory/hosts.yml --ask-vault-pass + .PHONY: run diff --git a/playbooks/all.yml b/playbooks/all.yml index 417dab6..8bb6cc8 100644 --- a/playbooks/all.yml +++ b/playbooks/all.yml @@ -10,6 +10,7 @@ - forgejo - radicale - mastodon + - seafile - name: Setup dataserver hosts: dataserver roles: diff --git a/playbooks/seafile.yml b/playbooks/seafile.yml new file mode 100644 index 0000000..54af9df --- /dev/null +++ b/playbooks/seafile.yml @@ -0,0 +1,4 @@ +- name: Install Seafile + hosts: homeserver + roles: + - seafile diff --git a/roles/seafile/meta/main.yml b/roles/seafile/meta/main.yml new file mode 100644 index 0000000..6b03734 --- /dev/null +++ b/roles/seafile/meta/main.yml @@ -0,0 +1,4 @@ +dependencies: + - role: common + - role: docker + - role: traefik diff --git a/roles/seafile/tasks/main.yml b/roles/seafile/tasks/main.yml new file mode 100644 index 0000000..1ebcd83 --- /dev/null +++ b/roles/seafile/tasks/main.yml @@ -0,0 +1,17 @@ +- name: Create Seafile app directory + file: + path: "{{ service_dir }}" + state: directory +- name: Copy Docker Compose script + template: + src: "{{ role_path }}/templates/docker-compose.yml.j2" + dest: "{{ service_dir }}/docker-compose.yml" +- name: Create data directory + file: + path: "{{ data_dir }}" + state: directory +- name: Start Docker Compose + docker_compose: + project_src: "{{ service_dir }}" + pull: true + remove_orphans: true diff --git a/roles/seafile/templates/docker-compose.yml.j2 b/roles/seafile/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..13b169b --- /dev/null +++ b/roles/seafile/templates/docker-compose.yml.j2 @@ -0,0 +1,44 @@ +version: '2.0' +services: + db: + image: mariadb:10.5 + container_name: seafile-mysql + restart: always + environment: + - MYSQL_ROOT_PASSWORD={{ db_root_passwd }} # Requested, set the root's password of MySQL service. + - MYSQL_LOG_CONSOLE=true + volumes: + - {{ data_dir }}/db:/var/lib/mysql # Requested, specifies the path to MySQL data persistent store. + networks: + - default + + memcached: + image: memcached:1.6 + container_name: seafile-memcached + restart: always + entrypoint: memcached -m 256 + networks: + - default + + seafile: + image: seafileltd/seafile-mc:9.0.10 + container_name: seafile + restart: always + ports: + - "81:80" +# - "443:443" # If https is enabled, cancel the comment. + volumes: + - {{ data_dir }}/data:/shared # Requested, specifies the path to Seafile data persistent store. + environment: + - DB_HOST=db + - DB_ROOT_PASSWD={{ db_root_passwd }} # Requested, the value shuold be root's password of MySQL service. + - TIME_ZONE=Europe/Amsterdam + - SEAFILE_ADMIN_EMAIL={{ seafile_admin_email }} # Specifies Seafile admin user, default is 'me@example.com'. + - SEAFILE_ADMIN_PASSWORD={{ seafile_admin_password }} # Specifies Seafile admin password. + - SEAFILE_SERVER_LETSENCRYPT=false # Whether to use https or not. + - SEAFILE_SERVER_HOSTNAME={{ seafile_domain }} # Specifies your host name if https is enabled. + depends_on: + - db + - memcached + networks: + - default \ No newline at end of file diff --git a/roles/seafile/vars/main.yml b/roles/seafile/vars/main.yml new file mode 100644 index 0000000..b5788da --- /dev/null +++ b/roles/seafile/vars/main.yml @@ -0,0 +1,22 @@ +service_name: seafile +data_dir: "{{ base_data_dir }}/{{ service_name }}" +service_dir: "{{ base_service_dir }}/{{ service_name }}" + +db_root_passwd: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 62376163363033396161363264613836623734623835316439666331356464636633393237313236 + 3731383961393939366165393537663435356166643966650a353132616166353630333733636639 + 63616163346566336461313264326562393964643661613831316233326165623463613865636637 + 6363363331333430320a366661356232393036383765353066623334656133313661636130666238 + 32336561323431303730373262343534326539383932613533623232376330646230363363636135 + 3266336663623037663838643936366437663831356634333930 +seafile_admin_email: niels@kunis.nl +seafile_admin_password: !vault | + $ANSIBLE_VAULT;1.1;AES256 + 34366163396632343065636232363435633039373236363461383563363162626561653763383438 + 3263393539663030363532353238633262616339343436370a613631323064303637623266653832 + 64323834356664316265376132633863666136316239623862643962366637306238343933386134 + 6237396238383232360a386637303639646136653134643737393735383661626539386134643333 + 35313536323963303734353338636162666236343430623062373464653531353230366238326231 + 6661363038393534373861643261383561386536613337396539 +seafile_domain: files.geokunis2.nl \ No newline at end of file