You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
213 lines
6.4 KiB
213 lines
6.4 KiB
5 years ago
|
---
|
||
|
|
||
|
- name: Install RPM dependencies
|
||
|
yum:
|
||
|
name:
|
||
|
- python-imaging
|
||
|
- MySQL-python
|
||
|
- python-memcached
|
||
|
- python-ldap
|
||
|
- python-urllib3
|
||
|
- python-virtualenv
|
||
|
- ffmpeg
|
||
|
- ffmpeg-devel
|
||
|
- libmemcached-devel
|
||
|
- mysql-devel
|
||
|
- zlib-devel
|
||
|
- gcc
|
||
|
- tar
|
||
|
- mariadb
|
||
|
- fuse
|
||
|
- java-1.8.0-openjdk # For seafile-pro
|
||
|
- poppler-utils # For seafile-pro
|
||
|
- unoconv # For seafile-pro
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Install or update python modules in the virtualenv
|
||
|
pip:
|
||
|
state: latest
|
||
|
virtualenv: "{{ seafile_root_dir }}"
|
||
|
virtualenv_python: python2.7
|
||
|
name:
|
||
|
- pip
|
||
|
- virtualenv
|
||
|
- pillow
|
||
|
#- moviepy
|
||
|
- pylibmc
|
||
|
- django-pylibmc
|
||
|
- requests_oauthlib
|
||
|
- MySQL-python
|
||
|
notify:
|
||
|
- restart seafile
|
||
|
- restart seahub
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Install Seafile pro license
|
||
|
copy: content={{ seafile_license }} dest={{ seafile_root_dir }}/seafile-license.txt
|
||
|
when: seafile_license is defined
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Download seafile archive
|
||
|
get_url:
|
||
|
url: "{{ seafile_archive_url }}"
|
||
|
dest: "{{ seafile_root_dir }}/tmp/seafile-server_{{ seafile_version }}_x86-64.tar.gz"
|
||
|
checksum: "sha1:{{ seafile_archive_sha1 }}"
|
||
|
when:
|
||
|
- seafile_install_mode != 'none'
|
||
|
- seafile_license is not defined
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Copy Seafile pro archive
|
||
|
copy: src=seafile-pro-server_{{ seafile_version }}_x86-64.tar.gz dest={{ seafile_root_dir }}/tmp/
|
||
|
when:
|
||
|
- seafile_install_mode != 'none'
|
||
|
- seafile_license is defined
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Extract seafile archive
|
||
|
unarchive:
|
||
|
src: "{{ seafile_root_dir }}/tmp/seafile-{{ seafile_license is defined | ternary('pro-','') }}server_{{ seafile_version }}_x86-64.tar.gz"
|
||
|
dest: "{{ seafile_root_dir }}/tmp"
|
||
|
remote_src: yes
|
||
|
when: seafile_install_mode != 'none'
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Move seafile to the correct location
|
||
|
synchronize:
|
||
|
src: "{{ seafile_root_dir }}/tmp/seafile-{{ seafile_license is defined | ternary('pro-','') }}server-{{ seafile_version }}/"
|
||
|
dest: "{{ seafile_root_dir }}/seafile-server/"
|
||
|
recursive: True
|
||
|
delete: True
|
||
|
delegate_to: "{{ inventory_hostname }}"
|
||
|
when: seafile_install_mode != 'none'
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Check if avatar is a dir or a link
|
||
|
stat: path={{ seafile_root_dir }}/seafile-server/seahub/media/avatars
|
||
|
register: seafile_avatar
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Remove default avatar directory
|
||
|
file: path={{ seafile_root_dir }}/seafile-server/seahub/media/avatars state=absent
|
||
|
when: seafile_avatar.stat.isdir is defined and seafile_avatar.stat.isdir
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Create seahub symlinks
|
||
|
file: src={{ seafile_data_dir }}/seahub/{{ item.src }} dest={{ seafile_root_dir }}/seafile-server/seahub/media/{{ item.dest }} state=link force=True
|
||
|
with_items:
|
||
|
- src: custom
|
||
|
dest: custom
|
||
|
- src: cache
|
||
|
dest: CACHE
|
||
|
- src: avatars
|
||
|
dest: avatars
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Create pro-data link
|
||
|
file: src={{ seafile_data_dir }}/pro dest={{ seafile_root_dir }}/pro-data state=link force=True
|
||
|
when: seafile_license is defined
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Set permissions on seahub runtime directory
|
||
|
file: path={{ seafile_root_dir }}/seafile-server/runtime state=directory owner={{ seafile_user }} mode=700
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Create library-template
|
||
|
file: path={{ seafile_data_dir }}/library-template state=directory
|
||
|
when: seafile_install_mode == 'install'
|
||
|
tags: seafile
|
||
|
|
||
|
# Needed since CentOS 7.5 so ldaps can be used
|
||
|
- name: Remove bundled libs
|
||
|
file: path={{ seafile_root_dir }}/seafile-server/seafile/lib/{{ item }} state=absent
|
||
|
with_items:
|
||
|
- libnssutil3.so
|
||
|
notify: restart seafile
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Copy documentation
|
||
|
copy: src={{ seafile_root_dir }}/tmp/seafile-server-{{ seafile_version }}/seafile/docs/seafile-tutorial.doc dest={{ seafile_data_dir }}/library-template remote_src=True
|
||
|
when: seafile_install_mode == 'install'
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Generate a secret for seahub
|
||
|
shell: python2.7 {{ seafile_root_dir }}/seafile-server/seahub/tools/secret_key_generator.py > {{ seafile_root_dir }}/meta/ansible_hub_secret
|
||
|
args:
|
||
|
creates: "{{ seafile_root_dir }}/meta/ansible_hub_secret"
|
||
|
when: seafile_seahub_secret is not defined
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Read seahub secret
|
||
|
command: cat {{ seafile_root_dir }}/meta/ansible_hub_secret
|
||
|
register: seafile_seahub_rand_secret
|
||
|
when: seafile_seahub_secret is not defined
|
||
|
changed_when: False
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Set seahub secret key
|
||
|
set_fact: seafile_seahub_secret={{ seafile_seahub_rand_secret.stdout }}
|
||
|
when: seafile_seahub_secret is not defined
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Create the databases
|
||
|
mysql_db:
|
||
|
name: "{{ item }}"
|
||
|
login_host: "{{ seafile_db_server }}"
|
||
|
login_user: sqladmin
|
||
|
login_password: "{{ mysql_admin_pass }}"
|
||
|
state: present
|
||
|
with_items:
|
||
|
- "{{ seafile_db_seafile }}"
|
||
|
- "{{ seafile_db_ccnet }}"
|
||
|
- "{{ seafile_db_seahub }}"
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Create database user
|
||
|
mysql_user:
|
||
|
name: "{{ seafile_db_user }}"
|
||
|
password: "{{ seafile_db_pass }}"
|
||
|
priv: "{{ seafile_db_seafile }}.*:ALL/{{ seafile_db_ccnet }}.*:ALL/{{ seafile_db_seahub }}.*:ALL"
|
||
|
host: "{{ item }}"
|
||
|
login_host: "{{ seafile_db_server }}"
|
||
|
login_user: sqladmin
|
||
|
login_password: "{{ mysql_admin_pass }}"
|
||
|
state: present
|
||
|
with_items: "{{ (seafile_db_server == '127.0.0.1') | ternary(['127.0.0.1','localhost'],ansible_all_ipv4_addresses) }}"
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Load database schema schema
|
||
|
mysql_db:
|
||
|
state: import
|
||
|
target: "{{ seafile_root_dir }}/seafile-server/seahub/sql/mysql.sql"
|
||
|
name: "{{ seafile_db_seahub }}"
|
||
|
login_host: "{{ seafile_db_server }}"
|
||
|
login_user: sqladmin
|
||
|
login_password: "{{ mysql_admin_pass }}"
|
||
|
loop:
|
||
|
- db: "{{ seafile_db_seahub }}"
|
||
|
file: "{{ seafile_root_dir }}/seafile-server/seahub/sql/mysql.sql"
|
||
|
- db: "{{ seafile_db_seafile }}"
|
||
|
file: "{{ seafile_root_dir }}/seafile-server/sql/mysql/seafile.sql"
|
||
|
- db: "{{ seafile_db_ccnet }}"
|
||
|
file: "{{ seafile_root_dir }}/seafile-server/sql/mysql/ccnet.sql"
|
||
|
when: seafile_install_mode == 'install'
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Deploy systemd services
|
||
|
template: src={{ item }}.service.j2 dest=/etc/systemd/system/{{ item }}.service
|
||
|
with_items:
|
||
|
- seafile
|
||
|
- seahub
|
||
|
notify:
|
||
|
- restart seafile
|
||
|
- restart seahub
|
||
|
register: seafile_systemd_unit
|
||
|
tags: seafile
|
||
|
|
||
|
- name: Reload systemd
|
||
|
command: systemctl daemon-reload
|
||
|
when: seafile_systemd_unit.changed
|
||
|
tags: seafile
|
||
|
|
||
|
|