kimai: lint and fixes

This commit is contained in:
uumas
2024-07-26 02:29:36 +03:00
parent 5613fa4189
commit 3412ca53d9
4 changed files with 50 additions and 56 deletions

View File

@@ -1,4 +1,3 @@
---
dependencies:
- composer

View File

@@ -0,0 +1,43 @@
---
- name: Clone kimai git repo
ansible.builtin.git:
repo: "https://github.com/kevinpapst/kimai2.git"
dest: "{{ kimai_installdir }}"
version: main
- name: Install kimai dependencies using composer
community.general.composer:
working_dir: "{{ kimai_installdir }}"
composer_executable: "{{ composer_path | default(omit) }}"
executable: "{{ kimai_php_executable | default(omit) }}"
- name: Configure kimai database
ansible.builtin.lineinfile:
path: "{{ kimai_installdir }}/.env"
regexp: "^DATABASE_URL=.*$"
line: "\
DATABASE_URL=mysql://{{ kimai_db_user | default(kimai_db) }}:{{ kimai_db_pw }}\
@{{ kimai_db_host | default('localhost') }}:3306/{{ kimai_db }}\
?charset=utf8&serverVersion={{ kimai_db_server }}"
- name: Run kimai install script
ansible.builtin.command: "{{ kimai_php_executable + ' ' if kimai_php_executable is defined else '' }}bin/console kimai:install -n"
args:
chdir: "{{ kimai_installdir }}"
register: kimai_install
changed_when: "'[OK] Already at the latest version' not in kimai_install.stdout"
failed_when: "'[OK] Congratulations! Successfully installed Kimai' not in kimai_install.stdout"
- name: Add symlink to kimai public in webroot
ansible.builtin.file:
src: "{{ kimai_installdir }}/public"
dest: "{{ kimai_webroot }}/kimai"
state: link
force: true
- name: Configure .htaccess in webroot
ansible.builtin.template:
src: htaccess.j2
dest: "{{ kimai_webroot }}/.htaccess"
mode: "0644"

View File

@@ -1,55 +0,0 @@
---
- name: Clone kimai git repo
git:
repo: 'https://github.com/kevinpapst/kimai2.git'
dest: "{{ kimai_installdir }}"
version: 'master'
- name: Install kimai dependencies using composer
composer:
working_dir: "{{ kimai_installdir }}"
composer_executable: "{{ composer_path | default(omit) }}"
- name: Configure kimai database
lineinfile:
path: "{{ kimai_installdir }}/.env"
regexp: "^DATABASE_URL=.*$"
line: "DATABASE_URL=mysql://{{ kimai_db_user | default(kimai_db) }}:{{ kimai_db_pw }}@{{ kimai_db_host | default('localhost') }}:3306/{{ kimai_db }}?charset=utf8&serverVersion={{ kimai_db_server }}"
- name: Run kimai install script
command: "bin/console kimai:install -n"
args:
chdir: "{{ kimai_installdir }}"
register: kimai_install
changed_when: "'[OK] Already at the latest version' not in kimai_install.stdout"
failed_when: "'[OK] Congratulations! Successfully installed Kimai' not in kimai_install.stdout"
- name: Get webroot stat
stat:
path: "{{ kimai_webroot }}"
register: kimai_webroot_stat
- name: Delete kimai webroot if it's a directory
file:
path: "{{ kimai_webroot }}"
state: absent
when: kimai_webroot_stat.stat.isdir
- name: Symlink webroot to public
file:
src: "{{ kimai_installdir }}/public"
dest: "{{ kimai_webroot }}"
state: link
force: yes
- name: Set https redirect
blockinfile:
path: "{{ kimai_webroot }}/.htaccess"
marker: "# {mark} ANSIBLE MANAGED BLOCK http -> https"
block: |
RewriteEngine On
RewriteCond %{ENV:HTTPS} !on
RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
insertbefore: BOF

View File

@@ -0,0 +1,7 @@
RewriteEngine On
RewriteCond %{ENV:HTTPS} !on
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_URI} !^/kimai/
RewriteRule ^(.*)$ /kimai/$1 [L]