php_app_separated_data #1
23
roles/koillection/tasks/api.yml
Normal file
23
roles/koillection/tasks/api.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Create API config dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
state: directory
|
||||||
|
dest: "{{ koillection_data_home }}/config/jwt"
|
||||||
|
owner: www-data
|
||||||
|
group: www-data
|
||||||
|
mode: "0o750"
|
||||||
|
|
||||||
|
- name: Link JWT config dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
state: link
|
||||||
|
src: "{{ koillection_data_home }}/config/jwt"
|
||||||
|
dest: "{{ koillection_app_home }}/config/jwt"
|
||||||
|
|
||||||
|
- name: Run lexik jwt
|
||||||
|
become: true
|
||||||
|
become_user: www-data
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "php bin/console lexik:jwt:generate-keypair"
|
||||||
|
chdir: "{{ koillection_app_home }}"
|
||||||
|
creates: "{{ koillection_app_home }}/config/jwt/private.pem"
|
@@ -3,10 +3,16 @@
|
|||||||
- name: Init db
|
- name: Init db
|
||||||
ansible.builtin.include_tasks: db.yml
|
ansible.builtin.include_tasks: db.yml
|
||||||
|
|
||||||
- name: Create application directory
|
## Remove the previous app & install the new version
|
||||||
|
- name: Remove Koillection previous version
|
||||||
|
ansible.builtin.file:
|
||||||
|
state: absent
|
||||||
|
dest: "{{ koillection_app_home }}"
|
||||||
|
|
||||||
|
- name: Create app home
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: directory
|
state: directory
|
||||||
dest: "{{ koillection_home }}"
|
dest: "{{ koillection_app_home }}"
|
||||||
owner: root
|
owner: root
|
||||||
group: www-data
|
group: www-data
|
||||||
mode: "0o750"
|
mode: "0o750"
|
||||||
@@ -15,19 +21,17 @@
|
|||||||
ansible.builtin.unarchive:
|
ansible.builtin.unarchive:
|
||||||
remote_src: true
|
remote_src: true
|
||||||
src: "{{ koillection_url }}"
|
src: "{{ koillection_url }}"
|
||||||
dest: "{{ koillection_home }}"
|
dest: "{{ koillection_app_home }}"
|
||||||
owner: root
|
owner: root
|
||||||
group: www-data
|
group: www-data
|
||||||
mode: "a-rwx,u+rwX,g+rX"
|
mode: "a-rwx,u+rwX,g+rX"
|
||||||
extra_opts: ['--strip-components=1']
|
extra_opts: ['--strip-components=1']
|
||||||
exclude:
|
exclude: "{{ koillection_userdata_app_dirs }}"
|
||||||
- .env
|
|
||||||
- config/jwt
|
|
||||||
|
|
||||||
- name: Put config file
|
- name: Put config file
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: "env.j2"
|
src: "env.j2"
|
||||||
dest: "{{ koillection_home }}/.env"
|
dest: "{{ koillection_app_home }}/.env"
|
||||||
owner: root
|
owner: root
|
||||||
group: www-data
|
group: www-data
|
||||||
mode: "0o640"
|
mode: "0o640"
|
||||||
@@ -35,21 +39,45 @@
|
|||||||
- name: Check writable dirs
|
- name: Check writable dirs
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
state: directory
|
state: directory
|
||||||
dest: "{{ koillection_home }}/{{ item }}"
|
dest: "{{ koillection_app_home }}/{{ item }}"
|
||||||
owner: root
|
owner: root
|
||||||
group: www-data
|
group: www-data
|
||||||
mode: "g+w"
|
mode: "g+w"
|
||||||
recurse: true
|
recurse: true
|
||||||
loop:
|
loop: "{{ koillection_writable_app_dirs }}"
|
||||||
- "var"
|
|
||||||
- "config/jwt"
|
|
||||||
- "public/uploads"
|
|
||||||
- "public/tmp"
|
|
||||||
|
|
||||||
- name: Run lexik jwt
|
## Ensure the data dirs exist, populate them if not
|
||||||
become: true
|
- name: Create data home
|
||||||
become_user: www-data
|
ansible.builtin.file:
|
||||||
ansible.builtin.command:
|
state: directory
|
||||||
cmd: "php bin/console lexik:jwt:generate-keypair"
|
path: "{{ koillection_data_home }}"
|
||||||
chdir: "{{ koillection_home }}"
|
owner: www-data
|
||||||
creates: "{{ koillection_home }}/config/jwt/private.pem"
|
group: www-data
|
||||||
|
mode: "0o750"
|
||||||
|
|
||||||
|
- name: Get data dir
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ koillection_data_home }}/{{ koillection_userdata_app_dirs[0] }}"
|
||||||
|
register: _koillection_userdata_dir_stat
|
||||||
|
|
||||||
|
- name: Install Koillection data dir
|
||||||
|
ansible.builtin.unarchive:
|
||||||
|
remote_src: true
|
||||||
|
src: "{{ koillection_url }}"
|
||||||
|
dest: "{{ koillection_data_home }}"
|
||||||
|
owner: www-data
|
||||||
|
group: www-data
|
||||||
|
mode: "a-rwx,u+rwX,g+rX"
|
||||||
|
extra_opts: ['--strip-components=1']
|
||||||
|
include: "{{ koillection_userdata_app_dirs | map('regex_replace', '^', 'public/') }}"
|
||||||
|
when: not _koillection_userdata_dir_stat.stat.exists
|
||||||
|
|
||||||
|
- name: Link Koillection userdata dirs
|
||||||
|
ansible.builtin.file:
|
||||||
|
state: link
|
||||||
|
src: "{{ koillection_data_home }}/{{ item }}"
|
||||||
|
dest: "{{ koillection_app_home }}/{{ item }}"
|
||||||
|
loop: "{{ koillection_userdata_app_dirs }}"
|
||||||
|
|
||||||
|
- name: Include API activation task
|
||||||
|
ansible.builtin.include_tasks: api.yml
|
||||||
|
@@ -5,4 +5,13 @@ koillection_url: "https://giteu.be/koillection/koillection/releases/download/{{
|
|||||||
|
|
||||||
koillection_access_url: "{{ web_hostname | selectattr('type', 'defined') | selectattr('type', '==', 'koillection') | map(attribute='host') | first }}"
|
koillection_access_url: "{{ web_hostname | selectattr('type', 'defined') | selectattr('type', '==', 'koillection') | map(attribute='host') | first }}"
|
||||||
|
|
||||||
koillection_home: "/srv/http/{{ koillection_access_url }}"
|
# Access path
|
||||||
|
koillection_app_home: "/var/www/{{ koillection_access_url }}"
|
||||||
|
koillection_data_home: "/srv/www-data/{{ koillection_access_url }}"
|
||||||
|
|
||||||
|
# App dirs
|
||||||
|
koillection_writable_app_dirs:
|
||||||
|
- var
|
||||||
|
- public/tmp
|
||||||
|
koillection_userdata_app_dirs:
|
||||||
|
- public/uploads
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
server {
|
server {
|
||||||
{% include './templates/header.conf.j2' %}
|
{% include './templates/header.conf.j2' %}
|
||||||
|
|
||||||
root /srv/http/koi.libertus.eu/public;
|
root /var/www/koi.libertus.eu/public;
|
||||||
|
|
||||||
index index.html index.htm index.php;
|
index index.html index.htm index.php;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user