aboutsummaryrefslogtreecommitdiff
path: root/roles/seafile_non_docker/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/seafile_non_docker/tasks')
-rw-r--r--roles/seafile_non_docker/tasks/main.yaml220
1 files changed, 220 insertions, 0 deletions
diff --git a/roles/seafile_non_docker/tasks/main.yaml b/roles/seafile_non_docker/tasks/main.yaml
new file mode 100644
index 0000000..597c389
--- /dev/null
+++ b/roles/seafile_non_docker/tasks/main.yaml
@@ -0,0 +1,220 @@
+# https://seafile.readthedocs.io/en/latest/config/seafile/seadav/#seafdav-configuration
+# https://manual.seafile.com/deploy/using_sqlite/
+# https://manual.seafile.com/deploy/using_sqlite/#setup-in-non-interactive-way
+# https://manual.seafile.com/deploy/deploy_with_nginx
+# https://manual.seafile.com/deploy/deploy_seahub_at_non-root_domain/
+# https://seafile.readthedocs.io/en/latest/installation/seafile/#enable-seafile-server-autostart-systemd
+---
+
+- name: 'install required apt packages'
+ apt:
+ name:
+ - 'libmemcached-dev'
+ - 'memcached'
+ - 'pwgen'
+ - 'python3'
+ - 'python3-setuptools'
+ - 'python3-pip'
+ - 'sqlite3'
+ - 'libopenjp2-7'
+ - 'libtiff5'
+ state: 'present'
+ update_cache: true
+
+- name: 'install required pip packages'
+ become_user: '{{ seafile_user_grp }}'
+ pip:
+ name:
+ - 'captcha'
+ - 'django==2.2.*'
+ - 'django-pylibmc'
+ - 'django-simple-captcha'
+ - 'future'
+ - 'jinja2'
+ - 'Pillow'
+ - 'psd-tools'
+ - 'pylibmc'
+ - 'pexpect'
+ state: 'present'
+
+- name: 'create seafile installation and data directories'
+ file:
+ path: '{{ item.path }}'
+ state: 'directory'
+ owner: '{{ item.owner }}'
+ group: '{{ item.group }}'
+ mode: '{{ item.mode }}'
+ loop:
+ - {path: '{{ seafile_install_dir }}/installed', owner: '{{ seafile_user_grp }}', group: '{{ seafile_user_grp }}', mode: '775'}
+ - {path: '{{ seafile_data_dir }}', owner: '{{ ansible_user }}', group: '{{ ansible_user }}', mode: '755'}
+
+- name: 'download seafile package to local folder'
+ become_user: '{{ seafile_user_grp }}'
+ get_url:
+ url: '{{ seafile_download_url }}'
+ dest: '{{ seafile_install_dir }}/installed/seafile-{{ seafile_version }}.tar.gz'
+ mode: '644'
+ register: '_download_archive'
+ until: '_download_archive is succeeded'
+ retries: 5
+ delay: 2
+ check_mode: false
+
+- name: 'unpack seafile binaries'
+ become_user: '{{ seafile_user_grp }}'
+ unarchive:
+ src: '{{ seafile_install_dir }}/installed/seafile-{{ seafile_version }}.tar.gz'
+ dest: '{{ seafile_install_dir }}'
+ remote_src: true
+ creates: '{{ seafile_install_dir }}/seafile-server-{{ seafile_version }}'
+ check_mode: false
+
+# this hack is needed for this version only
+- name: 'Remove old PIL dir'
+ become_user: '{{ seafile_user_grp }}'
+ file:
+ path: '{{ seafile_install_dir }}/seafile-server-{{ seafile_version }}/seahub/thirdpart/PIL'
+ state: 'absent'
+ when: '"buster" in seafile_download_url'
+
+# RUN NON-INTERACTIVELY
+- name: 'Run setup script' # noqa no-changed-when command-instead-of-shell
+ become_user: '{{ seafile_user_grp }}'
+ shell: './setup-seafile.sh auto -n "{{ inventory_hostname }}" -i "0.0.0.0"'
+ args:
+ executable: '/bin/bash'
+ chdir: '{{ seafile_install_dir }}/seafile-server-{{ seafile_version }}'
+ creates: '{{ seafile_install_dir }}/conf/ccnet.conf'
+
+- name: 'Get stats of the data object'
+ stat:
+ path: '{{ seafile_install_dir }}/seafile-data'
+ register: sym
+
+- block:
+ - name: 'Ensure Seafile is not running yet' # noqa command-instead-of-shell
+ become_user: '{{ seafile_user_grp }}'
+ shell: './seafile.sh stop'
+ args:
+ executable: '/bin/bash'
+ chdir: '{{ seafile_install_dir }}/seafile-server-{{ seafile_version }}'
+
+ - name: 'Move old data to new data' # noqa risky-file-permissions
+ become_user: '{{ seafile_user_grp }}'
+ copy:
+ src: '{{ seafile_install_dir }}/seafile-data/'
+ dest: '{{ seafile_data_dir }}'
+ remote_src: true
+
+ - name: 'Delete old data dir'
+ become_user: '{{ seafile_user_grp }}'
+ file:
+ path: '{{ seafile_install_dir }}/seafile-data'
+ state: 'absent'
+
+ - name: 'Create symlink to new data dir'
+ become_user: '{{ seafile_user_grp }}'
+ file:
+ src: '{{ seafile_data_dir }}'
+ dest: '{{ seafile_install_dir }}/seafile-data'
+ state: 'link'
+ when: sym.stat.islnk is defined and (not sym.stat.islnk) # => first time setup
+
+- name: 'Copy conf files'
+ become_user: '{{ seafile_user_grp }}'
+ template:
+ src: '{{ item }}.j2'
+ dest: '{{ seafile_install_dir }}/conf/{{ item }}'
+ mode: '644'
+ loop:
+ - 'ccnet.conf'
+ - 'seafdav.conf'
+ notify:
+ - 'seafile restart'
+ - 'seahub restart'
+
+- name: 'Update gunicorn conf'
+ lineinfile:
+ path: '{{ seafile_install_dir }}/conf/gunicorn.conf.py'
+ regexp: '^bind'
+ line: 'bind = "127.0.0.1:8000"'
+ notify:
+ - 'seahub restart'
+
+# some stuff needed for nginx based install
+- name: 'Update seahub_settings.py'
+ become_user: '{{ seafile_user_grp }}'
+ blockinfile:
+ path: '{{ seafile_install_dir }}/conf/seahub_settings.py'
+ insertafter: '^SECRET_KEY'
+ block: |
+ DEBUG = False
+ FILE_SERVER_ROOT = 'https://{{ seafile_domain }}/seafhttp'
+ SERVE_STATIC = False
+ MEDIA_URL = '/seafmedia/'
+ COMPRESS_URL = MEDIA_URL
+ STATIC_URL = MEDIA_URL + 'assets/'
+ SITE_ROOT = '/files/'
+ LOGIN_URL = '/files/accounts/login/'
+ notify:
+ - 'seahub restart'
+
+- block:
+ - name: 'Run Seafile start script' # noqa command-instead-of-shell
+ become_user: '{{ seafile_user_grp }}'
+ shell: './seafile.sh start'
+ args:
+ executable: '/bin/bash'
+ chdir: '{{ seafile_install_dir }}/seafile-server-{{ seafile_version }}'
+
+ - name: 'Init Seahub with a user'
+ become_user: '{{ seafile_user_grp }}'
+ expect:
+ command: './seahub.sh start'
+ chdir: '{{ seafile_install_dir }}/seafile-server-{{ seafile_version }}'
+ responses:
+ (?i)email: "{{ seafile_user_email }}"
+ (?i)password: "{{ seafile_user_password }}"
+
+ when: sym.stat.islnk is defined and (not sym.stat.islnk) # => first time setup
+
+- name: 'Create systemd services'
+ template:
+ src: '{{ item }}.j2'
+ dest: '/etc/systemd/system/{{ item }}'
+ mode: '644'
+ loop:
+ - 'seafile.service'
+ - 'seahub.service'
+ notify:
+ - 'seafile restart'
+ - 'seahub restart'
+
+- name: 'Reload systemd units'
+ systemd:
+ daemon_reload: true
+
+- block:
+ - name: 'Run Seahub start script' # noqa command-instead-of-shell
+ become_user: '{{ seafile_user_grp }}'
+ shell: './seahub.sh stop'
+ args:
+ executable: '/bin/bash'
+ chdir: '{{ seafile_install_dir }}/seafile-server-{{ seafile_version }}'
+
+ - name: 'Run Seafile stop script' # noqa command-instead-of-shell
+ become_user: '{{ seafile_user_grp }}'
+ shell: './seafile.sh stop'
+ args:
+ executable: '/bin/bash'
+ chdir: '{{ seafile_install_dir }}/seafile-server-{{ seafile_version }}'
+ when: sym.stat.islnk is defined and (not sym.stat.islnk) # => first time setup
+
+- name: 'Start Seafile and Seahub'
+ systemd:
+ name: '{{ item }}'
+ state: 'started'
+ enabled: true
+ loop:
+ - 'seafile'
+ - 'seahub'