: add koillection

This commit is contained in:
VC
2025-03-02 14:17:44 +01:00
parent 4bf895ceab
commit 123e62ffac
8 changed files with 175 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
---
- name: Create koillection db role
become_user: postgres
become: true
community.postgresql.postgresql_user:
name: "{{ koillection_pg_role }}"
password: "{{ koillection_pg_password }}"
- name: Create koillection db
become_user: postgres
become: true
community.postgresql.postgresql_db:
name: "{{ koillection_pg_database }}"
owner: "{{ koillection_pg_role }}"

View File

@@ -0,0 +1,55 @@
---
- name: Init db
ansible.builtin.include_tasks: db.yml
- name: Create application directory
ansible.builtin.file:
state: directory
dest: "{{ koillection_home }}"
owner: root
group: www-data
mode: "0o750"
- name: Install koillection application
ansible.builtin.unarchive:
remote_src: true
src: "{{ koillection_url }}"
dest: "{{ koillection_home }}"
owner: root
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']
exclude:
- .env
- config/jwt
- name: Put config file
ansible.builtin.template:
src: "env.j2"
dest: "{{ koillection_home }}/.env"
owner: root
group: www-data
mode: "0o640"
- name: Check writable dirs
ansible.builtin.file:
state: directory
dest: "{{ koillection_home }}/{{ item }}"
owner: root
group: www-data
mode: "g+w"
recurse: true
loop:
- "var"
- "config/jwt"
- "public/uploads"
- "public/tmp"
- name: Run lexik jwt
become: true
become_user: www-data
ansible.builtin.command:
cmd: "php bin/console lexik:jwt:generate-keypair"
chdir: "{{ koillection_home }}"
creates: "{{ koillection_home }}/config/jwt/private.pem"

View File

@@ -0,0 +1,44 @@
########################################################################################################
# WEB
#
# APP_DEBUG=1 displays detailed error message
#
# APP_SECRET is a random string used for security, you can use for example openssl rand -base64 21
# APP_SECRET is automatically generated when using Docker
#
# PHP_TZ, see possible values here https://www.w3schools.com/php/php_ref_timezones.asp
########################################################################################################
APP_DEBUG=0
APP_ENV=prod
APP_SECRET={{ koillection_app_secret }}
HTTPS_ENABLED=1
UPLOAD_MAX_FILESIZE=20M
PHP_MEMORY_LIMIT=512M
PHP_TZ=Europe/Paris
########################################################################################################
# API
#
#
# JWT_PASSPHRASE is a random string used for security, you can use for example openssl rand -base64 21
# JWT_PASSPHRASE is automatically generated when using Docker
########################################################################################################
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE={{ koillection_jwt_passphrase }}
########################################################################################################
# DATABASE
########################################################################################################
DB_DRIVER=pdo_pgsql
DB_NAME={{ koillection_pg_database }}
DB_HOST=localhost
DB_PORT=5432
DB_USER={{ koillection_pg_role }}
DB_PASSWORD={{ koillection_pg_password }}
DB_VERSION={{ postgres_pg_version }}

View File

@@ -0,0 +1,8 @@
---
koillection_version: "1.6.10"
koillection_url: "https://giteu.be/koillection/koillection/releases/download/{{ koillection_version }}/koillection-{{ koillection_version }}.tar.gz"
koillection_access_url: "{{ web_hostname | selectattr('type', 'defined') | selectattr('type', '==', 'koillection') | map(attribute='host') | first }}"
koillection_home: "/srv/http/{{ koillection_access_url }}"